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
5d309c20
Commit
5d309c20
authored
Mar 13, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added unit tests for boolean attributes
fixes #1022
parent
34cfb356
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
HtmlTest.php
tests/unit/framework/helpers/HtmlTest.php
+7
-0
ActiveFormTest.php
tests/unit/framework/widgets/ActiveFormTest.php
+53
-0
No files found.
tests/unit/framework/helpers/HtmlTest.php
View file @
5d309c20
...
...
@@ -592,6 +592,13 @@ EOD;
$this
->
assertTrue
(
!
array_key_exists
(
'style'
,
$options
));
}
public
function
testBooleanAttributes
()
{
$this
->
assertEquals
(
'<input type="email" name="mail">'
,
Html
::
input
(
'email'
,
'mail'
,
null
,
[
'required'
=>
false
]));
$this
->
assertEquals
(
'<input type="email" name="mail" required>'
,
Html
::
input
(
'email'
,
'mail'
,
null
,
[
'required'
=>
true
]));
$this
->
assertEquals
(
'<input type="email" name="mail" required="hi">'
,
Html
::
input
(
'email'
,
'mail'
,
null
,
[
'required'
=>
'hi'
]));
}
protected
function
getDataItems
()
{
return
[
...
...
tests/unit/framework/widgets/ActiveFormTest.php
0 → 100644
View file @
5d309c20
<?php
/**
* @author Carsten Brandt <mail@cebe.cc>
*/
namespace
yiiunit\framework\widgets
;
use
yii\base\DynamicModel
;
use
yii\widgets\ActiveForm
;
/**
* @group widgets
*/
class
ActiveFormTest
extends
\yiiunit\TestCase
{
protected
function
setUp
()
{
$this
->
mockApplication
();
}
public
function
testBooleanAttributes
()
{
$o
=
[
'template'
=>
'{input}'
];
$model
=
new
DynamicModel
([
'name'
]);
ob_start
();
$form
=
new
ActiveForm
([
'action'
=>
'./'
]);
ob_end_clean
();
$this
->
assertEquals
(
<<<EOF
<div class="form-group field-dynamicmodel-name">
<input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]" required>
</div>
EOF
,
(
string
)
$form
->
field
(
$model
,
'name'
,
$o
)
->
input
(
'email'
,
[
'required'
=>
true
]));
$this
->
assertEquals
(
<<<EOF
<div class="form-group field-dynamicmodel-name">
<input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]">
</div>
EOF
,
(
string
)
$form
->
field
(
$model
,
'name'
,
$o
)
->
input
(
'email'
,
[
'required'
=>
false
]));
$this
->
assertEquals
(
<<<EOF
<div class="form-group field-dynamicmodel-name">
<input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]">
</div>
EOF
,
(
string
)
$form
->
field
(
$model
,
'name'
,
$o
)
->
input
(
'email'
,
[
'required'
=>
false
]));
}
}
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