OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
knoblyExpressLandingPage
/
vendor
/
guzzlehttp
/
promises
/
tests
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/21/2024 10:04:03 AM
rwxr-xr-x
📄
AggregateExceptionTest.php
456 bytes
08/21/2024 10:02:32 AM
rw-r--r--
📄
CoroutineTest.php
3.63 KB
08/21/2024 10:02:32 AM
rw-r--r--
📄
CreateTest.php
1.63 KB
08/21/2024 10:02:32 AM
rw-r--r--
📄
EachPromiseTest.php
14.92 KB
08/21/2024 10:02:32 AM
rw-r--r--
📄
EachTest.php
944 bytes
08/21/2024 10:02:33 AM
rw-r--r--
📄
FulfilledPromiseTest.php
3.12 KB
08/21/2024 10:02:33 AM
rw-r--r--
📄
IsTest.php
1.06 KB
08/21/2024 10:02:33 AM
rw-r--r--
📄
NotPromiseInstance.php
1.08 KB
08/21/2024 10:02:33 AM
rw-r--r--
📄
PromiseTest.php
22.44 KB
08/21/2024 10:02:33 AM
rw-r--r--
📄
PropertyHelper.php
596 bytes
08/21/2024 10:02:33 AM
rw-r--r--
📄
RejectedPromiseTest.php
4.08 KB
08/21/2024 10:02:33 AM
rw-r--r--
📄
RejectionExceptionTest.php
796 bytes
08/21/2024 10:02:33 AM
rw-r--r--
📄
TaskQueueTest.php
942 bytes
08/21/2024 10:02:33 AM
rw-r--r--
📄
Thennable.php
502 bytes
08/21/2024 10:02:33 AM
rw-r--r--
📄
Thing1.php
296 bytes
08/21/2024 10:02:33 AM
rw-r--r--
📄
Thing2.php
228 bytes
08/21/2024 10:02:33 AM
rw-r--r--
📄
UtilsTest.php
24.18 KB
08/21/2024 10:02:33 AM
rw-r--r--
Editing: RejectedPromiseTest.php
Close
<?php declare(strict_types=1); namespace GuzzleHttp\Promise\Tests; use GuzzleHttp\Promise as P; use GuzzleHttp\Promise\Promise; use GuzzleHttp\Promise\RejectedPromise; use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Promise\RejectedPromise */ class RejectedPromiseTest extends TestCase { public function testThrowsReasonWhenWaitedUpon(): void { $p = new RejectedPromise('foo'); $this->assertTrue(P\Is::rejected($p)); try { $p->wait(true); $this->fail(); } catch (\Exception $e) { $this->assertTrue(P\Is::rejected($p)); $this->assertStringContainsString('foo', $e->getMessage()); } } public function testCannotCancel(): void { $p = new RejectedPromise('foo'); $p->cancel(); $this->assertTrue(P\Is::rejected($p)); } /** * @exepctedExceptionMessage Cannot resolve a rejected promise */ public function testCannotResolve(): void { $this->expectException(\LogicException::class); $p = new RejectedPromise('foo'); $p->resolve('bar'); } /** * @expectedExceptionMessage Cannot reject a rejected promise */ public function testCannotReject(): void { $this->expectException(\LogicException::class); $p = new RejectedPromise('foo'); $p->reject('bar'); } public function testCanRejectWithSameValue(): void { $p = new RejectedPromise('foo'); $p->reject('foo'); $this->assertTrue(P\Is::rejected($p)); } public function testThrowsSpecificException(): void { $e = new \Exception(); $p = new RejectedPromise($e); try { $p->wait(true); $this->fail(); } catch (\Exception $e2) { $this->assertSame($e, $e2); } } public function testCannotResolveWithPromise(): void { $this->expectException(\InvalidArgumentException::class); new RejectedPromise(new Promise()); } public function testReturnsSelfWhenNoOnReject(): void { $p = new RejectedPromise('a'); $this->assertSame($p, $p->then()); } public function testInvokesOnRejectedAsynchronously(): void { $p = new RejectedPromise('a'); $r = null; $f = function ($reason) use (&$r): void { $r = $reason; }; $p->then(null, $f); $this->assertNull($r); P\Utils::queue()->run(); $this->assertSame('a', $r); } public function testReturnsNewRejectedWhenOnRejectedFails(): void { $p = new RejectedPromise('a'); $f = function (): void { throw new \Exception('b'); }; $p2 = $p->then(null, $f); $this->assertNotSame($p, $p2); try { $p2->wait(); $this->fail(); } catch (\Exception $e) { $this->assertSame('b', $e->getMessage()); } } public function testWaitingIsNoOp(): void { $p = new RejectedPromise('a'); $p->wait(false); $this->assertTrue(P\Is::rejected($p)); } public function testOtherwiseIsSugarForRejections(): void { $p = new RejectedPromise('foo'); $p->otherwise(function ($v) use (&$c): void { $c = $v; }); P\Utils::queue()->run(); $this->assertSame('foo', $c); } public function testCanResolveThenWithSuccess(): void { $actual = null; $p = new RejectedPromise('foo'); $p->otherwise(function ($v) { return $v.' bar'; })->then(function ($v) use (&$actual): void { $actual = $v; }); P\Utils::queue()->run(); $this->assertSame('foo bar', $actual); } public function testDoesNotTryToRejectTwiceDuringTrampoline(): void { $fp = new RejectedPromise('a'); $t1 = $fp->then(null, function ($v) { return $v.' b'; }); $t1->resolve('why!'); $this->assertSame('why!', $t1->wait()); } }