/** * @test */ public function anObjectWithRelationsCanBeRetrieved() { $article = new Article(); $article->setTitle('Who is John Galt?'); $article->setBody('Find out!'); $article->addTag('Philosophy'); $this->documentManager->persist($article); $this->documentManager->flush(); $articles = $this->documentManager->getRepository('\\Radmiraal\\CouchDB\\Tests\\Functional\\Fixtures\\Domain\\Model\\Article')->findAll(); $this->assertEquals(1, count($articles)); $this->assertInstanceOf('DateTime', $articles[0]->getCreated()); $this->assertNotNull($articles[0]->getId()); $this->assertEquals('Who is John Galt?', $articles[0]->getTitle()); $this->assertEquals('Find out!', $articles[0]->getBody()); $this->assertEquals(1, $articles[0]->getTags()->count()); $this->assertEquals('Philosophy', $articles[0]->getTags()->first()->getName()); }
/** * @test */ public function findOneByPropertyReturnsTheDocument() { $model = new Article(); $model->setTitle('foo'); $this->articleRepository->add($model); $this->documentManager->flush(); $result = $this->articleRepository->findOneByTitle('foo'); $this->assertNotNull($result->getId()); }