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
08be6964
Commit
08be6964
authored
Apr 23, 2013
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed Html test under Windows (line endings)
parent
3e2e4afa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
19 deletions
+27
-19
HtmlTest.php
tests/unit/framework/helpers/HtmlTest.php
+27
-19
No files found.
tests/unit/framework/helpers/HtmlTest.php
View file @
08be6964
...
...
@@ -22,6 +22,14 @@ class HtmlTest extends \yii\test\TestCase
));
}
public
function
assertEqualsWithoutLE
(
$expected
,
$actual
)
{
$expected
=
str_replace
(
"
\r\n
"
,
"
\n
"
,
$expected
);
$actual
=
str_replace
(
"
\r\n
"
,
"
\n
"
,
$actual
);
$this
->
assertEquals
(
$expected
,
$actual
);
}
public
function
tearDown
()
{
Yii
::
$app
=
null
;
...
...
@@ -240,21 +248,21 @@ class HtmlTest extends \yii\test\TestCase
</select>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
dropDownList
(
'test'
));
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
dropDownList
(
'test'
));
$expected
=
<<<EOD
<select name="test">
<option value="value1">text1</option>
<option value="value2">text2</option>
</select>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
dropDownList
(
'test'
,
null
,
$this
->
getDataItems
()));
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
dropDownList
(
'test'
,
null
,
$this
->
getDataItems
()));
$expected
=
<<<EOD
<select name="test">
<option value="value1">text1</option>
<option value="value2" selected="selected">text2</option>
</select>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
dropDownList
(
'test'
,
'value2'
,
$this
->
getDataItems
()));
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
dropDownList
(
'test'
,
'value2'
,
$this
->
getDataItems
()));
}
public
function
testListBox
()
...
...
@@ -264,48 +272,48 @@ EOD;
</select>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
listBox
(
'test'
));
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
listBox
(
'test'
));
$expected
=
<<<EOD
<select name="test" size="5">
<option value="value1">text1</option>
<option value="value2">text2</option>
</select>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
listBox
(
'test'
,
null
,
$this
->
getDataItems
(),
array
(
'size'
=>
5
)));
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
listBox
(
'test'
,
null
,
$this
->
getDataItems
(),
array
(
'size'
=>
5
)));
$expected
=
<<<EOD
<select name="test" size="4">
<option value="value1<>">text1<></option>
<option value="value 2">text 2</option>
</select>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
listBox
(
'test'
,
null
,
$this
->
getDataItems2
()));
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
listBox
(
'test'
,
null
,
$this
->
getDataItems2
()));
$expected
=
<<<EOD
<select name="test" size="4">
<option value="value1">text1</option>
<option value="value2" selected="selected">text2</option>
</select>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
listBox
(
'test'
,
'value2'
,
$this
->
getDataItems
()));
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
listBox
(
'test'
,
'value2'
,
$this
->
getDataItems
()));
$expected
=
<<<EOD
<select name="test" size="4">
<option value="value1" selected="selected">text1</option>
<option value="value2" selected="selected">text2</option>
</select>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
listBox
(
'test'
,
array
(
'value1'
,
'value2'
),
$this
->
getDataItems
()));
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
listBox
(
'test'
,
array
(
'value1'
,
'value2'
),
$this
->
getDataItems
()));
$expected
=
<<<EOD
<select name="test[]" multiple="multiple" size="4">
</select>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
listBox
(
'test'
,
null
,
array
(),
array
(
'multiple'
=>
true
)));
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
listBox
(
'test'
,
null
,
array
(),
array
(
'multiple'
=>
true
)));
$expected
=
<<<EOD
<input type="hidden" name="test" value="0" /><select name="test" size="4">
</select>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
listBox
(
'test'
,
''
,
array
(),
array
(
'unselect'
=>
'0'
)));
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
listBox
(
'test'
,
''
,
array
(),
array
(
'unselect'
=>
'0'
)));
}
public
function
testCheckboxList
()
...
...
@@ -316,19 +324,19 @@ EOD;
<label><input type="checkbox" name="test[]" value="value1" /> text1</label>
<label><input type="checkbox" name="test[]" value="value2" checked="checked" /> text2</label>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
checkboxList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
()));
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
checkboxList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
()));
$expected
=
<<<EOD
<label><input type="checkbox" name="test[]" value="value1<>" /> text1<></label>
<label><input type="checkbox" name="test[]" value="value 2" /> text 2</label>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
checkboxList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems2
()));
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
checkboxList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems2
()));
$expected
=
<<<EOD
<input type="hidden" name="test" value="0" /><label><input type="checkbox" name="test[]" value="value1" /> text1</label><br />
<label><input type="checkbox" name="test[]" value="value2" checked="checked" /> text2</label>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
checkboxList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
(),
array
(
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
checkboxList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
(),
array
(
'separator'
=>
"<br />
\n
"
,
'unselect'
=>
'0'
,
)));
...
...
@@ -337,7 +345,7 @@ EOD;
0<label>text1 <input type="checkbox" name="test[]" value="value1" /></label>
1<label>text2 <input type="checkbox" name="test[]" value="value2" checked="checked" /></label>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
checkboxList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
(),
array
(
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
checkboxList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
(),
array
(
'item'
=>
function
(
$index
,
$label
,
$name
,
$checked
,
$value
)
{
return
$index
.
Html
::
label
(
$label
.
' '
.
Html
::
checkbox
(
$name
,
$checked
,
$value
));
}
...
...
@@ -352,19 +360,19 @@ EOD;
<label><input type="radio" name="test" value="value1" /> text1</label>
<label><input type="radio" name="test" value="value2" checked="checked" /> text2</label>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
radioList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
()));
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
radioList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
()));
$expected
=
<<<EOD
<label><input type="radio" name="test" value="value1<>" /> text1<></label>
<label><input type="radio" name="test" value="value 2" /> text 2</label>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
radioList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems2
()));
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
radioList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems2
()));
$expected
=
<<<EOD
<input type="hidden" name="test" value="0" /><label><input type="radio" name="test" value="value1" /> text1</label><br />
<label><input type="radio" name="test" value="value2" checked="checked" /> text2</label>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
radioList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
(),
array
(
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
radioList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
(),
array
(
'separator'
=>
"<br />
\n
"
,
'unselect'
=>
'0'
,
)));
...
...
@@ -373,7 +381,7 @@ EOD;
0<label>text1 <input type="radio" name="test" value="value1" /></label>
1<label>text2 <input type="radio" name="test" value="value2" checked="checked" /></label>
EOD;
$this
->
assertEquals
(
$expected
,
Html
::
radioList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
(),
array
(
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
radioList
(
'test'
,
array
(
'value2'
),
$this
->
getDataItems
(),
array
(
'item'
=>
function
(
$index
,
$label
,
$name
,
$checked
,
$value
)
{
return
$index
.
Html
::
label
(
$label
.
' '
.
Html
::
radio
(
$name
,
$checked
,
$value
));
}
...
...
@@ -420,7 +428,7 @@ EOD;
'group12'
=>
array
(
'class'
=>
'group'
),
),
);
$this
->
assertEquals
(
$expected
,
Html
::
renderSelectOptions
(
array
(
'value111'
,
'value1'
),
$data
,
$attributes
));
$this
->
assertEquals
WithoutLE
(
$expected
,
Html
::
renderSelectOptions
(
array
(
'value111'
,
'value1'
),
$data
,
$attributes
));
}
public
function
testRenderAttributes
()
...
...
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