Sokil\Mongo\DocumentRelationTest::testGetRelated_ManyMany_RequestFromCollectionWithoutLocalyStoredRelationData PHP Метод

testGetRelated_ManyMany_RequestFromCollectionWithoutLocalyStoredRelationData() публичный Метод

    public function testGetRelated_ManyMany_RequestFromCollectionWithoutLocalyStoredRelationData()
    {
        $carsCollection = $this->database->getCollection('cars');
        $driversCollection = $this->database->getCollection('drivers');
        $driver1 = $driversCollection->createDocument(array('name' => 'Dmytro'))->save();
        $driver2 = $driversCollection->createDocument(array('name' => 'Natalia'))->save();
        $car1 = $carsCollection->createDocument(array('number' => 'AA0123AK', 'driver_id' => array($driver1->getId(), $driver2->getId())))->save();
        $car2 = $carsCollection->createDocument(array('number' => 'AA4567AK', 'driver_id' => array($driver1->getId(), $driver2->getId())))->save();
        $this->assertEquals(array($car1->getId(), $car2->getId()), array_keys($driver1->getRelated('cars')));
        $this->assertEquals(array($car1->getId(), $car2->getId()), array_keys($driver2->getRelated('cars')));
    }