/** * * @param arra $eventListenerArray * @return array */ public function &setUpMockedMapper($eventListenerArray, array $mapperMethods = array()) { $returnMockedParams = array(); $mapperMethods = count($mapperMethods) ? array_merge($mapperMethods, array('getSelect', 'select')) : array('getSelect', 'select'); $this->setUpMockMapperInsert($mapperMethods); $this->mapper->expects($this->once())->method('select')->will($this->returnValue($this->mockedResultSet)); $mockedSelect = $this->mockedSelect; $this->mockedSelect->expects($this->once())->method('where')->will($this->returnCallback(function () use(&$returnMockedParams, $mockedSelect) { $returnMockedParams['whereArgs'] = func_get_args(); return $mockedSelect; })); foreach ($eventListenerArray as $eventKey => $eventListener) { $this->mapper->getEventManager()->attach($eventKey, $eventListener); } $this->mapper->setDbAdapter($this->mockedDbAdapter); $this->mapper->setEntityPrototype(new Entity()); return $returnMockedParams; }
public function testFetchColWithEmptyTable() { $this->_select->expects($this->once())->method('columns')->with(array('col'), false); $this->_table->method('selectWith')->with($this->_select)->willReturn(array()); $this->assertSame(array(), $this->_table->fetchCol('col')); }