/** * Tests cloning documents. */ public function testCloningDocuments() { $manager = $this->getManager(); $document = new Product(); $document->setId('tuna_id'); $document->title = 'tuna'; $manager->persist($document); $manager->commit(); $repository = $manager->getRepository('AcmeTestBundle:Product'); $document = $repository->find('tuna_id'); $clone = clone $document; $this->assertNull($clone->getId(), 'Id should be null\'ed.'); $manager->persist($clone); $manager->commit(); $search = $repository->createSearch()->addQuery(new TermQuery('title', 'tuna')); $this->assertCount(2, $repository->execute($search), '2 Results should be found.'); }
/** * Test repository find method with array result type. */ public function testFind() { $manager = $this->getManager(); $product = new Product(); $product->setId('123'); $product->title = 'foo'; $manager->persist($product); $manager->commit(); $repo = $manager->getRepository('AcmeTestBundle:Product'); $result = $repo->find(123); $this->assertEquals(get_object_vars($product), get_object_vars($result)); }