本文整理汇总了PHP中Guzzle\Common\Collection::getIterator方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::getIterator方法的具体用法?PHP Collection::getIterator怎么用?PHP Collection::getIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Common\Collection
的用法示例。
在下文中一共展示了Collection::getIterator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testImplementsIteratorAggregate
/**
* 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);
}
示例2: testOverwriteWithTraversable
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());
}