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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
31fece56
Commit
31fece56
authored
Jan 10, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed test break
parent
6d0f1e4c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
ActiveRecordTest.php
tests/unit/extensions/elasticsearch/ActiveRecordTest.php
+3
-0
ActiveRecordTestTrait.php
tests/unit/framework/ar/ActiveRecordTestTrait.php
+31
-0
No files found.
tests/unit/extensions/elasticsearch/ActiveRecordTest.php
View file @
31fece56
...
...
@@ -47,6 +47,7 @@ class ActiveRecordTest extends ElasticSearchTestCase
if
(
$db
->
createCommand
()
->
indexExists
(
'yiitest'
))
{
$db
->
createCommand
()
->
deleteIndex
(
'yiitest'
);
}
$db
->
createCommand
()
->
createIndex
(
'yiitest'
);
$command
=
$db
->
createCommand
();
Customer
::
setUpMapping
(
$command
);
...
...
@@ -54,6 +55,8 @@ class ActiveRecordTest extends ElasticSearchTestCase
Order
::
setUpMapping
(
$command
);
OrderItem
::
setUpMapping
(
$command
);
$db
->
createCommand
()
->
flushIndex
(
'yiitest'
);
$customer
=
new
Customer
();
$customer
->
id
=
1
;
$customer
->
setAttributes
([
'email'
=>
'user1@example.com'
,
'name'
=>
'user1'
,
'address'
=>
'address1'
,
'status'
=>
1
],
false
);
...
...
tests/unit/framework/ar/ActiveRecordTestTrait.php
View file @
31fece56
...
...
@@ -487,6 +487,37 @@ trait ActiveRecordTestTrait
public
function
testFindEagerViaRelationPreserveOrder
()
{
/** @var TestCase|ActiveRecordTestTrait $this */
/*
Item (name, category_id)
Order (customer_id, create_time, total)
OrderItem (order_id, item_id, quantity, subtotal)
Result should be the following:
Order 1: 1, 1325282384, 110.0
- orderItems:
OrderItem: 1, 1, 1, 30.0
OrderItem: 1, 2, 2, 40.0
- itemsInOrder:
Item 1: 'Agile Web Application Development with Yii1.1 and PHP5', 1
Item 2: 'Yii 1.1 Application Development Cookbook', 1
Order 2: 2, 1325334482, 33.0
- orderItems:
OrderItem: 2, 3, 1, 8.0
OrderItem: 2, 4, 1, 10.0
OrderItem: 2, 5, 1, 15.0
- itemsInOrder:
Item 5: 'Cars', 2
Item 3: 'Ice Age', 2
Item 4: 'Toy Story', 2
Order 3: 2, 1325502201, 40.0
- orderItems:
OrderItem: 3, 2, 1, 40.0
- itemsInOrder:
Item 3: 'Ice Age', 2
*/
$orders
=
$this
->
callOrderFind
()
->
with
(
'itemsInOrder1'
)
->
orderBy
(
'create_time'
)
->
all
();
$this
->
assertEquals
(
3
,
count
(
$orders
));
...
...
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