diff --git a/composer.json b/composer.json index 11605e5..f960186 100644 --- a/composer.json +++ b/composer.json @@ -11,14 +11,13 @@ "require": { "php": ">=7.4", "softonic/laravel-amqp": "2.1.0", - "laravel/framework": "^7.0 || ^8.0" + "laravel/framework": "^7.0 || ^8.0 || ^9.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.16", + "friendsofphp/php-cs-fixer": "^2.0 || ^3.0", "laravel/legacy-factories": "^1.0.4", "mockery/mockery": "^1.2", - "orchestra/testbench": "^6.0", - "orchestra/database": "^6.0", + "orchestra/testbench": "^6.0 || ^7.0", "phpunit/phpunit": "^9.0", "php-mock/php-mock-mockery": "^1.3" }, diff --git a/tests/Console/Commands/EmitAllEventsTest.php b/tests/Console/Commands/EmitAllEventsTest.php index bb7caed..8bdf012 100644 --- a/tests/Console/Commands/EmitAllEventsTest.php +++ b/tests/Console/Commands/EmitAllEventsTest.php @@ -2,11 +2,13 @@ namespace Softonic\TransactionalEventPublisher\Tests\Console\Commands; +use Illuminate\Contracts\Bus\Dispatcher as BusDispatcherContract; use Illuminate\Foundation\Testing\DatabaseTransactions; use Softonic\TransactionalEventPublisher\EventStoreMiddlewares\AmqpMiddleware; use Softonic\TransactionalEventPublisher\Jobs\SendDomainEvents; use Softonic\TransactionalEventPublisher\Model\DomainEvent; use Softonic\TransactionalEventPublisher\TestCase; +use Mockery; class EmitAllEventsTest extends TestCase { @@ -30,7 +32,12 @@ public function setUp(): void public function whenRunCommandItShouldResendAllTheCurrentDomainEvents(): void { factory(DomainEvent::class, 4)->create(); - $this->expectsJobs(SendDomainEvents::class); + + $mock = Mockery::mock(BusDispatcherContract::class); + $mock->shouldReceive('dispatch')->andReturnUsing(function ($dispatched) { + $this->dispatchedJobs[] = $dispatched; + }); + $this->app->instance(BusDispatcherContract::class, $mock); $this->app->register('Softonic\TransactionalEventPublisher\ServiceProvider'); $this->artisan('event-sourcing:emit-all')->run(); @@ -43,7 +50,11 @@ public function whenRunCommandItShouldResendAllTheCurrentDomainEvents(): void public function whenRunCommandWithBatchSizeItShouldResendAllTheCurrentDomainEventsInBatch(): void { factory(DomainEvent::class, 4)->create(); - $this->expectsJobs(SendDomainEvents::class); + $mock = Mockery::mock(BusDispatcherContract::class); + $mock->shouldReceive('dispatch')->andReturnUsing(function ($dispatched) { + $this->dispatchedJobs[] = $dispatched; + }); + $this->app->instance(BusDispatcherContract::class, $mock); $this->app->register('Softonic\TransactionalEventPublisher\ServiceProvider'); $this->artisan('event-sourcing:emit-all --batchSize=2')->run();