Commit d56e0201 by Carsten Brandt

more random test fixes

parent c1febb74
......@@ -33,7 +33,7 @@ class ActiveRecordTest extends ElasticSearchTestCase
*/
public function afterSave()
{
$this->getConnection()->createCommand()->flushIndex();
$this->getConnection()->createCommand()->flushIndex('yiitest');
}
public function setUp()
......@@ -129,7 +129,7 @@ class ActiveRecordTest extends ElasticSearchTestCase
$orderItem->setAttributes(['order_id' => 3, 'item_id' => 2, 'quantity' => 1, 'subtotal' => 40.0], false);
$orderItem->save(false);
Customer::getDb()->createCommand()->flushIndex();
$db->createCommand()->flushIndex('yiitest');
}
public function testGetDb()
......
......@@ -352,14 +352,17 @@ trait ActiveRecordTestTrait
public function testFindEager()
{
/** @var TestCase|ActiveRecordTestTrait $this */
$customers = $this->callCustomerFind()->with('orders')->all();
$customers = $this->callCustomerFind()->with('orders')->indexBy('id')->all();
ksort($customers);
$this->assertEquals(3, count($customers));
$this->assertTrue($customers[0]->isRelationPopulated('orders'));
$this->assertTrue($customers[1]->isRelationPopulated('orders'));
$this->assertEquals(1, count($customers[0]->orders));
$this->assertEquals(2, count($customers[1]->orders));
$this->assertTrue($customers[2]->isRelationPopulated('orders'));
$this->assertTrue($customers[3]->isRelationPopulated('orders'));
$this->assertEquals(1, count($customers[1]->orders));
$this->assertEquals(2, count($customers[2]->orders));
$this->assertEquals(0, count($customers[3]->orders));
$customer = $this->callCustomerFind()->with('orders')->one();
$customer = $this->callCustomerFind()->where(['id' => 1])->with('orders')->one();
$this->assertTrue($customer->isRelationPopulated('orders'));
$this->assertEquals(1, count($customer->orders));
$this->assertEquals(1, count($customer->populatedRelations));
......
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