CompletedFutureArrayTest.php 711 B

123456789101112131415161718192021
  1. <?php
  2. namespace GuzzleHttp\Tests\Ring\Future;
  3. use GuzzleHttp\Ring\Future\CompletedFutureArray;
  4. class CompletedFutureArrayTest extends \PHPUnit_Framework_TestCase
  5. {
  6. public function testReturnsAsArray()
  7. {
  8. $f = new CompletedFutureArray(['foo' => 'bar']);
  9. $this->assertEquals('bar', $f['foo']);
  10. $this->assertFalse(isset($f['baz']));
  11. $f['abc'] = '123';
  12. $this->assertTrue(isset($f['abc']));
  13. $this->assertEquals(['foo' => 'bar', 'abc' => '123'], iterator_to_array($f));
  14. $this->assertEquals(2, count($f));
  15. unset($f['abc']);
  16. $this->assertEquals(1, count($f));
  17. $this->assertEquals(['foo' => 'bar'], iterator_to_array($f));
  18. }
  19. }