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
7654fff2
Commit
7654fff2
authored
Dec 26, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unit test for ActiveRecord::updateAttributes().
parent
7eccd9d9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
ActiveRecordTestTrait.php
tests/unit/framework/ar/ActiveRecordTestTrait.php
+34
-0
No files found.
tests/unit/framework/ar/ActiveRecordTestTrait.php
View file @
7654fff2
...
@@ -671,6 +671,40 @@ trait ActiveRecordTestTrait
...
@@ -671,6 +671,40 @@ trait ActiveRecordTestTrait
$this
->
assertEquals
(
0
,
$ret
);
$this
->
assertEquals
(
0
,
$ret
);
}
}
public
function
testUpdateAttributes
()
{
$customerClass
=
$this
->
getCustomerClass
();
/** @var TestCase|ActiveRecordTestTrait $this */
// save
$customer
=
$this
->
callCustomerFind
(
2
);
$this
->
assertTrue
(
$customer
instanceof
$customerClass
);
$this
->
assertEquals
(
'user2'
,
$customer
->
name
);
$this
->
assertFalse
(
$customer
->
isNewRecord
);
static
::
$afterSaveNewRecord
=
null
;
static
::
$afterSaveInsert
=
null
;
$customer
->
updateAttributes
([
'name'
=>
'user2x'
]);
$this
->
afterSave
();
$this
->
assertEquals
(
'user2x'
,
$customer
->
name
);
$this
->
assertFalse
(
$customer
->
isNewRecord
);
$this
->
assertFalse
(
static
::
$afterSaveNewRecord
);
$this
->
assertFalse
(
static
::
$afterSaveInsert
);
$customer2
=
$this
->
callCustomerFind
(
2
);
$this
->
assertEquals
(
'user2x'
,
$customer2
->
name
);
$customer
=
$this
->
callCustomerFind
(
1
);
$this
->
assertEquals
(
'user1'
,
$customer
->
name
);
$this
->
assertEquals
(
1
,
$customer
->
status
);
$customer
->
name
=
'user1x'
;
$customer
->
status
=
2
;
$customer
->
updateAttributes
([
'name'
]);
$this
->
assertEquals
(
'user1x'
,
$customer
->
name
);
$this
->
assertEquals
(
2
,
$customer
->
status
);
$customer
=
$this
->
callCustomerFind
(
1
);
$this
->
assertEquals
(
'user1x'
,
$customer
->
name
);
$this
->
assertEquals
(
1
,
$customer
->
status
);
}
public
function
testUpdateCounters
()
public
function
testUpdateCounters
()
{
{
$orderItemClass
=
$this
->
getOrderItemClass
();
$orderItemClass
=
$this
->
getOrderItemClass
();
...
...
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