Beispiel #1
0
 /**
  * Test the IteratorAggregate implementation of theCollection object
  *
  * @covers Guzzle\Common\Collection::getIterator
  */
 public function testImplementsIteratorAggregate()
 {
     $this->coll->set('key', 'value');
     $this->assertInstanceOf('ArrayIterator', $this->coll->getIterator());
     $this->assertEquals(1, count($this->coll));
     $total = 0;
     foreach ($this->coll as $key => $value) {
         $this->assertEquals('key', $key);
         $this->assertEquals('value', $value);
         $total++;
     }
     $this->assertEquals(1, $total);
 }
Beispiel #2
0
 public function testOverwriteWithTraversable()
 {
     $c = new Collection(array('foo' => 1, 'baz' => 2, 'bar' => 3));
     $b = new Collection(array('foo' => 10, 'bar' => 300));
     $c->overwriteWith($b->getIterator());
     $this->assertEquals(array('foo' => 10, 'baz' => 2, 'bar' => 300), $c->getAll());
 }