diff options
author | marvin-borner@live.com | 2018-04-16 21:09:05 +0200 |
---|---|---|
committer | marvin-borner@live.com | 2018-04-16 21:09:05 +0200 |
commit | cf14306c2b3f82a81f8d56669a71633b4d4b5fce (patch) | |
tree | 86700651aa180026e89a66064b0364b1e4346f3f /assets/php/vendor/react/promise/tests/PromiseTest/RejectTestTrait.php | |
parent | 619b01b3615458c4ed78bfaeabb6b1a47cc8ad8b (diff) |
Main merge to user management system - files are now at /main/public/
Diffstat (limited to 'assets/php/vendor/react/promise/tests/PromiseTest/RejectTestTrait.php')
-rwxr-xr-x | assets/php/vendor/react/promise/tests/PromiseTest/RejectTestTrait.php | 368 |
1 files changed, 0 insertions, 368 deletions
diff --git a/assets/php/vendor/react/promise/tests/PromiseTest/RejectTestTrait.php b/assets/php/vendor/react/promise/tests/PromiseTest/RejectTestTrait.php deleted file mode 100755 index 063f178..0000000 --- a/assets/php/vendor/react/promise/tests/PromiseTest/RejectTestTrait.php +++ /dev/null @@ -1,368 +0,0 @@ -<?php - -namespace React\Promise\PromiseTest; - -use React\Promise; -use React\Promise\Deferred; - -trait RejectTestTrait -{ - /** - * @return \React\Promise\PromiseAdapter\PromiseAdapterInterface - */ - abstract public function getPromiseTestAdapter(callable $canceller = null); - - /** @test */ - public function rejectShouldRejectWithAnImmediateValue() - { - $adapter = $this->getPromiseTestAdapter(); - - $mock = $this->createCallableMock(); - $mock - ->expects($this->once()) - ->method('__invoke') - ->with($this->identicalTo(1)); - - $adapter->promise() - ->then($this->expectCallableNever(), $mock); - - $adapter->reject(1); - } - - /** @test */ - public function rejectShouldRejectWithFulfilledPromise() - { - $adapter = $this->getPromiseTestAdapter(); - - $mock = $this->createCallableMock(); - $mock - ->expects($this->once()) - ->method('__invoke') - ->with($this->identicalTo(1)); - - $adapter->promise() - ->then($this->expectCallableNever(), $mock); - - $adapter->reject(Promise\resolve(1)); - } - - /** @test */ - public function rejectShouldRejectWithRejectedPromise() - { - $adapter = $this->getPromiseTestAdapter(); - - $mock = $this->createCallableMock(); - $mock - ->expects($this->once()) - ->method('__invoke') - ->with($this->identicalTo(1)); - - $adapter->promise() - ->then($this->expectCallableNever(), $mock); - - $adapter->reject(Promise\reject(1)); - } - - /** @test */ - public function rejectShouldForwardReasonWhenCallbackIsNull() - { - $adapter = $this->getPromiseTestAdapter(); - - $mock = $this->createCallableMock(); - $mock - ->expects($this->once()) - ->method('__invoke') - ->with($this->identicalTo(1)); - - $adapter->promise() - ->then( - $this->expectCallableNever() - ) - ->then( - $this->expectCallableNever(), - $mock - ); - - $adapter->reject(1); - } - - /** @test */ - public function rejectShouldMakePromiseImmutable() - { - $adapter = $this->getPromiseTestAdapter(); - - $mock = $this->createCallableMock(); - $mock - ->expects($this->once()) - ->method('__invoke') - ->with($this->identicalTo(1)); - - $adapter->promise() - ->then(null, function ($value) use ($adapter) { - $adapter->reject(3); - - return Promise\reject($value); - }) - ->then( - $this->expectCallableNever(), - $mock - ); - - $adapter->reject(1); - $adapter->reject(2); - } - - /** @test */ - public function notifyShouldInvokeOtherwiseHandler() - { - $adapter = $this->getPromiseTestAdapter(); - - $mock = $this->createCallableMock(); - $mock - ->expects($this->once()) - ->method('__invoke') - ->with($this->identicalTo(1)); - - $adapter->promise() - ->otherwise($mock); - - $adapter->reject(1); - } - - /** @test */ - public function doneShouldInvokeRejectionHandler() - { - $adapter = $this->getPromiseTestAdapter(); - - $mock = $this->createCallableMock(); - $mock - ->expects($this->once()) - ->method('__invoke') - ->with($this->identicalTo(1)); - - $this->assertNull($adapter->promise()->done(null, $mock)); - $adapter->reject(1); - } - - /** @test */ - public function doneShouldThrowExceptionThrownByRejectionHandler() - { - $adapter = $this->getPromiseTestAdapter(); - - $this->setExpectedException('\Exception', 'UnhandledRejectionException'); - - $this->assertNull($adapter->promise()->done(null, function () { - throw new \Exception('UnhandledRejectionException'); - })); - $adapter->reject(1); - } - - /** @test */ - public function doneShouldThrowUnhandledRejectionExceptionWhenRejectedWithNonException() - { - $adapter = $this->getPromiseTestAdapter(); - - $this->setExpectedException('React\\Promise\\UnhandledRejectionException'); - - $this->assertNull($adapter->promise()->done()); - $adapter->reject(1); - } - - /** @test */ - public function doneShouldThrowUnhandledRejectionExceptionWhenRejectionHandlerRejects() - { - $adapter = $this->getPromiseTestAdapter(); - - $this->setExpectedException('React\\Promise\\UnhandledRejectionException'); - - $this->assertNull($adapter->promise()->done(null, function () { - return \React\Promise\reject(); - })); - $adapter->reject(1); - } - - /** @test */ - public function doneShouldThrowRejectionExceptionWhenRejectionHandlerRejectsWithException() - { - $adapter = $this->getPromiseTestAdapter(); - - $this->setExpectedException('\Exception', 'UnhandledRejectionException'); - - $this->assertNull($adapter->promise()->done(null, function () { - return \React\Promise\reject(new \Exception('UnhandledRejectionException')); - })); - $adapter->reject(1); - } - - /** @test */ - public function doneShouldThrowUnhandledRejectionExceptionWhenRejectionHandlerRetunsPendingPromiseWhichRejectsLater() - { - $adapter = $this->getPromiseTestAdapter(); - - $this->setExpectedException('React\\Promise\\UnhandledRejectionException'); - - $d = new Deferred(); - $promise = $d->promise(); - - $this->assertNull($adapter->promise()->done(null, function () use ($promise) { - return $promise; - })); - $adapter->reject(1); - $d->reject(1); - } - - /** @test */ - public function doneShouldThrowExceptionProvidedAsRejectionValue() - { - $adapter = $this->getPromiseTestAdapter(); - - $this->setExpectedException('\Exception', 'UnhandledRejectionException'); - - $this->assertNull($adapter->promise()->done()); - $adapter->reject(new \Exception('UnhandledRejectionException')); - } - - /** @test */ - public function doneShouldThrowWithDeepNestingPromiseChains() - { - $this->setExpectedException('\Exception', 'UnhandledRejectionException'); - - $exception = new \Exception('UnhandledRejectionException'); - - $d = new Deferred(); - - $result = \React\Promise\resolve(\React\Promise\resolve($d->promise()->then(function () use ($exception) { - $d = new Deferred(); - $d->resolve(); - - return \React\Promise\resolve($d->promise()->then(function () {}))->then( - function () use ($exception) { - throw $exception; - } - ); - }))); - - $result->done(); - - $d->resolve(); - } - - /** @test */ - public function doneShouldRecoverWhenRejectionHandlerCatchesException() - { - $adapter = $this->getPromiseTestAdapter(); - - $this->assertNull($adapter->promise()->done(null, function (\Exception $e) { - - })); - $adapter->reject(new \Exception('UnhandledRejectionException')); - } - - /** @test */ - public function alwaysShouldNotSuppressRejection() - { - $adapter = $this->getPromiseTestAdapter(); - - $exception = new \Exception(); - - $mock = $this->createCallableMock(); - $mock - ->expects($this->once()) - ->method('__invoke') - ->with($this->identicalTo($exception)); - - $adapter->promise() - ->always(function () {}) - ->then(null, $mock); - - $adapter->reject($exception); - } - - /** @test */ - public function alwaysShouldNotSuppressRejectionWhenHandlerReturnsANonPromise() - { - $adapter = $this->getPromiseTestAdapter(); - - $exception = new \Exception(); - - $mock = $this->createCallableMock(); - $mock - ->expects($this->once()) - ->method('__invoke') - ->with($this->identicalTo($exception)); - - $adapter->promise() - ->always(function () { - return 1; - }) - ->then(null, $mock); - - $adapter->reject($exception); - } - - /** @test */ - public function alwaysShouldNotSuppressRejectionWhenHandlerReturnsAPromise() - { - $adapter = $this->getPromiseTestAdapter(); - - $exception = new \Exception(); - - $mock = $this->createCallableMock(); - $mock - ->expects($this->once()) - ->method('__invoke') - ->with($this->identicalTo($exception)); - - $adapter->promise() - ->always(function () { - return \React\Promise\resolve(1); - }) - ->then(null, $mock); - - $adapter->reject($exception); - } - - /** @test */ - public function alwaysShouldRejectWhenHandlerThrowsForRejection() - { - $adapter = $this->getPromiseTestAdapter(); - - $exception = new \Exception(); - - $mock = $this->createCallableMock(); - $mock - ->expects($this->once()) - ->method('__invoke') - ->with($this->identicalTo($exception)); - - $adapter->promise() - ->always(function () use ($exception) { - throw $exception; - }) - ->then(null, $mock); - - $adapter->reject($exception); - } - - /** @test */ - public function alwaysShouldRejectWhenHandlerRejectsForRejection() - { - $adapter = $this->getPromiseTestAdapter(); - - $exception = new \Exception(); - - $mock = $this->createCallableMock(); - $mock - ->expects($this->once()) - ->method('__invoke') - ->with($this->identicalTo($exception)); - - $adapter->promise() - ->always(function () use ($exception) { - return \React\Promise\reject($exception); - }) - ->then(null, $mock); - - $adapter->reject($exception); - } -} |