Server : Apache System : Linux indy02.toastserver.com 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64 User : palandch ( 1163) PHP Version : 7.1.33 Disable Function : NONE Directory : /home/palandch/Cloudflare-CPanel-7.0.1/vendor/guzzlehttp/ringphp/tests/Future/ |
<?php namespace GuzzleHttp\Tests\Ring\Future; use GuzzleHttp\Ring\Future\FutureArray; use React\Promise\Deferred; class FutureArrayTest extends \PHPUnit_Framework_TestCase { public function testLazilyCallsDeref() { $c = false; $deferred = new Deferred(); $f = new FutureArray( $deferred->promise(), function () use (&$c, $deferred) { $c = true; $deferred->resolve(['status' => 200]); } ); $this->assertFalse($c); $this->assertFalse($this->readAttribute($f, 'isRealized')); $this->assertEquals(200, $f['status']); $this->assertTrue($c); } public function testActsLikeArray() { $deferred = new Deferred(); $f = new FutureArray( $deferred->promise(), function () use (&$c, $deferred) { $deferred->resolve(['status' => 200]); } ); $this->assertTrue(isset($f['status'])); $this->assertEquals(200, $f['status']); $this->assertEquals(['status' => 200], $f->wait()); $this->assertEquals(1, count($f)); $f['baz'] = 10; $this->assertEquals(10, $f['baz']); unset($f['baz']); $this->assertFalse(isset($f['baz'])); $this->assertEquals(['status' => 200], iterator_to_array($f)); } /** * @expectedException \RuntimeException */ public function testThrowsWhenAccessingInvalidProperty() { $deferred = new Deferred(); $f = new FutureArray($deferred->promise(), function () {}); $f->foo; } }