/** * @test */ public function magicCallMethodReturnsNullInFindOneBySomethingIfQueryReturnsEmptyRawResult() { $queryResultArray = array(); $this->mockQuery->expects($this->once())->method('equals')->with('foo', 'bar')->will($this->returnValue('matchCriteria')); $this->mockQuery->expects($this->once())->method('matching')->with('matchCriteria')->will($this->returnValue($this->mockQuery)); $this->mockQuery->expects($this->once())->method('setLimit')->with(1)->will($this->returnValue($this->mockQuery)); $this->mockQuery->expects($this->once())->method('execute')->will($this->returnValue($queryResultArray)); $this->assertNull($this->repository->findOneByFoo('bar')); }