diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..0925d33 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/examples/ export-ignore +/phpunit.xml.dist export-ignore +/tests/ export-ignore diff --git a/composer.json b/composer.json index 27caca6..50372f9 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,9 @@ "autoload": { "files": [ "src/functions_include.php" ] }, + "autoload-dev": { + "psr-4": { "Clue\\Tests\\React\\Block\\": "tests/" } + }, "require": { "php": ">=5.3", "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e29d977..40b9570 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,11 +1,6 @@ - + ./tests/ @@ -16,4 +11,4 @@ ./src/ - \ No newline at end of file + diff --git a/tests/FunctionAwaitAllTest.php b/tests/FunctionAwaitAllTest.php index f445e77..13cf58b 100644 --- a/tests/FunctionAwaitAllTest.php +++ b/tests/FunctionAwaitAllTest.php @@ -1,8 +1,10 @@ createPromiseResolved(1), - $this->createPromiseRejected(new Exception('test')) + $this->createPromiseRejected(new \Exception('test')) ); Block\awaitAll($all, $this->loop); @@ -55,8 +57,8 @@ public function testAwaitAllRejectedWithFalseWillWrapInUnexpectedValueException( public function testAwaitAllOnlyRejected() { $all = array( - $this->createPromiseRejected(new Exception('first')), - $this->createPromiseRejected(new Exception('second')) + $this->createPromiseRejected(new \Exception('first')), + $this->createPromiseRejected(new \Exception('second')) ); Block\awaitAll($all, $this->loop); @@ -78,14 +80,14 @@ public function testAwaitAllWithRejectedWillCancelPending() }); $all = array( - Promise\reject(new Exception('test')), + Promise\reject(new \Exception('test')), $promise ); try { Block\awaitAll($all, $this->loop); $this->fail(); - } catch (Exception $expected) { + } catch (\Exception $expected) { $this->assertEquals('test', $expected->getMessage()); $this->assertTrue($cancelled); } @@ -117,11 +119,11 @@ public function testAwaitAllPendingPromiseWithTimeoutAndCancellerShouldNotCreate gc_collect_cycles(); $promise = new \React\Promise\Promise(function () { }, function () { - throw new RuntimeException(); + throw new \RuntimeException(); }); try { Block\awaitAll(array($promise), $this->loop, 0.001); - } catch (Exception $e) { + } catch (\Exception $e) { // no-op } unset($promise, $e); diff --git a/tests/FunctionAwaitAnyTest.php b/tests/FunctionAwaitAnyTest.php index 37298a2..a9a0d35 100644 --- a/tests/FunctionAwaitAnyTest.php +++ b/tests/FunctionAwaitAnyTest.php @@ -1,9 +1,11 @@ loop, 0.001); - } catch (Exception $e) { + } catch (\Exception $e) { // no-op } unset($promise, $e); diff --git a/tests/FunctionAwaitTest.php b/tests/FunctionAwaitTest.php index a22753c..d9d40f8 100644 --- a/tests/FunctionAwaitTest.php +++ b/tests/FunctionAwaitTest.php @@ -1,8 +1,10 @@ createPromiseRejected(new Exception('test')); + $promise = $this->createPromiseRejected(new \Exception('test')); Block\await($promise, $this->loop); } @@ -44,12 +46,12 @@ public function testAwaitOneRejectedWithNullWillWrapInUnexpectedValueException() */ public function testAwaitOneRejectedWithPhp7ErrorWillWrapInUnexpectedValueExceptionWithPrevious() { - $promise = Promise\reject(new Error('Test')); + $promise = Promise\reject(new \Error('Test')); try { Block\await($promise, $this->loop); $this->fail(); - } catch (UnexpectedValueException $e) { + } catch (\UnexpectedValueException $e) { $this->assertEquals('Promise rejected with unexpected value of type Error', $e->getMessage()); $this->assertInstanceOf('Throwable', $e->getPrevious()); $this->assertEquals('Test', $e->getPrevious()->getMessage()); @@ -130,10 +132,10 @@ public function testAwaitOneRejectedShouldNotCreateAnyGarbageReferences() gc_collect_cycles(); - $promise = Promise\reject(new RuntimeException()); + $promise = Promise\reject(new \RuntimeException()); try { Block\await($promise, $this->loop); - } catch (Exception $e) { + } catch (\Exception $e) { // no-op } unset($promise, $e); @@ -149,10 +151,10 @@ public function testAwaitOneRejectedWithTimeoutShouldNotCreateAnyGarbageReferenc gc_collect_cycles(); - $promise = Promise\reject(new RuntimeException()); + $promise = Promise\reject(new \RuntimeException()); try { Block\await($promise, $this->loop, 0.001); - } catch (Exception $e) { + } catch (\Exception $e) { // no-op } unset($promise, $e); @@ -171,7 +173,7 @@ public function testAwaitNullValueShouldNotCreateAnyGarbageReferences() $promise = Promise\reject(null); try { Block\await($promise, $this->loop); - } catch (Exception $e) { + } catch (\Exception $e) { // no-op } unset($promise, $e); @@ -191,11 +193,11 @@ public function testAwaitPendingPromiseWithTimeoutAndCancellerShouldNotCreateAny gc_collect_cycles(); $promise = new \React\Promise\Promise(function () { }, function () { - throw new RuntimeException(); + throw new \RuntimeException(); }); try { Block\await($promise, $this->loop, 0.001); - } catch (Exception $e) { + } catch (\Exception $e) { // no-op } unset($promise, $e); @@ -213,7 +215,7 @@ public function testAwaitPendingPromiseWithTimeoutAndWithoutCancellerShouldNotCr $promise = new \React\Promise\Promise(function () { }); try { Block\await($promise, $this->loop, 0.001); - } catch (Exception $e) { + } catch (\Exception $e) { // no-op } unset($promise, $e); @@ -233,7 +235,7 @@ public function testAwaitPendingPromiseWithTimeoutAndNoOpCancellerShouldNotCreat }); try { Block\await($promise, $this->loop, 0.001); - } catch (Exception $e) { + } catch (\Exception $e) { // no-op } unset($promise, $e); diff --git a/tests/FunctionSleepTest.php b/tests/FunctionSleepTest.php index 074ae59..259f2ed 100644 --- a/tests/FunctionSleepTest.php +++ b/tests/FunctionSleepTest.php @@ -1,5 +1,7 @@ loop = React\EventLoop\Factory::create(); + $this->loop = \React\EventLoop\Factory::create(); } protected function createPromiseResolved($value = null, $delay = 0.01)