/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage ContainerInterface not injected */ public function testMissingContainer() { /** @var OnFlushEventArgs|\PHPUnit_Framework_MockObject_MockObject $args */ $args = $this->getMockBuilder('Doctrine\\ORM\\Event\\OnFlushEventArgs')->disableOriginalConstructor()->getMock(); $em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock(); $uow = $this->getMockBuilder('Doctrine\\ORM\\UnitOfWork')->disableOriginalConstructor()->getMock(); $args->expects($this->once())->method('getEntityManager')->will($this->returnValue($em)); $em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($uow)); $uow->expects($this->once())->method('getScheduledEntityInsertions')->will($this->returnValue([new \stdClass()])); $uow->expects($this->any())->method('getScheduledEntityUpdates')->will($this->returnValue([])); $uow->expects($this->any())->method('getScheduledEntityDeletions')->will($this->returnValue([])); $treeListener = new OwnerTreeListener(); $treeListener->addSupportedClass('stdClass'); $treeListener->onFlush($args); }