current() public method

See also: Iterator::current()
public current ( ) : mixed
return mixed
コード例 #1
0
 /**
  * @test
  */
 public function iteratorMethodsAreCorrectlyImplemented()
 {
     $array1 = ['foo' => 'Foo1', 'bar' => 'Bar1'];
     $array2 = ['foo' => 'Foo2', 'bar' => 'Bar2'];
     $this->assertEquals($array1, $this->queryResult->current());
     $this->assertTrue($this->queryResult->valid());
     $this->queryResult->next();
     $this->assertEquals($array2, $this->queryResult->current());
     $this->assertTrue($this->queryResult->valid());
     $this->assertEquals(1, $this->queryResult->key());
     $this->queryResult->next();
     $this->assertFalse($this->queryResult->current());
     $this->assertFalse($this->queryResult->valid());
     $this->assertNull($this->queryResult->key());
     $this->queryResult->rewind();
     $this->assertEquals(0, $this->queryResult->key());
     $this->assertEquals($array1, $this->queryResult->current());
 }