public function testFetchAll() { $expected = ['all' => 10, 'catalog' => 100]; $selectMock = $this->getMock('Zend_Db_Select', [], [], '', false); $this->_adapterMock->expects($this->once())->method('select')->will($this->returnValue($selectMock)); $selectMock->expects($this->once())->method('from')->will($this->returnSelf()); $selectMock->expects($this->once())->method('columns')->will($this->returnSelf()); $selectMock->expects($this->once())->method('group')->will($this->returnSelf()); $this->_adapterMock->expects($this->once())->method('fetchPairs')->will($this->returnValue($expected)); $actual = $this->_model->fetchAll(); $this->assertEquals($expected, $actual); }
/** * Migrate old keys to new * * @param array $map * @return void */ public function migrate($map) { foreach ($this->_reader->fetchAll() as $oldKey => $count) { $newKey = isset($map[$oldKey]) ? $map[$oldKey] : null; if (in_array($oldKey, $map)) { $newKey = $oldKey; $oldKey = null; } if ($newKey && $oldKey && $this->_mode == self::WRITE_MODE) { $this->_writer->update($oldKey, $newKey); } $this->_logger->add($oldKey, $newKey, $count); } }