From 563cf677df0dc6aaab1498701761a64c40aa6ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Sat, 13 Jul 2019 17:03:41 +0200 Subject: [PATCH] Add test namespaces and simplify test bootstrap logic --- composer.json | 9 ++++++++- phpunit.xml.dist | 11 ++++++++++- tests/FactoryTest.php | 4 +++- tests/SocketTest.php | 6 ++++-- tests/{bootstrap.php => TestCase.php} | 13 +++---------- 5 files changed, 28 insertions(+), 15 deletions(-) rename tests/{bootstrap.php => TestCase.php} (72%) diff --git a/composer.json b/composer.json index 09670a2..2ab56a6 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,14 @@ } ], "autoload": { - "psr-4": {"React\\Datagram\\": "src"} + "psr-4": { + "React\\Datagram\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "React\\Tests\\Datagram\\": "tests" + } }, "require": { "php": ">=5.3", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c763a40..f2c3ea9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,15 @@ - + ./tests/ diff --git a/tests/FactoryTest.php b/tests/FactoryTest.php index 6e20766..727843d 100644 --- a/tests/FactoryTest.php +++ b/tests/FactoryTest.php @@ -1,5 +1,7 @@ loop = React\EventLoop\Factory::create(); + $this->loop = \React\EventLoop\Factory::create(); $this->resolver = $this->createResolverMock(); $this->factory = new Factory($this->loop, $this->resolver); } diff --git a/tests/SocketTest.php b/tests/SocketTest.php index 50fd7e7..290f011 100644 --- a/tests/SocketTest.php +++ b/tests/SocketTest.php @@ -1,5 +1,7 @@ loop = React\EventLoop\Factory::create(); - $this->factory = new React\Datagram\Factory($this->loop, $this->createResolverMock()); + $this->loop = \React\EventLoop\Factory::create(); + $this->factory = new \React\Datagram\Factory($this->loop, $this->createResolverMock()); } public function testCreateClientCloseWillNotBlock() diff --git a/tests/bootstrap.php b/tests/TestCase.php similarity index 72% rename from tests/bootstrap.php rename to tests/TestCase.php index 6fec244..ae4da80 100644 --- a/tests/bootstrap.php +++ b/tests/TestCase.php @@ -1,8 +1,8 @@ getMockBuilder('CallableStub')->getMock(); + return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock(); } protected function createResolverMock() @@ -34,10 +34,3 @@ protected function createResolverMock() return $this->getMockBuilder('React\Dns\Resolver\ResolverInterface')->getMock(); } } - -class CallableStub -{ - public function __invoke() - { - } -}