Commit 0208f289 by Carsten Brandt

fixed test breaks

parent 59b9065c
...@@ -773,23 +773,23 @@ trait ActiveRecordTestTrait ...@@ -773,23 +773,23 @@ trait ActiveRecordTestTrait
/** @var Order $order */ /** @var Order $order */
$order = $orderClass::findOne(1); $order = $orderClass::findOne(1);
$this->assertEquals(2, count($order->books)); $this->assertEquals(2, count($order->books));
$this->assertEquals(6, $orderItemClass::find()->count()); $orderItemCount = $orderItemClass::find()->count();
$this->assertEquals(5, $itemClass::find()->count()); $this->assertEquals(5, $itemClass::find()->count());
$order->unlinkAll('books', true); $order->unlinkAll('books', true);
$this->afterSave(); $this->afterSave();
$this->assertEquals(5, $itemClass::find()->count()); $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)); $this->assertEquals(0, count($order->books));
// via model without delete // via model without delete
$this->assertEquals(2, count($order->booksWithNullFK)); $this->assertEquals(2, count($order->booksWithNullFK));
$this->assertEquals(6, $orderItemsWithNullFKClass::find()->count()); $orderItemCount = $orderItemsWithNullFKClass::find()->count();
$this->assertEquals(5, $itemClass::find()->count()); $this->assertEquals(5, $itemClass::find()->count());
$order->unlinkAll('booksWithNullFK',false); $order->unlinkAll('booksWithNullFK',false);
$this->afterSave(); $this->afterSave();
$this->assertEquals(0, count($order->booksWithNullFK)); $this->assertEquals(0, count($order->booksWithNullFK));
$this->assertEquals(2,$orderItemsWithNullFKClass::find()->where(['AND', ['item_id' => [1, 2]], ['order_id' => null]])->count()); $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()); $this->assertEquals(5, $itemClass::find()->count());
// via table is covered in \yiiunit\framework\db\ActiveRecordTest::testUnlinkAllViaTable() // via table is covered in \yiiunit\framework\db\ActiveRecordTest::testUnlinkAllViaTable()
......
...@@ -543,30 +543,30 @@ class ActiveRecordTest extends DatabaseTestCase ...@@ -543,30 +543,30 @@ class ActiveRecordTest extends DatabaseTestCase
/** @var \yii\db\ActiveRecordInterface $orderItemClass */ /** @var \yii\db\ActiveRecordInterface $orderItemClass */
$orderItemClass = $this->getOrderItemClass(); $orderItemClass = $this->getOrderItemClass();
/** @var \yii\db\ActiveRecordInterface $itemClass */ /** @var \yii\db\ActiveRecordInterface $itemClass */
$itemClass = $this->getOrderItemClass(); $itemClass = $this->getItemClass();
/** @var \yii\db\ActiveRecordInterface $orderItemsWithNullFKClass */ /** @var \yii\db\ActiveRecordInterface $orderItemsWithNullFKClass */
$orderItemsWithNullFKClass = $this->getOrderItemWithNullFKmClass(); $orderItemsWithNullFKClass = $this->getOrderItemWithNullFKmClass();
// via table with delete // via table with delete
/** @var Order $order */ /** @var Order $order */
$order = $orderClass::findOne(1); $order = $orderClass::findOne(1);
$this->assertEquals(2, count($order->books)); $this->assertEquals(2, count($order->booksViaTable));
$this->assertEquals(6, $orderItemClass::find()->count()); $orderItemCount = $orderItemClass::find()->count();
$this->assertEquals(5, $itemClass::find()->count()); $this->assertEquals(5, $itemClass::find()->count());
$order->unlinkAll('booksViaTable', true); $order->unlinkAll('booksViaTable', true);
$this->afterSave(); $this->afterSave();
$this->assertEquals(5, $itemClass::find()->count()); $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)); $this->assertEquals(0, count($order->booksViaTable));
// via table without delete // via table without delete
$this->assertEquals(2, count($order->booksWithNullFK)); $this->assertEquals(2, count($order->booksWithNullFKViaTable));
$this->assertEquals(6, $orderItemsWithNullFKClass::find()->count()); $orderItemCount = $orderItemsWithNullFKClass::find()->count();
$this->assertEquals(5, $itemClass::find()->count()); $this->assertEquals(5, $itemClass::find()->count());
$order->unlinkAll('booksWithNullFKViaTable',false); $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(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()); $this->assertEquals(5, $itemClass::find()->count());
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment