Doctrine\Tests\ODM\PHPCR\Functional\ReferenceTest::testUpdateOneInMany PHP Метод

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

public testUpdateOneInMany ( )
    public function testUpdateOneInMany()
    {
        $refManyTestObj = new RefManyTestObj();
        $refManyTestObj->id = "/functional/refManyTestObj";
        $max = 5;
        for ($i = 0; $i < $max; $i++) {
            $newRefRefTestObj = new RefRefTestObj();
            $newRefRefTestObj->id = "/functional/refRefTestObj{$i}";
            $newRefRefTestObj->name = "refRefTestObj{$i}";
            $refManyTestObj->references[] = $newRefRefTestObj;
        }
        $this->dm->persist($refManyTestObj);
        $this->dm->flush();
        $this->dm->clear();
        $referrer = $this->dm->find($this->referrerManyType, '/functional/refManyTestObj');
        $pos = 2;
        $referrer->references[$pos]->name = "new name";
        $this->dm->persist($referrer);
        $this->dm->flush();
        $this->dm->clear();
        $referrer = $this->dm->find($this->referrerManyType, '/functional/refManyTestObj');
        $i = 0;
        foreach ($this->session->getNode('/functional/refManyTestObj')->getProperty('myReferences')->getNode() as $node) {
            if ($i != $pos) {
                $this->assertEquals("refRefTestObj{$i}", $node->getProperty('name')->getValue());
            } else {
                $this->assertEquals("new name", $referrer->references[$pos]->name);
            }
            $i++;
        }
        $this->assertEquals($max, $i);
    }