public function testDelete() { $query = $this->getMock('Doctrine\\ORM\\AbstractQuery', array('getSQL', 'setMaxResults', 'getOneOrNullResult', 'setParameter', '_doExecute'), array(), '', false); $searchRepo = $this->getMockBuilder('Oro\\Bundle\\SearchBundle\\Entity\\Repository\\SearchIndexRepository')->disableOriginalConstructor()->getMock(); $this->om->expects($this->any())->method('getRepository')->with($this->equalTo('OroSearchBundle:Item'))->will($this->returnValue($searchRepo)); $this->container->expects($this->any())->method('getParameter')->with($this->equalTo('oro_search.engine_orm'))->will($this->returnValue('test_orm')); $searchRepo->expects($this->any())->method('setDriversClasses'); $item = new Item(); $searchRepo->expects($this->any())->method('findOneBy')->will($this->returnValue($item)); $this->om->expects($this->any())->method('remove')->with($this->equalTo($item)); $this->om->expects($this->any())->method('flush'); $this->om->expects($this->once())->method('createQuery')->will($this->returnValue($query)); $query->expects($this->any())->method('setParameter')->will($this->returnValue($query)); $query->expects($this->once())->method('setMaxResults')->will($this->returnValue($query)); $query->expects($this->once())->method('getOneOrNullResult')->will($this->returnValue(0)); $this->orm->delete($this->product, true); $this->orm->delete($this->product, false); }