Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102139440
DifferentialUnitFieldSpecification.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Feb 17, 11:54
Size
2 KB
Mime Type
text/x-php
Expires
Wed, Feb 19, 11:54 (2 d)
Engine
blob
Format
Raw Data
Handle
24291462
Attached To
rPH Phabricator
DifferentialUnitFieldSpecification.php
View Options
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final
class
DifferentialUnitFieldSpecification
extends
DifferentialFieldSpecification
{
public
function
shouldAppearOnRevisionView
()
{
return
true
;
}
public
function
renderLabelForRevisionView
()
{
return
'Unit:'
;
}
public
function
getRequiredDiffProperties
()
{
return
array
(
'arc:unit'
);
}
public
function
renderValueForRevisionView
()
{
$diff
=
$this
->
getDiff
();
$ustar
=
DifferentialRevisionUpdateHistoryView
::
renderDiffUnitStar
(
$diff
);
$umsg
=
DifferentialRevisionUpdateHistoryView
::
getDiffUnitMessage
(
$diff
);
$postponed_count
=
0
;
$udata
=
$this
->
getDiffProperty
(
'arc:unit'
);
$utail
=
null
;
if
(
$udata
)
{
$unit_messages
=
array
();
foreach
(
$udata
as
$test
)
{
$name
=
idx
(
$test
,
'name'
);
$result
=
idx
(
$test
,
'result'
);
if
(
$result
!=
DifferentialUnitTestResult
::
RESULT_POSTPONED
&&
$result
!=
DifferentialUnitTestResult
::
RESULT_PASS
)
{
$userdata
=
phutil_utf8_shorten
(
idx
(
$test
,
'userdata'
),
256
);
$userdata
=
phutil_escape_html
(
$userdata
);
$userdata
=
str_replace
(
"
\n
"
,
'<br />'
,
$userdata
);
$unit_messages
[]
=
'<li>'
.
'<span class="unit-result-'
.
phutil_escape_html
(
$result
).
'">'
.
phutil_escape_html
(
ucwords
(
$result
)).
'</span>'
.
' '
.
phutil_escape_html
(
$name
).
'<p>'
.
$userdata
.
'</p>'
.
'</li>'
;
}
else
if
(
$result
==
DifferentialUnitTestResult
::
RESULT_POSTPONED
)
{
$postponed_count
++;
}
}
}
if
(
$unit_messages
)
{
$utail
=
'<div class="differential-unit-block">'
.
'<ul>'
.
implode
(
"
\n
"
,
$unit_messages
).
'</ul>'
.
'</div>'
;
}
if
(
$postponed_count
>
0
&&
$diff
->
getUnitStatus
()
==
DifferentialUnitStatus
::
UNIT_POSTPONED
)
{
$umsg
=
$postponed_count
.
' '
.
$umsg
;
}
return
$ustar
.
' '
.
$umsg
.
$utail
;
}
}
Event Timeline
Log In to Comment