Skip to content

Commit

Permalink
fixed test breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
cebe committed Jun 4, 2014
1 parent 59b9065 commit 0208f28
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions tests/unit/framework/ar/ActiveRecordTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -773,23 +773,23 @@ public function testUnlinkAll()
/** @var Order $order */
$order = $orderClass::findOne(1);
$this->assertEquals(2, count($order->books));
$this->assertEquals(6, $orderItemClass::find()->count());
$orderItemCount = $orderItemClass::find()->count();
$this->assertEquals(5, $itemClass::find()->count());
$order->unlinkAll('books', true);
$this->afterSave();
$this->assertEquals(5, $itemClass::find()->count());
$this->assertEquals(4, $orderItemClass::find()->count());
$this->assertEquals($orderItemCount - 2, $orderItemClass::find()->count());
$this->assertEquals(0, count($order->books));

// via model without delete
$this->assertEquals(2, count($order->booksWithNullFK));
$this->assertEquals(6, $orderItemsWithNullFKClass::find()->count());
$orderItemCount = $orderItemsWithNullFKClass::find()->count();
$this->assertEquals(5, $itemClass::find()->count());
$order->unlinkAll('booksWithNullFK',false);
$this->afterSave();
$this->assertEquals(0, count($order->booksWithNullFK));
$this->assertEquals(2,$orderItemsWithNullFKClass::find()->where(['AND', ['item_id' => [1, 2]], ['order_id' => null]])->count());
$this->assertEquals(6, $orderItemsWithNullFKClass::find()->count());
$this->assertEquals(2, $orderItemsWithNullFKClass::find()->where(['AND', ['item_id' => [1, 2]], ['order_id' => null]])->count());
$this->assertEquals($orderItemCount, $orderItemsWithNullFKClass::find()->count());
$this->assertEquals(5, $itemClass::find()->count());

// via table is covered in \yiiunit\framework\db\ActiveRecordTest::testUnlinkAllViaTable()
Expand Down
18 changes: 9 additions & 9 deletions tests/unit/framework/db/ActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,30 +543,30 @@ public function testUnlinkAllViaTable()
/** @var \yii\db\ActiveRecordInterface $orderItemClass */
$orderItemClass = $this->getOrderItemClass();
/** @var \yii\db\ActiveRecordInterface $itemClass */
$itemClass = $this->getOrderItemClass();
$itemClass = $this->getItemClass();
/** @var \yii\db\ActiveRecordInterface $orderItemsWithNullFKClass */
$orderItemsWithNullFKClass = $this->getOrderItemWithNullFKmClass();

// via table with delete
/** @var Order $order */
$order = $orderClass::findOne(1);
$this->assertEquals(2, count($order->books));
$this->assertEquals(6, $orderItemClass::find()->count());
$this->assertEquals(2, count($order->booksViaTable));
$orderItemCount = $orderItemClass::find()->count();
$this->assertEquals(5, $itemClass::find()->count());
$order->unlinkAll('booksViaTable', true);
$this->afterSave();
$this->assertEquals(5, $itemClass::find()->count());
$this->assertEquals(4, $orderItemClass::find()->count());
$this->assertEquals(0, count($order->books));
$this->assertEquals($orderItemCount - 2, $orderItemClass::find()->count());
$this->assertEquals(0, count($order->booksViaTable));

// via table without delete
$this->assertEquals(2, count($order->booksWithNullFK));
$this->assertEquals(6, $orderItemsWithNullFKClass::find()->count());
$this->assertEquals(2, count($order->booksWithNullFKViaTable));
$orderItemCount = $orderItemsWithNullFKClass::find()->count();
$this->assertEquals(5, $itemClass::find()->count());
$order->unlinkAll('booksWithNullFKViaTable',false);
$this->assertEquals(0, count($order->booksWithNullFK));
$this->assertEquals(0, count($order->booksWithNullFKViaTable));
$this->assertEquals(2,$orderItemsWithNullFKClass::find()->where(['AND', ['item_id' => [1, 2]], ['order_id' => null]])->count());
$this->assertEquals(6, $orderItemsWithNullFKClass::find()->count());
$this->assertEquals($orderItemCount, $orderItemsWithNullFKClass::find()->count());
$this->assertEquals(5, $itemClass::find()->count());
}
}

0 comments on commit 0208f28

Please sign in to comment.