public function testSeekableInterface() { $this->assertSame(-1, $this->_model->key()); $this->_model->seek(-1); $this->assertSame(-1, $this->_model->key()); $this->_model->expects($this->any())->method('_getNextRow')->will($this->onConsecutiveCalls([1, 2, 3], [4, 5, 5], [6, 7, 8], [1, 2, 3], [4, 5, 5])); $this->_model->seek(2); $this->assertSame(['key1' => 6, 'key2' => 7, 'key3' => 8], $this->_model->current()); $this->_model->seek(1); $this->assertSame(['key1' => 4, 'key2' => 5, 'key3' => 5], $this->_model->current()); }
public function testSeekableInterface() { $this->assertSame(-1, $this->_model->key()); $this->_model->seek(-1); $this->assertSame(-1, $this->_model->key()); $this->_model->expects($this->any())->method('_getNextRow')->will($this->onConsecutiveCalls(array(1, 2, 3), array(4, 5), array(6, 7, 8), array(1, 2, 3), array(4, 5))); $this->_model->seek(2); $this->assertSame(array('key1' => 6, 'key2' => 7, 'key3' => 8), $this->_model->current()); $this->_model->seek(1); $this->assertSame(array('key1' => 4, 'key2' => 5, 'key3' => ''), $this->_model->current()); }
/** * @covers Zend\Db\ResultSet\AbstractResultSet::current */ public function testCurrentCallsDataSourceCurrentOnceWithBuffer() { $result = $this->getMock('Zend\\Db\\Adapter\\Driver\\ResultInterface'); $this->resultSet->buffer(); $this->resultSet->initialize($result); $result->expects($this->once())->method('current')->will($this->returnValue(array('foo' => 'bar'))); $value1 = $this->resultSet->current(); $value2 = $this->resultSet->current(); $this->resultSet->current(); $this->assertEquals($value1, $value2); }
/** * Asserts a certain item at a certain index of the typed list. * * @param int $index The index of the expected item. * @param Item $item The item expected at index. */ private function assertIndexValidAndHoldsExpectedItem($index, Item $item) { $this->assertAttributeSame($index, 'position', $this->typedList); $this->assertSame($index, $this->typedList->key()); $this->assertTrue($this->typedList->valid()); $this->assertSame($item, $this->typedList->current()); }
/** * @dataProvider iteratorDataProvider */ public function testIterateTwice(array $expectations, array $expectedItems) { $this->expectIteratorCalls($expectations); $actualItems = array(); $this->iterator->rewind(); while ($this->iterator->valid()) { $actualItems[$this->iterator->key()] = $this->iterator->current(); $this->iterator->next(); } $this->assertEquals($expectedItems, $actualItems); $this->expectIteratorCalls($expectations); $actualItems = array(); $this->iterator->rewind(); while ($this->iterator->valid()) { $actualItems[$this->iterator->key()] = $this->iterator->current(); $this->iterator->next(); } $this->assertEquals($expectedItems, $actualItems); }