コード例 #1
0
 public function testGetEntityManagers()
 {
     $defaultEm = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $anotherEm = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $this->doctrine->expects($this->at(0))->method('getManager')->with(null)->willReturn($defaultEm);
     $this->doctrine->expects($this->at(1))->method('getManager')->with('another')->willReturn($anotherEm);
     $this->entityManagerBag->addEntityManager('another');
     $result = $this->entityManagerBag->getEntityManagers();
     $this->assertCount(2, $result);
     $this->assertSame($defaultEm, $result[0]);
     $this->assertSame($anotherEm, $result[1]);
 }