From 808bc5a174f64de5bf5392c6fddc18a7772eda38 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Mon, 11 Nov 2024 14:46:27 +0300 Subject: [PATCH] Extract stubs to separate namespace --- composer.json | 3 ++- {src/Adapter => stubs}/StubAdapter.php | 3 ++- {src/Cli => stubs}/StubLoop.php | 4 +++- {src => stubs}/StubQueue.php | 3 ++- {src/Worker => stubs}/StubWorker.php | 3 ++- tests/Unit/Provider/AdapterFactoryQueueProviderTest.php | 6 +++--- tests/Unit/Provider/CompositeQueueProviderTest.php | 2 +- tests/Unit/Provider/PrototypeQueueProviderTest.php | 2 +- tests/Unit/Provider/QueueFactoryQueueProviderTest.php | 4 ++-- tests/Unit/{Adapter => Stubs}/StubAdapterTest.php | 4 ++-- tests/Unit/{Cli => Stubs}/StubLoopTest.php | 4 ++-- tests/Unit/{ => Stubs}/StubQueueTest.php | 7 +++---- tests/Unit/{Worker => Stubs}/StubWorkerTest.php | 4 ++-- 13 files changed, 27 insertions(+), 22 deletions(-) rename {src/Adapter => stubs}/StubAdapter.php (90%) rename {src/Cli => stubs}/StubLoop.php (80%) rename {src => stubs}/StubQueue.php (96%) rename {src/Worker => stubs}/StubWorker.php (82%) rename tests/Unit/{Adapter => Stubs}/StubAdapterTest.php (87%) rename tests/Unit/{Cli => Stubs}/StubLoopTest.php (86%) rename tests/Unit/{ => Stubs}/StubQueueTest.php (90%) rename tests/Unit/{Worker => Stubs}/StubWorkerTest.php (89%) diff --git a/composer.json b/composer.json index de5d4b2b..0a7ad970 100644 --- a/composer.json +++ b/composer.json @@ -61,7 +61,8 @@ }, "autoload": { "psr-4": { - "Yiisoft\\Queue\\": "src" + "Yiisoft\\Queue\\": "src", + "Yiisoft\\Queue\\Stubs\\": "stubs" } }, "autoload-dev": { diff --git a/src/Adapter/StubAdapter.php b/stubs/StubAdapter.php similarity index 90% rename from src/Adapter/StubAdapter.php rename to stubs/StubAdapter.php index 894a5951..b47c850b 100644 --- a/src/Adapter/StubAdapter.php +++ b/stubs/StubAdapter.php @@ -2,8 +2,9 @@ declare(strict_types=1); -namespace Yiisoft\Queue\Adapter; +namespace Yiisoft\Queue\Stubs; +use Yiisoft\Queue\Adapter\AdapterInterface; use Yiisoft\Queue\Enum\JobStatus; use Yiisoft\Queue\Message\MessageInterface; diff --git a/src/Cli/StubLoop.php b/stubs/StubLoop.php similarity index 80% rename from src/Cli/StubLoop.php rename to stubs/StubLoop.php index a8747365..20a238b5 100644 --- a/src/Cli/StubLoop.php +++ b/stubs/StubLoop.php @@ -2,7 +2,9 @@ declare(strict_types=1); -namespace Yiisoft\Queue\Cli; +namespace Yiisoft\Queue\Stubs; + +use Yiisoft\Queue\Cli\LoopInterface; /** * Stub loop. diff --git a/src/StubQueue.php b/stubs/StubQueue.php similarity index 96% rename from src/StubQueue.php rename to stubs/StubQueue.php index 343c4e93..8436b46a 100644 --- a/src/StubQueue.php +++ b/stubs/StubQueue.php @@ -2,12 +2,13 @@ declare(strict_types=1); -namespace Yiisoft\Queue; +namespace Yiisoft\Queue\Stubs; use Yiisoft\Queue\Adapter\AdapterInterface; use Yiisoft\Queue\Enum\JobStatus; use Yiisoft\Queue\Message\MessageInterface; use Yiisoft\Queue\Middleware\Push\MiddlewarePushInterface; +use Yiisoft\Queue\QueueInterface; /** * Stub queue that does nothing. Job status is always "done". diff --git a/src/Worker/StubWorker.php b/stubs/StubWorker.php similarity index 82% rename from src/Worker/StubWorker.php rename to stubs/StubWorker.php index 2080f893..7a939006 100644 --- a/src/Worker/StubWorker.php +++ b/stubs/StubWorker.php @@ -2,10 +2,11 @@ declare(strict_types=1); -namespace Yiisoft\Queue\Worker; +namespace Yiisoft\Queue\Stubs; use Yiisoft\Queue\Message\MessageInterface; use Yiisoft\Queue\QueueInterface; +use Yiisoft\Queue\Worker\WorkerInterface; /** * Stub worker that does nothing. diff --git a/tests/Unit/Provider/AdapterFactoryQueueProviderTest.php b/tests/Unit/Provider/AdapterFactoryQueueProviderTest.php index 410d6446..24ca9096 100644 --- a/tests/Unit/Provider/AdapterFactoryQueueProviderTest.php +++ b/tests/Unit/Provider/AdapterFactoryQueueProviderTest.php @@ -6,12 +6,12 @@ use PHPUnit\Framework\TestCase; use Yiisoft\Queue\Adapter\AdapterInterface; -use Yiisoft\Queue\Adapter\StubAdapter; -use Yiisoft\Queue\Cli\StubLoop; +use Yiisoft\Queue\Stubs\StubLoop; use Yiisoft\Queue\Provider\AdapterFactoryQueueProvider; use Yiisoft\Queue\Provider\ChannelNotFoundException; use Yiisoft\Queue\Provider\InvalidQueueConfigException; -use Yiisoft\Queue\StubQueue; +use Yiisoft\Queue\Stubs\StubQueue; +use Yiisoft\Queue\Stubs\StubAdapter; use function sprintf; diff --git a/tests/Unit/Provider/CompositeQueueProviderTest.php b/tests/Unit/Provider/CompositeQueueProviderTest.php index 4804870a..9d74e269 100644 --- a/tests/Unit/Provider/CompositeQueueProviderTest.php +++ b/tests/Unit/Provider/CompositeQueueProviderTest.php @@ -7,7 +7,7 @@ use Yiisoft\Queue\Provider\ChannelNotFoundException; use Yiisoft\Queue\Provider\CompositeQueueProvider; use Yiisoft\Queue\Provider\QueueFactoryQueueProvider; -use Yiisoft\Queue\StubQueue; +use Yiisoft\Queue\Stubs\StubQueue; use Yiisoft\Queue\Tests\TestCase; final class CompositeQueueProviderTest extends TestCase diff --git a/tests/Unit/Provider/PrototypeQueueProviderTest.php b/tests/Unit/Provider/PrototypeQueueProviderTest.php index 06fc5e18..601a0f24 100644 --- a/tests/Unit/Provider/PrototypeQueueProviderTest.php +++ b/tests/Unit/Provider/PrototypeQueueProviderTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use Yiisoft\Queue\Provider\PrototypeQueueProvider; -use Yiisoft\Queue\StubQueue; +use Yiisoft\Queue\Stubs\StubQueue; final class PrototypeQueueProviderTest extends TestCase { diff --git a/tests/Unit/Provider/QueueFactoryQueueProviderTest.php b/tests/Unit/Provider/QueueFactoryQueueProviderTest.php index 629d04fc..6a569d35 100644 --- a/tests/Unit/Provider/QueueFactoryQueueProviderTest.php +++ b/tests/Unit/Provider/QueueFactoryQueueProviderTest.php @@ -5,12 +5,12 @@ namespace Yiisoft\Queue\Tests\Unit\Provider; use PHPUnit\Framework\TestCase; -use Yiisoft\Queue\Cli\StubLoop; +use Yiisoft\Queue\Stubs\StubLoop; use Yiisoft\Queue\Provider\ChannelNotFoundException; use Yiisoft\Queue\Provider\QueueFactoryQueueProvider; use Yiisoft\Queue\Provider\InvalidQueueConfigException; use Yiisoft\Queue\QueueInterface; -use Yiisoft\Queue\StubQueue; +use Yiisoft\Queue\Stubs\StubQueue; use function sprintf; diff --git a/tests/Unit/Adapter/StubAdapterTest.php b/tests/Unit/Stubs/StubAdapterTest.php similarity index 87% rename from tests/Unit/Adapter/StubAdapterTest.php rename to tests/Unit/Stubs/StubAdapterTest.php index 3903ba84..b7337967 100644 --- a/tests/Unit/Adapter/StubAdapterTest.php +++ b/tests/Unit/Stubs/StubAdapterTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Yiisoft\Queue\Tests\Unit\Adapter; +namespace Yiisoft\Queue\Tests\Unit\Stubs; use PHPUnit\Framework\TestCase; -use Yiisoft\Queue\Adapter\StubAdapter; use Yiisoft\Queue\Message\Message; +use Yiisoft\Queue\Stubs\StubAdapter; final class StubAdapterTest extends TestCase { diff --git a/tests/Unit/Cli/StubLoopTest.php b/tests/Unit/Stubs/StubLoopTest.php similarity index 86% rename from tests/Unit/Cli/StubLoopTest.php rename to tests/Unit/Stubs/StubLoopTest.php index 3bb54fe2..c78d3af7 100644 --- a/tests/Unit/Cli/StubLoopTest.php +++ b/tests/Unit/Stubs/StubLoopTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Cli; +namespace Yiisoft\Queue\Tests\Unit\Stubs; use PHPUnit\Framework\Attributes\DataProvider; -use Yiisoft\Queue\Cli\StubLoop; +use Yiisoft\Queue\Stubs\StubLoop; use Yiisoft\Queue\Tests\TestCase; final class StubLoopTest extends TestCase diff --git a/tests/Unit/StubQueueTest.php b/tests/Unit/Stubs/StubQueueTest.php similarity index 90% rename from tests/Unit/StubQueueTest.php rename to tests/Unit/Stubs/StubQueueTest.php index 314f0915..29efe050 100644 --- a/tests/Unit/StubQueueTest.php +++ b/tests/Unit/Stubs/StubQueueTest.php @@ -2,14 +2,13 @@ declare(strict_types=1); -namespace Yiisoft\Queue\Tests\Unit; +namespace Yiisoft\Queue\Tests\Unit\Stubs; use PHPUnit\Framework\TestCase; -use Yiisoft\Queue\Adapter\StubAdapter; use Yiisoft\Queue\Message\Message; -use Yiisoft\Queue\Queue; use Yiisoft\Queue\QueueInterface; -use Yiisoft\Queue\StubQueue; +use Yiisoft\Queue\Stubs\StubQueue; +use Yiisoft\Queue\Stubs\StubAdapter; final class StubQueueTest extends TestCase { diff --git a/tests/Unit/Worker/StubWorkerTest.php b/tests/Unit/Stubs/StubWorkerTest.php similarity index 89% rename from tests/Unit/Worker/StubWorkerTest.php rename to tests/Unit/Stubs/StubWorkerTest.php index 9f8d379d..e61021ec 100644 --- a/tests/Unit/Worker/StubWorkerTest.php +++ b/tests/Unit/Stubs/StubWorkerTest.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Worker; +namespace Yiisoft\Queue\Tests\Unit\Stubs; use PHPUnit\Framework\TestCase; use Yiisoft\Queue\Message\Message; use Yiisoft\Queue\QueueInterface; -use Yiisoft\Queue\Worker\StubWorker; +use Yiisoft\Queue\Stubs\StubWorker; final class StubWorkerTest extends TestCase {