diff --git a/src/Assert.php b/src/Assert.php index 6272747..8ae6a67 100644 --- a/src/Assert.php +++ b/src/Assert.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing; use ArrayAccess; diff --git a/src/AssertableJsonString.php b/src/AssertableJsonString.php index c64a96f..b6a257b 100644 --- a/src/AssertableJsonString.php +++ b/src/AssertableJsonString.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing; use ArrayAccess; diff --git a/src/Client.php b/src/Client.php index d7cfb30..36e7e9f 100644 --- a/src/Client.php +++ b/src/Client.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing; use Hyperf\Codec\Packer\JsonPacker; diff --git a/src/Concerns/InteractsWithContainer.php b/src/Concerns/InteractsWithContainer.php index 8bd647b..4297fef 100644 --- a/src/Concerns/InteractsWithContainer.php +++ b/src/Concerns/InteractsWithContainer.php @@ -9,19 +9,22 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Concerns; use Closure; use Hyperf\Context\ApplicationContext; +use Hyperf\Contract\ApplicationInterface; use Hyperf\Di\Container; use Hyperf\Di\Definition\DefinitionSourceFactory; use Mockery; +use Mockery\MockInterface; use Psr\Container\ContainerInterface; trait InteractsWithContainer { /** - * @var null|ContainerInterface|\Hyperf\Di\Container + * @var null|Container|ContainerInterface */ protected ?ContainerInterface $container = null; @@ -56,7 +59,7 @@ protected function instance($abstract, $instance) * Mock an instance of an object in the container. * * @param string $abstract - * @return \Mockery\MockInterface + * @return MockInterface */ protected function mock($abstract, ?Closure $mock = null) { @@ -67,7 +70,7 @@ protected function mock($abstract, ?Closure $mock = null) * Mock a partial instance of an object in the container. * * @param string $abstract - * @return \Mockery\MockInterface + * @return MockInterface */ protected function partialMock($abstract, ?Closure $mock = null) { @@ -78,7 +81,7 @@ protected function partialMock($abstract, ?Closure $mock = null) * Spy an instance of an object in the container. * * @param string $abstract - * @return \Mockery\MockInterface + * @return MockInterface */ protected function spy($abstract, ?Closure $mock = null) { @@ -108,6 +111,6 @@ protected function setContainer(ContainerInterface $container): void protected function refreshContainer(): void { $this->container = ApplicationContext::setContainer($this->createContainer()); - $this->container->get(\Hyperf\Contract\ApplicationInterface::class); + $this->container->get(ApplicationInterface::class); } } diff --git a/src/Concerns/InteractsWithDatabase.php b/src/Concerns/InteractsWithDatabase.php index 3c1e752..e828e63 100644 --- a/src/Concerns/InteractsWithDatabase.php +++ b/src/Concerns/InteractsWithDatabase.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Concerns; use Hyperf\Context\ApplicationContext; diff --git a/src/Concerns/InteractsWithModelFactory.php b/src/Concerns/InteractsWithModelFactory.php index 777faad..5e8f0b9 100644 --- a/src/Concerns/InteractsWithModelFactory.php +++ b/src/Concerns/InteractsWithModelFactory.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Concerns; use Faker\Factory as FakerFactory; diff --git a/src/Concerns/MakesHttpRequests.php b/src/Concerns/MakesHttpRequests.php index b171fb0..c3d2dd4 100644 --- a/src/Concerns/MakesHttpRequests.php +++ b/src/Concerns/MakesHttpRequests.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Concerns; use Hyperf\Testing\Http\Client; diff --git a/src/Concerns/RunTestsInCoroutine.php b/src/Concerns/RunTestsInCoroutine.php index 2558a28..b892b09 100644 --- a/src/Concerns/RunTestsInCoroutine.php +++ b/src/Concerns/RunTestsInCoroutine.php @@ -9,8 +9,13 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Concerns; +use Hyperf\Coordinator\Constants; +use Hyperf\Coordinator\CoordinatorManager; +use Swoole\Coroutine; +use Swoole\Timer; use Throwable; /** @@ -36,8 +41,8 @@ final protected function runTestsInCoroutine(...$arguments) } catch (Throwable $e) { $exception = $e; } finally { - \Swoole\Timer::clearAll(); - \Hyperf\Coordinator\CoordinatorManager::until(\Hyperf\Coordinator\Constants::WORKER_EXIT)->resume(); + Timer::clearAll(); + CoordinatorManager::until(Constants::WORKER_EXIT)->resume(); } }); @@ -50,7 +55,7 @@ final protected function runTestsInCoroutine(...$arguments) final protected function runTest(): mixed { - if (extension_loaded('swoole') && \Swoole\Coroutine::getCid() === -1 && $this->enableCoroutine) { + if (extension_loaded('swoole') && Coroutine::getCid() === -1 && $this->enableCoroutine) { $this->realTestName = $this->name(); parent::setName('runTestsInCoroutine'); } diff --git a/src/Constraint/ArraySubset.php b/src/Constraint/ArraySubset.php index 20ed48e..3c70473 100644 --- a/src/Constraint/ArraySubset.php +++ b/src/Constraint/ArraySubset.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Constraint; use ArrayObject; diff --git a/src/Constraint/HasInDatabase.php b/src/Constraint/HasInDatabase.php index 82ad386..13162f5 100644 --- a/src/Constraint/HasInDatabase.php +++ b/src/Constraint/HasInDatabase.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Constraint; use Hyperf\Database\ConnectionInterface; diff --git a/src/Constraint/SeeInOrder.php b/src/Constraint/SeeInOrder.php index 7d95b79..27dcff4 100644 --- a/src/Constraint/SeeInOrder.php +++ b/src/Constraint/SeeInOrder.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Constraint; use PHPUnit\Framework\Constraint\Constraint; diff --git a/src/Debug.php b/src/Debug.php index c50cfe7..77e0099 100644 --- a/src/Debug.php +++ b/src/Debug.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing; class Debug diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php index 6e92d28..d3a52cc 100644 --- a/src/Exception/InvalidArgumentException.php +++ b/src/Exception/InvalidArgumentException.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Exception; use PHPUnit\Framework\Exception; diff --git a/src/Fluent/AssertableJson.php b/src/Fluent/AssertableJson.php index 9eb2203..a6498f1 100644 --- a/src/Fluent/AssertableJson.php +++ b/src/Fluent/AssertableJson.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Fluent; use Closure; diff --git a/src/Fluent/Concerns/Debugging.php b/src/Fluent/Concerns/Debugging.php index 2b65ba5..80f18d8 100644 --- a/src/Fluent/Concerns/Debugging.php +++ b/src/Fluent/Concerns/Debugging.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Fluent\Concerns; trait Debugging diff --git a/src/Fluent/Concerns/Has.php b/src/Fluent/Concerns/Has.php index 1cbe8bc..4a310ee 100644 --- a/src/Fluent/Concerns/Has.php +++ b/src/Fluent/Concerns/Has.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Fluent\Concerns; use Closure; diff --git a/src/Fluent/Concerns/Interaction.php b/src/Fluent/Concerns/Interaction.php index bd5e52e..22f2837 100644 --- a/src/Fluent/Concerns/Interaction.php +++ b/src/Fluent/Concerns/Interaction.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Fluent\Concerns; use Hyperf\Stringable\Str; diff --git a/src/Fluent/Concerns/Matching.php b/src/Fluent/Concerns/Matching.php index 9d59aa6..5b8dbbf 100644 --- a/src/Fluent/Concerns/Matching.php +++ b/src/Fluent/Concerns/Matching.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Fluent\Concerns; use Closure; diff --git a/src/Http/Client.php b/src/Http/Client.php index 026297a..10cb588 100644 --- a/src/Http/Client.php +++ b/src/Http/Client.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Http; use Hyperf\Collection\Arr; diff --git a/src/Http/Concerns/AssertsStatusCodes.php b/src/Http/Concerns/AssertsStatusCodes.php index b159a1d..729e693 100644 --- a/src/Http/Concerns/AssertsStatusCodes.php +++ b/src/Http/Concerns/AssertsStatusCodes.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Http\Concerns; use PHPUnit\Framework\Assert as PHPUnit; diff --git a/src/Http/TestResponse.php b/src/Http/TestResponse.php index a77b7c8..3aabdff 100644 --- a/src/Http/TestResponse.php +++ b/src/Http/TestResponse.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\Http; use ArrayAccess; diff --git a/src/HttpClient.php b/src/HttpClient.php index 5a23d99..11099a7 100644 --- a/src/HttpClient.php +++ b/src/HttpClient.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing; use GuzzleHttp\Client; diff --git a/src/HttpMessage/Upload/UploadedFile.php b/src/HttpMessage/Upload/UploadedFile.php index b032354..b7397f4 100644 --- a/src/HttpMessage/Upload/UploadedFile.php +++ b/src/HttpMessage/Upload/UploadedFile.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing\HttpMessage\Upload; class UploadedFile extends \Hyperf\HttpMessage\Upload\UploadedFile diff --git a/src/ModelFactory.php b/src/ModelFactory.php index 206d0dd..22a8029 100644 --- a/src/ModelFactory.php +++ b/src/ModelFactory.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing; use Faker\Generator; diff --git a/src/TestCase.php b/src/TestCase.php index da08ab5..558e196 100644 --- a/src/TestCase.php +++ b/src/TestCase.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Testing; use Mockery as m; diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 30386d4..5a1f9a1 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Testing; use Hyperf\Codec\Json; diff --git a/tests/DebugTest.php b/tests/DebugTest.php index f3b6a19..ab7df68 100644 --- a/tests/DebugTest.php +++ b/tests/DebugTest.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Testing; use Hyperf\Testing\Debug; diff --git a/tests/HttpClientTest.php b/tests/HttpClientTest.php index dcb65b6..c5a8b79 100644 --- a/tests/HttpClientTest.php +++ b/tests/HttpClientTest.php @@ -9,11 +9,13 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace tests; use Hyperf\Testing\HttpClient; use Mockery; use PHPUnit\Framework\Attributes\CoversNothing; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; @@ -31,7 +33,7 @@ protected function tearDown(): void Mockery::close(); } - #[\PHPUnit\Framework\Attributes\Group('NonCoroutine')] + #[Group('NonCoroutine')] public function testJsonRequest() { run(function () { diff --git a/tests/Stub/Exception/Handler/FooExceptionHandler.php b/tests/Stub/Exception/Handler/FooExceptionHandler.php index 6ae8831..86f9cac 100644 --- a/tests/Stub/Exception/Handler/FooExceptionHandler.php +++ b/tests/Stub/Exception/Handler/FooExceptionHandler.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Testing\Stub\Exception\Handler; use Hyperf\ExceptionHandler\ExceptionHandler; diff --git a/tests/Stub/FooController.php b/tests/Stub/FooController.php index 38df387..7bf7e2c 100644 --- a/tests/Stub/FooController.php +++ b/tests/Stub/FooController.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Testing\Stub; use Hyperf\Context\Context;