Sokil\Mongo\DocumentRelationTest::testRemoveRelation_Belongs PHP Method

testRemoveRelation_Belongs() public method

    public function testRemoveRelation_Belongs()
    {
        // collections
        $carsCollection = $this->database->getCollection('cars');
        $wheelsCollection = $this->database->getCollection('wheels');
        // add documents
        $carDocument = $carsCollection->createDocument(array('brand' => 'Nissan'))->save();
        // add target documents
        $wheelDocument = $wheelsCollection->createDocument(array('diameter' => 30, 'car_id' => $carDocument->getId()))->save();
        // remove relation
        $wheelDocument->removeRelation('car');
        // check
        $this->assertEmpty($wheelDocument->car_id);
    }