Sokil\Mongo\DocumentRelationTest::testGetRelated_Belongs_Cache PHP Method

testGetRelated_Belongs_Cache() public method

    public function testGetRelated_Belongs_Cache()
    {
        // collections
        $carsCollection = $this->database->getCollection('cars');
        $wheelsCollection = $this->database->getCollection('wheels');
        // add documents
        $carDocument = $carsCollection->createDocument(array('param' => 'value'))->save();
        // add target documents
        $wheelDocument1 = $wheelsCollection->createDocument(array('car_id' => $carDocument->getId()))->save();
        // add target document
        $wheelDocument2 = $wheelsCollection->createDocument(array('car_id' => $carDocument->getId()))->save();
        // modify property on car, linked to wheel1
        $wheelDocument1->car->color = 'red';
        // test if same object
        $this->assertEquals('red', $wheelDocument2->car->color);
    }