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

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

B -> BELONGS -> A
    public function testGetRelated_Belongs()
    {
        // collections
        $carsCollection = $this->database->getCollection('cars');
        $enginesCollection = $this->database->getCollection('engines');
        // add documents
        $carDocument = $carsCollection->createDocument(array('param' => 'value'))->save();
        // add target document
        $engineDocument = $enginesCollection->createDocument(array('car_id' => $carDocument->getId()))->save();
        // test
        $this->assertInstanceOf('\\Sokil\\Mongo\\DocumentRelationTest\\CarDocument', $engineDocument->car);
        $this->assertEquals($carDocument->getId(), $engineDocument->car->getId());
    }