public function testFetchListResult() { $data = array(array('id' => 42, 'firstname' => 'Manfred', 'lastname' => 'Mustermann', 'street' => 'Am Testen 123', 'postcode' => '54321', 'city' => 'Musterhausen', 'country' => 'de'), array('id' => 43, 'firstname' => 'Manuela', 'lastname' => 'Musterfrau', 'street' => 'Am Mustern 987', 'postcode' => '98765', 'city' => 'Testhausen', 'country' => 'de')); $mockDbStatement = $this->getMock('Zend\\Db\\Adapter\\Driver\\StatementInterface'); $mockDbStatement->expects($this->any())->method('execute')->will($this->returnValue($data)); $mockDbDriver = $this->getMock('Zend\\Db\\Adapter\\Driver\\DriverInterface'); $mockDbDriver->expects($this->any())->method('createStatement')->will($this->returnValue($mockDbStatement)); $mockDbAdapter = $this->getMock('Zend\\Db\\Adapter\\Adapter', null, array($mockDbDriver)); $customerTable = new CustomerTable($mockDbAdapter); $customerList = $customerTable->fetchList(); $this->assertEquals($data, $customerList->toArray()); }
public function testFetchListByCountryOrderedByCountry() { $customerTable = new CustomerTable($this->adapter); $customerList = $customerTable->fetchList('de'); $queryTable = $this->getConnection()->createQueryTable('loadCustomersOrderedByLastname', 'SELECT * FROM customers WHERE country = "de" ORDER BY lastname;'); $this->assertEquals($queryTable->getRowCount(), $customerList->count()); $hydrator = new CustomerHydrator(); foreach ($customerList as $key => $customerEntity) { $expectedRow = $queryTable->getRow($key); $customerRow = $hydrator->extract($customerEntity); $this->assertEquals($expectedRow, $customerRow); } }