public function testCondition() { $objectToInsert = new \test\data\Customer(); $id1 = (int) \Faker\Provider\Base::randomNumber(5); $faker = \Faker\Factory::create(); $objectToInsert->id = $id1; $objectToInsert->name = $faker->name; $objectToInsert->contacts = ['telephone1' => 123456, 'telephone2' => 345678, 'telephone3' => 345678]; $objectToInsert->prices = [1000000, 1000000, 1000000, 1000000]; $objectToInsert->kids = ['Alice', 'Billy', 'Charlie']; $this->assertTrue($objectToInsert->save(false)); $objectToInsert2 = new \test\data\Customer(); $id2 = $id1 + 1; $faker = \Faker\Factory::create(); $objectToInsert2->id = $id2; $objectToInsert2->name = $faker->name; $objectToInsert2->contacts = ['telephone1' => 123456, 'telephone2' => 345678, 'telephone3' => 345678]; $objectToInsert2->prices = [1000000, 1000000, 1000000, 1000000]; $objectToInsert2->kids = ['Alice', 'Ari', 'Charlie']; $this->assertTrue($objectToInsert2->save(false)); $objectToInsert3 = new \test\data\Customer(); $id3 = $id2 + 1; $faker = \Faker\Factory::create(); $objectToInsert3->id = $id3; $objectToInsert3->name = $faker->name; $objectToInsert3->contacts = ['telephone1' => 123456, 'telephone2' => 345678, 'telephone3' => 345678]; $objectToInsert3->prices = [1000000, 1000000, 1000000, 1000000]; $objectToInsert3->kids = ['Alice', 'Ari', 'Angle']; $this->assertTrue($objectToInsert3->save(false)); $objectsFromFind = \test\data\Customer::find()->where(['id' => [$id1]])->all(); $this->assertEquals(1, count($objectsFromFind)); $objectsFromFind = \test\data\Customer::find()->where(['id' => $id1])->orWhere(['id' => $id2])->all(); $this->assertEquals(2, count($objectsFromFind)); $objectsFromFind = \test\data\Customer::find()->where(['>=', 'id', $id1])->all(); $this->assertEquals(3, count($objectsFromFind)); $objectsFromFind = \test\data\Customer::find()->where(['IN', 'id', [$id1, $id2]])->all(); $this->assertEquals(2, count($objectsFromFind)); $objectsFromFind = \test\data\Customer::find()->limit(2)->all(); $this->assertEquals(2, count($objectsFromFind)); $objectsFromFind = \test\data\Customer::find()->where(['>', 'id', $id1])->all(); $objectsFromFind = \test\data\Customer::find()->where(['CONTAINS', 'kids', 'Angle'])->all(); $this->assertEquals(1, count($objectsFromFind)); }