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
df6176ed
Commit
df6176ed
authored
Sep 18, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added unit test for Model::load()
parent
128ee07b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
Speaker.php
tests/unit/data/base/Speaker.php
+7
-0
ModelTest.php
tests/unit/framework/base/ModelTest.php
+26
-0
No files found.
tests/unit/data/base/Speaker.php
View file @
df6176ed
...
...
@@ -17,6 +17,13 @@ class Speaker extends Model
protected
$protectedProperty
;
private
$_privateProperty
;
public
static
$formName
=
'Speaker'
;
public
function
formName
()
{
return
static
::
$formName
;
}
public
function
attributeLabels
()
{
return
array
(
...
...
tests/unit/framework/base/ModelTest.php
View file @
df6176ed
...
...
@@ -75,6 +75,32 @@ class ModelTest extends TestCase
$this
->
assertEquals
(
'Qiang'
,
$speaker
->
firstName
);
}
public
function
testLoad
()
{
$singer
=
new
Singer
();
$this
->
assertEquals
(
'Singer'
,
$singer
->
formName
());
$post
=
array
(
'firstName'
=>
'Qiang'
);
Speaker
::
$formName
=
''
;
$model
=
new
Speaker
();
$model
->
setScenario
(
'test'
);
$this
->
assertTrue
(
$model
->
load
(
$post
));
$this
->
assertEquals
(
'Qiang'
,
$model
->
firstName
);
Speaker
::
$formName
=
'Speaker'
;
$model
=
new
Speaker
();
$model
->
setScenario
(
'test'
);
$this
->
assertTrue
(
$model
->
load
(
array
(
'Speaker'
=>
$post
)));
$this
->
assertEquals
(
'Qiang'
,
$model
->
firstName
);
Speaker
::
$formName
=
'Speaker'
;
$model
=
new
Speaker
();
$model
->
setScenario
(
'test'
);
$this
->
assertFalse
(
$model
->
load
(
array
(
'Example'
=>
array
())));
$this
->
assertEquals
(
''
,
$model
->
firstName
);
}
public
function
testActiveAttributes
()
{
// by default mass assignment doesn't work at all
...
...
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