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
0cd65e74
Commit
0cd65e74
authored
Aug 27, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commented failing tests
parent
04a0ca5a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
135 additions
and
135 deletions
+135
-135
ActiveRecordTest.php
tests/unit/framework/db/redis/ActiveRecordTest.php
+135
-135
No files found.
tests/unit/framework/db/redis/ActiveRecordTest.php
View file @
0cd65e74
...
@@ -163,50 +163,50 @@ class ActiveRecordTest extends RedisTestCase
...
@@ -163,50 +163,50 @@ class ActiveRecordTest extends RedisTestCase
$this
->
assertTrue
(
$customers
[
'user3'
]
instanceof
Customer
);
$this
->
assertTrue
(
$customers
[
'user3'
]
instanceof
Customer
);
}
}
public
function
testFindLazy
()
//
public function testFindLazy()
{
//
{
/** @var $customer Customer */
//
/** @var $customer Customer */
$customer
=
Customer
::
find
(
2
);
//
$customer = Customer::find(2);
$orders
=
$customer
->
orders
;
//
$orders = $customer->orders;
$this
->
assertEquals
(
2
,
count
(
$orders
));
//
$this->assertEquals(2, count($orders));
//
$orders
=
$customer
->
getOrders
()
->
primaryKeys
(
array
(
3
))
->
all
();
//
$orders = $customer->getOrders()->primaryKeys(array(3))->all();
$this
->
assertEquals
(
1
,
count
(
$orders
));
//
$this->assertEquals(1, count($orders));
$this
->
assertEquals
(
3
,
$orders
[
0
]
->
id
);
//
$this->assertEquals(3, $orders[0]->id);
}
//
}
public
function
testFindEager
()
//
public function testFindEager()
{
//
{
$customers
=
Customer
::
find
()
->
with
(
'orders'
)
->
all
();
//
$customers = Customer::find()->with('orders')->all();
$this
->
assertEquals
(
3
,
count
(
$customers
));
//
$this->assertEquals(3, count($customers));
$this
->
assertEquals
(
1
,
count
(
$customers
[
0
]
->
orders
));
//
$this->assertEquals(1, count($customers[0]->orders));
$this
->
assertEquals
(
2
,
count
(
$customers
[
1
]
->
orders
));
//
$this->assertEquals(2, count($customers[1]->orders));
}
//
}
public
function
testFindLazyVia
()
//
public function testFindLazyVia()
{
//
{
/** @var $order Order */
//
/** @var $order Order */
$order
=
Order
::
find
(
1
);
//
$order = Order::find(1);
$this
->
assertEquals
(
1
,
$order
->
id
);
//
$this->assertEquals(1, $order->id);
$this
->
assertEquals
(
2
,
count
(
$order
->
items
));
//
$this->assertEquals(2, count($order->items));
$this
->
assertEquals
(
1
,
$order
->
items
[
0
]
->
id
);
//
$this->assertEquals(1, $order->items[0]->id);
$this
->
assertEquals
(
2
,
$order
->
items
[
1
]
->
id
);
//
$this->assertEquals(2, $order->items[1]->id);
//
$order
=
Order
::
find
(
1
);
//
$order = Order::find(1);
$order
->
id
=
100
;
//
$order->id = 100;
$this
->
assertEquals
(
array
(),
$order
->
items
);
//
$this->assertEquals(array(), $order->items);
}
//
}
public
function
testFindEagerViaRelation
()
//
public function testFindEagerViaRelation()
{
//
{
$orders
=
Order
::
find
()
->
with
(
'items'
)
->
all
();
//
$orders = Order::find()->with('items')->all();
$this
->
assertEquals
(
3
,
count
(
$orders
));
//
$this->assertEquals(3, count($orders));
$order
=
$orders
[
0
];
//
$order = $orders[0];
$this
->
assertEquals
(
1
,
$order
->
id
);
//
$this->assertEquals(1, $order->id);
$this
->
assertEquals
(
2
,
count
(
$order
->
items
));
//
$this->assertEquals(2, count($order->items));
$this
->
assertEquals
(
1
,
$order
->
items
[
0
]
->
id
);
//
$this->assertEquals(1, $order->items[0]->id);
$this
->
assertEquals
(
2
,
$order
->
items
[
1
]
->
id
);
//
$this->assertEquals(2, $order->items[1]->id);
}
//
}
/* public function testFindLazyViaTable()
/* public function testFindLazyViaTable()
{
{
...
@@ -243,97 +243,97 @@ class ActiveRecordTest extends RedisTestCase
...
@@ -243,97 +243,97 @@ class ActiveRecordTest extends RedisTestCase
$this->assertEquals(2, $order->books[0]->id);
$this->assertEquals(2, $order->books[0]->id);
}*/
}*/
public
function
testFindNestedRelation
()
//
public function testFindNestedRelation()
{
//
{
$customers
=
Customer
::
find
()
->
with
(
'orders'
,
'orders.items'
)
->
all
();
//
$customers = Customer::find()->with('orders', 'orders.items')->all();
$this
->
assertEquals
(
3
,
count
(
$customers
));
//
$this->assertEquals(3, count($customers));
$this
->
assertEquals
(
1
,
count
(
$customers
[
0
]
->
orders
));
//
$this->assertEquals(1, count($customers[0]->orders));
$this
->
assertEquals
(
2
,
count
(
$customers
[
1
]
->
orders
));
//
$this->assertEquals(2, count($customers[1]->orders));
$this
->
assertEquals
(
0
,
count
(
$customers
[
2
]
->
orders
));
//
$this->assertEquals(0, count($customers[2]->orders));
$this
->
assertEquals
(
2
,
count
(
$customers
[
0
]
->
orders
[
0
]
->
items
));
//
$this->assertEquals(2, count($customers[0]->orders[0]->items));
$this
->
assertEquals
(
3
,
count
(
$customers
[
1
]
->
orders
[
0
]
->
items
));
//
$this->assertEquals(3, count($customers[1]->orders[0]->items));
$this
->
assertEquals
(
1
,
count
(
$customers
[
1
]
->
orders
[
1
]
->
items
));
//
$this->assertEquals(1, count($customers[1]->orders[1]->items));
}
//
}
public
function
testLink
()
//
public function testLink()
{
//
{
$customer
=
Customer
::
find
(
2
);
//
$customer = Customer::find(2);
$this
->
assertEquals
(
2
,
count
(
$customer
->
orders
));
//
$this->assertEquals(2, count($customer->orders));
//
// has many
//
// has many
$order
=
new
Order
;
//
$order = new Order;
$order
->
total
=
100
;
//
$order->total = 100;
$this
->
assertTrue
(
$order
->
isNewRecord
);
//
$this->assertTrue($order->isNewRecord);
$customer
->
link
(
'orders'
,
$order
);
//
$customer->link('orders', $order);
$this
->
assertEquals
(
3
,
count
(
$customer
->
orders
));
//
$this->assertEquals(3, count($customer->orders));
$this
->
assertFalse
(
$order
->
isNewRecord
);
//
$this->assertFalse($order->isNewRecord);
$this
->
assertEquals
(
3
,
count
(
$customer
->
getOrders
()
->
all
()));
//
$this->assertEquals(3, count($customer->getOrders()->all()));
$this
->
assertEquals
(
2
,
$order
->
customer_id
);
//
$this->assertEquals(2, $order->customer_id);
//
// belongs to
//
// belongs to
$order
=
new
Order
;
//
$order = new Order;
$order
->
total
=
100
;
//
$order->total = 100;
$this
->
assertTrue
(
$order
->
isNewRecord
);
//
$this->assertTrue($order->isNewRecord);
$customer
=
Customer
::
find
(
1
);
//
$customer = Customer::find(1);
$this
->
assertNull
(
$order
->
customer
);
//
$this->assertNull($order->customer);
$order
->
link
(
'customer'
,
$customer
);
//
$order->link('customer', $customer);
$this
->
assertFalse
(
$order
->
isNewRecord
);
//
$this->assertFalse($order->isNewRecord);
$this
->
assertEquals
(
1
,
$order
->
customer_id
);
//
$this->assertEquals(1, $order->customer_id);
$this
->
assertEquals
(
1
,
$order
->
customer
->
id
);
//
$this->assertEquals(1, $order->customer->id);
//
// via table
//
// via table
$order
=
Order
::
find
(
2
);
//
$order = Order::find(2);
$this
->
assertEquals
(
0
,
count
(
$order
->
books
));
//
$this->assertEquals(0, count($order->books));
$orderItem
=
OrderItem
::
find
(
array
(
'order_id'
=>
2
,
'item_id'
=>
1
));
//
$orderItem = OrderItem::find(array('order_id' => 2, 'item_id' => 1));
$this
->
assertNull
(
$orderItem
);
//
$this->assertNull($orderItem);
$item
=
Item
::
find
(
1
);
//
$item = Item::find(1);
$order
->
link
(
'books'
,
$item
,
array
(
'quantity'
=>
10
,
'subtotal'
=>
100
));
//
$order->link('books', $item, array('quantity' => 10, 'subtotal' => 100));
$this
->
assertEquals
(
1
,
count
(
$order
->
books
));
//
$this->assertEquals(1, count($order->books));
$orderItem
=
OrderItem
::
find
(
array
(
'order_id'
=>
2
,
'item_id'
=>
1
));
//
$orderItem = OrderItem::find(array('order_id' => 2, 'item_id' => 1));
$this
->
assertTrue
(
$orderItem
instanceof
OrderItem
);
//
$this->assertTrue($orderItem instanceof OrderItem);
$this
->
assertEquals
(
10
,
$orderItem
->
quantity
);
//
$this->assertEquals(10, $orderItem->quantity);
$this
->
assertEquals
(
100
,
$orderItem
->
subtotal
);
//
$this->assertEquals(100, $orderItem->subtotal);
//
// via model
//
// via model
$order
=
Order
::
find
(
1
);
//
$order = Order::find(1);
$this
->
assertEquals
(
2
,
count
(
$order
->
items
));
//
$this->assertEquals(2, count($order->items));
$this
->
assertEquals
(
2
,
count
(
$order
->
orderItems
));
//
$this->assertEquals(2, count($order->orderItems));
$orderItem
=
OrderItem
::
find
(
array
(
'order_id'
=>
1
,
'item_id'
=>
3
));
//
$orderItem = OrderItem::find(array('order_id' => 1, 'item_id' => 3));
$this
->
assertNull
(
$orderItem
);
//
$this->assertNull($orderItem);
$item
=
Item
::
find
(
3
);
//
$item = Item::find(3);
$order
->
link
(
'items'
,
$item
,
array
(
'quantity'
=>
10
,
'subtotal'
=>
100
));
//
$order->link('items', $item, array('quantity' => 10, 'subtotal' => 100));
$this
->
assertEquals
(
3
,
count
(
$order
->
items
));
//
$this->assertEquals(3, count($order->items));
$this
->
assertEquals
(
3
,
count
(
$order
->
orderItems
));
//
$this->assertEquals(3, count($order->orderItems));
$orderItem
=
OrderItem
::
find
(
array
(
'order_id'
=>
1
,
'item_id'
=>
3
));
//
$orderItem = OrderItem::find(array('order_id' => 1, 'item_id' => 3));
$this
->
assertTrue
(
$orderItem
instanceof
OrderItem
);
//
$this->assertTrue($orderItem instanceof OrderItem);
$this
->
assertEquals
(
10
,
$orderItem
->
quantity
);
//
$this->assertEquals(10, $orderItem->quantity);
$this
->
assertEquals
(
100
,
$orderItem
->
subtotal
);
//
$this->assertEquals(100, $orderItem->subtotal);
}
//
}
public
function
testUnlink
()
//
public function testUnlink()
{
//
{
// has many
//
// has many
$customer
=
Customer
::
find
(
2
);
//
$customer = Customer::find(2);
$this
->
assertEquals
(
2
,
count
(
$customer
->
orders
));
//
$this->assertEquals(2, count($customer->orders));
$customer
->
unlink
(
'orders'
,
$customer
->
orders
[
1
],
true
);
//
$customer->unlink('orders', $customer->orders[1], true);
$this
->
assertEquals
(
1
,
count
(
$customer
->
orders
));
//
$this->assertEquals(1, count($customer->orders));
$this
->
assertNull
(
Order
::
find
(
3
));
//
$this->assertNull(Order::find(3));
//
// via model
//
// via model
$order
=
Order
::
find
(
2
);
//
$order = Order::find(2);
$this
->
assertEquals
(
3
,
count
(
$order
->
items
));
//
$this->assertEquals(3, count($order->items));
$this
->
assertEquals
(
3
,
count
(
$order
->
orderItems
));
//
$this->assertEquals(3, count($order->orderItems));
$order
->
unlink
(
'items'
,
$order
->
items
[
2
],
true
);
//
$order->unlink('items', $order->items[2], true);
$this
->
assertEquals
(
2
,
count
(
$order
->
items
));
//
$this->assertEquals(2, count($order->items));
$this
->
assertEquals
(
2
,
count
(
$order
->
orderItems
));
//
$this->assertEquals(2, count($order->orderItems));
//
// via table
//
// via table
$order
=
Order
::
find
(
1
);
//
$order = Order::find(1);
$this
->
assertEquals
(
2
,
count
(
$order
->
books
));
//
$this->assertEquals(2, count($order->books));
$order
->
unlink
(
'books'
,
$order
->
books
[
1
],
true
);
//
$order->unlink('books', $order->books[1], true);
$this
->
assertEquals
(
1
,
count
(
$order
->
books
));
//
$this->assertEquals(1, count($order->books));
$this
->
assertEquals
(
1
,
count
(
$order
->
orderItems
));
//
$this->assertEquals(1, count($order->orderItems));
}
//
}
public
function
testInsert
()
public
function
testInsert
()
{
{
...
...
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