public function testDuplicateSplObjectHash() { $group = new EmbeddedGroup('Model\\Comment'); $comment = $this->mongator->create('Model\\Comment'); $this->assertEquals(0, count($group->getAdd())); $group->add($comment); $this->assertEquals(1, count($group->getAdd())); unset($group); $group = new EmbeddedGroup('Model\\Comment'); $this->assertEquals(0, count($group->getAdd())); }
public function testSetDocumentDataEmbeddedsMany() { $this->markTestIncomplete('This test has not been implemented yet.'); $infosData = array(array('name' => 'foo', 'text' => 'foobar'), array('name' => 'bar', 'text' => 'barfoo')); $commentsData = array(array('name' => 'ups', 'text' => 'upsfoo'), array('text' => 'mon', 'line' => 'monfoo', 'infos' => $infosData)); $article = $this->mongator->create('Model\\Article')->setDocumentData(array('_query_hash' => $queryHash = md5('mongodb'), 'comments' => $commentsData)); $comments = $article->getComments(); $expected = new EmbeddedGroup('Model\\Comment', $commentsData); $expected->setRootAndPath($article, 'comments'); $savedComments = $comments->getSaved(); $this->assertSame(2, count($savedComments)); $this->assertSameGroups($this->mongator->create('Model\\Comment')->setDocumentData($commentsData[0])->getName(), $savedComments[0]->getName()); $this->assertSameGroups($this->mongator->create('Model\\Comment')->setDocumentData($commentsData[1])->getName(), $savedComments[1]->getName()); $this->assertSameGroups($expected, $comments); $this->assertSame(array('root' => $article, 'path' => 'comments'), $comments->getRootAndPath()); $this->assertSame(0, $savedComments[0]->getInfos()->count()); $infos = $savedComments[1]->getInfos(); $this->assertEquals(new EmbeddedGroup('Model\\Info', $infosData), $infos); $this->assertSame(array('root' => $article, 'path' => 'comments.1.infos'), $infos->getRootAndPath()); $savedInfos = $infos->getSaved(); $this->assertSame(2, count($savedComments)); $this->assertEquals($this->mongator->create('Model\\Info')->setDocumentData($infosData[0]), $savedInfos[0]); $this->assertEquals($this->mongator->create('Model\\Info')->setDocumentData($infosData[1]), $savedInfos[1]); }