first commit
This commit is contained in:
21
modules/inpostshipping/vendor/guzzlehttp/ringphp/tests/Future/CompletedFutureArrayTest.php
vendored
Normal file
21
modules/inpostshipping/vendor/guzzlehttp/ringphp/tests/Future/CompletedFutureArrayTest.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace GuzzleHttp\Tests\Ring\Future;
|
||||
|
||||
use GuzzleHttp\Ring\Future\CompletedFutureArray;
|
||||
|
||||
class CompletedFutureArrayTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testReturnsAsArray()
|
||||
{
|
||||
$f = new CompletedFutureArray(['foo' => 'bar']);
|
||||
$this->assertEquals('bar', $f['foo']);
|
||||
$this->assertFalse(isset($f['baz']));
|
||||
$f['abc'] = '123';
|
||||
$this->assertTrue(isset($f['abc']));
|
||||
$this->assertEquals(['foo' => 'bar', 'abc' => '123'], iterator_to_array($f));
|
||||
$this->assertEquals(2, count($f));
|
||||
unset($f['abc']);
|
||||
$this->assertEquals(1, count($f));
|
||||
$this->assertEquals(['foo' => 'bar'], iterator_to_array($f));
|
||||
}
|
||||
}
|
||||
46
modules/inpostshipping/vendor/guzzlehttp/ringphp/tests/Future/CompletedFutureValueTest.php
vendored
Normal file
46
modules/inpostshipping/vendor/guzzlehttp/ringphp/tests/Future/CompletedFutureValueTest.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
namespace GuzzleHttp\Tests\Ring\Future;
|
||||
|
||||
use GuzzleHttp\Ring\Exception\CancelledFutureAccessException;
|
||||
use GuzzleHttp\Ring\Future\CompletedFutureValue;
|
||||
|
||||
class CompletedFutureValueTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testReturnsValue()
|
||||
{
|
||||
$f = new CompletedFutureValue('hi');
|
||||
$this->assertEquals('hi', $f->wait());
|
||||
$f->cancel();
|
||||
|
||||
$a = null;
|
||||
$f->then(function ($v) use (&$a) {
|
||||
$a = $v;
|
||||
});
|
||||
$this->assertSame('hi', $a);
|
||||
}
|
||||
|
||||
public function testThrows()
|
||||
{
|
||||
$ex = new \Exception('foo');
|
||||
$f = new CompletedFutureValue(null, $ex);
|
||||
$f->cancel();
|
||||
try {
|
||||
$f->wait();
|
||||
$this->fail('did not throw');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertSame($e, $ex);
|
||||
}
|
||||
}
|
||||
|
||||
public function testMarksAsCancelled()
|
||||
{
|
||||
$ex = new CancelledFutureAccessException();
|
||||
$f = new CompletedFutureValue(null, $ex);
|
||||
try {
|
||||
$f->wait();
|
||||
$this->fail('did not throw');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertSame($e, $ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
56
modules/inpostshipping/vendor/guzzlehttp/ringphp/tests/Future/FutureArrayTest.php
vendored
Normal file
56
modules/inpostshipping/vendor/guzzlehttp/ringphp/tests/Future/FutureArrayTest.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
109
modules/inpostshipping/vendor/guzzlehttp/ringphp/tests/Future/FutureValueTest.php
vendored
Normal file
109
modules/inpostshipping/vendor/guzzlehttp/ringphp/tests/Future/FutureValueTest.php
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
namespace GuzzleHttp\Tests\Ring\Future;
|
||||
|
||||
use GuzzleHttp\Ring\Exception\CancelledFutureAccessException;
|
||||
use GuzzleHttp\Ring\Future\FutureValue;
|
||||
use React\Promise\Deferred;
|
||||
|
||||
class FutureValueTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testDerefReturnsValue()
|
||||
{
|
||||
$called = 0;
|
||||
$deferred = new Deferred();
|
||||
|
||||
$f = new FutureValue(
|
||||
$deferred->promise(),
|
||||
function () use ($deferred, &$called) {
|
||||
$called++;
|
||||
$deferred->resolve('foo');
|
||||
}
|
||||
);
|
||||
|
||||
$this->assertEquals('foo', $f->wait());
|
||||
$this->assertEquals(1, $called);
|
||||
$this->assertEquals('foo', $f->wait());
|
||||
$this->assertEquals(1, $called);
|
||||
$f->cancel();
|
||||
$this->assertTrue($this->readAttribute($f, 'isRealized'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \GuzzleHttp\Ring\Exception\CancelledFutureAccessException
|
||||
*/
|
||||
public function testThrowsWhenAccessingCancelled()
|
||||
{
|
||||
$f = new FutureValue(
|
||||
(new Deferred())->promise(),
|
||||
function () {},
|
||||
function () { return true; }
|
||||
);
|
||||
$f->cancel();
|
||||
$f->wait();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testThrowsWhenDerefFailure()
|
||||
{
|
||||
$called = false;
|
||||
$deferred = new Deferred();
|
||||
$f = new FutureValue(
|
||||
$deferred->promise(),
|
||||
function () use(&$called) {
|
||||
$called = true;
|
||||
}
|
||||
);
|
||||
$deferred->reject(new \OutOfBoundsException());
|
||||
$f->wait();
|
||||
$this->assertFalse($called);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \GuzzleHttp\Ring\Exception\RingException
|
||||
* @expectedExceptionMessage Waiting did not resolve future
|
||||
*/
|
||||
public function testThrowsWhenDerefDoesNotResolve()
|
||||
{
|
||||
$deferred = new Deferred();
|
||||
$f = new FutureValue(
|
||||
$deferred->promise(),
|
||||
function () use(&$called) {
|
||||
$called = true;
|
||||
}
|
||||
);
|
||||
$f->wait();
|
||||
}
|
||||
|
||||
public function testThrowingCancelledFutureAccessExceptionCancels()
|
||||
{
|
||||
$deferred = new Deferred();
|
||||
$f = new FutureValue(
|
||||
$deferred->promise(),
|
||||
function () use ($deferred) {
|
||||
throw new CancelledFutureAccessException();
|
||||
}
|
||||
);
|
||||
try {
|
||||
$f->wait();
|
||||
$this->fail('did not throw');
|
||||
} catch (CancelledFutureAccessException $e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage foo
|
||||
*/
|
||||
public function testThrowingExceptionInDerefMarksAsFailed()
|
||||
{
|
||||
$deferred = new Deferred();
|
||||
$f = new FutureValue(
|
||||
$deferred->promise(),
|
||||
function () {
|
||||
throw new \Exception('foo');
|
||||
}
|
||||
);
|
||||
$f->wait();
|
||||
}
|
||||
}
|
||||
11
modules/inpostshipping/vendor/guzzlehttp/ringphp/tests/Future/index.php
vendored
Normal file
11
modules/inpostshipping/vendor/guzzlehttp/ringphp/tests/Future/index.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
Reference in New Issue
Block a user