Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
7aeb2fcf
Commit
7aeb2fcf
authored
Aug 09, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed test breaks.
parent
20727c8c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
18 deletions
+46
-18
HtmlBase.php
framework/yii/helpers/HtmlBase.php
+8
-6
HtmlTest.php
tests/unit/framework/helpers/HtmlTest.php
+38
-12
No files found.
framework/yii/helpers/HtmlBase.php
View file @
7aeb2fcf
...
@@ -761,9 +761,10 @@ class HtmlBase
...
@@ -761,9 +761,10 @@ class HtmlBase
if
(
$formatter
!==
null
)
{
if
(
$formatter
!==
null
)
{
$lines
[]
=
call_user_func
(
$formatter
,
$index
,
$label
,
$name
,
$checked
,
$value
);
$lines
[]
=
call_user_func
(
$formatter
,
$index
,
$label
,
$name
,
$checked
,
$value
);
}
else
{
}
else
{
$checkbox
=
static
::
checkbox
(
$name
,
$checked
,
array
(
'value'
=>
$value
));
$lines
[]
=
static
::
checkbox
(
$name
,
$checked
,
array
(
$content
=
static
::
label
(
$checkbox
.
' '
.
(
$encode
?
static
::
encode
(
$label
)
:
$label
));
'value'
=>
$value
,
$lines
[]
=
static
::
tag
(
'div'
,
$content
,
array
(
'class'
=>
'checkbox'
));
'label'
=>
$encode
?
static
::
encode
(
$label
)
:
$label
,
));
}
}
$index
++
;
$index
++
;
}
}
...
@@ -819,9 +820,10 @@ class HtmlBase
...
@@ -819,9 +820,10 @@ class HtmlBase
if
(
$formatter
!==
null
)
{
if
(
$formatter
!==
null
)
{
$lines
[]
=
call_user_func
(
$formatter
,
$index
,
$label
,
$name
,
$checked
,
$value
);
$lines
[]
=
call_user_func
(
$formatter
,
$index
,
$label
,
$name
,
$checked
,
$value
);
}
else
{
}
else
{
$radio
=
static
::
radio
(
$name
,
$checked
,
array
(
'value'
=>
$value
));
$lines
[]
=
static
::
radio
(
$name
,
$checked
,
array
(
$content
=
static
::
label
(
$radio
.
' '
.
(
$encode
?
static
::
encode
(
$label
)
:
$label
));
'value'
=>
$value
,
$lines
[]
=
static
::
tag
(
'div'
,
$content
,
array
(
'class'
=>
'radio'
));
'label'
=>
$encode
?
static
::
encode
(
$label
)
:
$label
,
));
}
}
$index
++
;
$index
++
;
}
}
...
...
tests/unit/framework/helpers/HtmlTest.php
View file @
7aeb2fcf
...
@@ -210,6 +210,19 @@ class HtmlTest extends TestCase
...
@@ -210,6 +210,19 @@ class HtmlTest extends TestCase
$this
->
assertEquals
(
'<input type="radio" name="test" value="1">'
,
Html
::
radio
(
'test'
));
$this
->
assertEquals
(
'<input type="radio" name="test" value="1">'
,
Html
::
radio
(
'test'
));
$this
->
assertEquals
(
'<input type="radio" class="a" name="test" checked>'
,
Html
::
radio
(
'test'
,
true
,
array
(
'class'
=>
'a'
,
'value'
=>
null
)));
$this
->
assertEquals
(
'<input type="radio" class="a" name="test" checked>'
,
Html
::
radio
(
'test'
,
true
,
array
(
'class'
=>
'a'
,
'value'
=>
null
)));
$this
->
assertEquals
(
'<input type="hidden" name="test" value="0"><input type="radio" class="a" name="test" value="2" checked>'
,
Html
::
radio
(
'test'
,
true
,
array
(
'class'
=>
'a'
,
'uncheck'
=>
'0'
,
'value'
=>
2
)));
$this
->
assertEquals
(
'<input type="hidden" name="test" value="0"><input type="radio" class="a" name="test" value="2" checked>'
,
Html
::
radio
(
'test'
,
true
,
array
(
'class'
=>
'a'
,
'uncheck'
=>
'0'
,
'value'
=>
2
)));
$this
->
assertEquals
(
'<div class="radio"><label class="bbb"><input type="checkbox" class="a" name="test" checked> ccc</label></div>'
,
Html
::
radio
(
'test'
,
true
,
array
(
'class'
=>
'a'
,
'value'
=>
null
,
'label'
=>
'ccc'
,
'labelOptions'
=>
array
(
'class'
=>
'bbb'
),
)));
$this
->
assertEquals
(
'<input type="hidden" name="test" value="0"><div class="radio"><label><input type="checkbox" class="a" name="test" value="2" checked></label></div>'
,
Html
::
radio
(
'test'
,
true
,
array
(
'class'
=>
'a'
,
'uncheck'
=>
'0'
,
'label'
=>
'ccc'
,
'value'
=>
2
,
)));
}
}
public
function
testCheckbox
()
public
function
testCheckbox
()
...
@@ -217,6 +230,19 @@ class HtmlTest extends TestCase
...
@@ -217,6 +230,19 @@ class HtmlTest extends TestCase
$this
->
assertEquals
(
'<input type="checkbox" name="test" value="1">'
,
Html
::
checkbox
(
'test'
));
$this
->
assertEquals
(
'<input type="checkbox" name="test" value="1">'
,
Html
::
checkbox
(
'test'
));
$this
->
assertEquals
(
'<input type="checkbox" class="a" name="test" checked>'
,
Html
::
checkbox
(
'test'
,
true
,
array
(
'class'
=>
'a'
,
'value'
=>
null
)));
$this
->
assertEquals
(
'<input type="checkbox" class="a" name="test" checked>'
,
Html
::
checkbox
(
'test'
,
true
,
array
(
'class'
=>
'a'
,
'value'
=>
null
)));
$this
->
assertEquals
(
'<input type="hidden" name="test" value="0"><input type="checkbox" class="a" name="test" value="2" checked>'
,
Html
::
checkbox
(
'test'
,
true
,
array
(
'class'
=>
'a'
,
'uncheck'
=>
'0'
,
'value'
=>
2
)));
$this
->
assertEquals
(
'<input type="hidden" name="test" value="0"><input type="checkbox" class="a" name="test" value="2" checked>'
,
Html
::
checkbox
(
'test'
,
true
,
array
(
'class'
=>
'a'
,
'uncheck'
=>
'0'
,
'value'
=>
2
)));
$this
->
assertEquals
(
'<div class="checkbox"><label class="bbb"><input type="checkbox" class="a" name="test" checked> ccc</label></div>'
,
Html
::
checkbox
(
'test'
,
true
,
array
(
'class'
=>
'a'
,
'value'
=>
null
,
'label'
=>
'ccc'
,
'labelOptions'
=>
array
(
'class'
=>
'bbb'
),
)));
$this
->
assertEquals
(
'<input type="hidden" name="test" value="0"><div class="checkbox"><label><input type="checkbox" class="a" name="test" value="2" checked></label></div>'
,
Html
::
checkbox
(
'test'
,
true
,
array
(
'class'
=>
'a'
,
'uncheck'
=>
'0'
,
'label'
=>
'ccc'
,
'value'
=>
2
,
)));
}
}
public
function
testDropDownList
()
public
function
testDropDownList
()
...
@@ -299,20 +325,20 @@ EOD;
...
@@ -299,20 +325,20 @@ EOD;
$this
->
assertEquals
(
''
,
Html
::
checkboxList
(
'test'
));
$this
->
assertEquals
(
''
,
Html
::
checkboxList
(
'test'
));
$expected
=
<<<EOD
$expected
=
<<<EOD
<
label><input type="checkbox" name="test[]" value="value1"> text1</label
>
<
div class="checkbox"><label><input type="checkbox" name="test[]" value="value1"> text1</label></div
>
<
label><input type="checkbox" name="test[]" value="value2" checked> text2</label
>
<
div class="checkbox"><label><input type="checkbox" name="test[]" value="value2" checked> text2</label></div
>
EOD;
EOD;
$this
->
assertEqualsWithoutLE
(
$expected
,
Html
::
checkboxList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
()));
$this
->
assertEqualsWithoutLE
(
$expected
,
Html
::
checkboxList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
()));
$expected
=
<<<EOD
$expected
=
<<<EOD
<
label><input type="checkbox" name="test[]" value="value1<>"> text1<></label
>
<
div class="checkbox"><label><input type="checkbox" name="test[]" value="value1<>"> text1<></label></div
>
<
label><input type="checkbox" name="test[]" value="value 2"> text 2</label
>
<
div class="checkbox"><label><input type="checkbox" name="test[]" value="value 2"> text 2</label></div
>
EOD;
EOD;
$this
->
assertEqualsWithoutLE
(
$expected
,
Html
::
checkboxList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems2
()));
$this
->
assertEqualsWithoutLE
(
$expected
,
Html
::
checkboxList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems2
()));
$expected
=
<<<EOD
$expected
=
<<<EOD
<
input type="hidden" name="test" value="0"><label><input type="checkbox" name="test[]" value="value1"> text1</label
><br>
<
div class="checkbox"><input type="hidden" name="test" value="0"><label><input type="checkbox" name="test[]" value="value1"> text1</label></div
><br>
<
label><input type="checkbox" name="test[]" value="value2" checked> text2</label
>
<
div class="checkbox"><label><input type="checkbox" name="test[]" value="value2" checked> text2</label></div
>
EOD;
EOD;
$this
->
assertEqualsWithoutLE
(
$expected
,
Html
::
checkboxList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
(),
array
(
$this
->
assertEqualsWithoutLE
(
$expected
,
Html
::
checkboxList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
(),
array
(
'separator'
=>
"<br>
\n
"
,
'separator'
=>
"<br>
\n
"
,
...
@@ -335,20 +361,20 @@ EOD;
...
@@ -335,20 +361,20 @@ EOD;
$this
->
assertEquals
(
''
,
Html
::
radioList
(
'test'
));
$this
->
assertEquals
(
''
,
Html
::
radioList
(
'test'
));
$expected
=
<<<EOD
$expected
=
<<<EOD
<
label><input type="radio" name="test" value="value1"> text1</label
>
<
div class="radio"><label><input type="radio" name="test" value="value1"> text1</label></div
>
<
label><input type="radio" name="test" value="value2" checked> text2</label
>
<
div class="radio"><label><input type="radio" name="test" value="value2" checked> text2</label></div
>
EOD;
EOD;
$this
->
assertEqualsWithoutLE
(
$expected
,
Html
::
radioList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
()));
$this
->
assertEqualsWithoutLE
(
$expected
,
Html
::
radioList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
()));
$expected
=
<<<EOD
$expected
=
<<<EOD
<
label><input type="radio" name="test" value="value1<>"> text1<></label
>
<
div class="radio"><label><input type="radio" name="test" value="value1<>"> text1<></label></div
>
<
label><input type="radio" name="test" value="value 2"> text 2</label
>
<
div class="radio"><label><input type="radio" name="test" value="value 2"> text 2</label></div
>
EOD;
EOD;
$this
->
assertEqualsWithoutLE
(
$expected
,
Html
::
radioList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems2
()));
$this
->
assertEqualsWithoutLE
(
$expected
,
Html
::
radioList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems2
()));
$expected
=
<<<EOD
$expected
=
<<<EOD
<
input type="hidden" name="test" value="0"><label><input type="radio" name="test" value="value1"> text1</label
><br>
<
div class="radio"><input type="hidden" name="test" value="0"><label><input type="radio" name="test" value="value1"> text1</label></div
><br>
<
label><input type="radio" name="test" value="value2" checked> text2</label
>
<
div class="radio"><label><input type="radio" name="test" value="value2" checked> text2</label></div
>
EOD;
EOD;
$this
->
assertEqualsWithoutLE
(
$expected
,
Html
::
radioList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
(),
array
(
$this
->
assertEqualsWithoutLE
(
$expected
,
Html
::
radioList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
(),
array
(
'separator'
=>
"<br>
\n
"
,
'separator'
=>
"<br>
\n
"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment