From 952556ee72532636192d143294a1c181da604b76 Mon Sep 17 00:00:00 2001 From: pascalbaljet Date: Mon, 3 Apr 2023 12:35:59 +0200 Subject: [PATCH] Fixes --- .github/workflows/run-tests.yml | 9 ++------- composer.json | 4 ++-- src/Bus/PersistentBusFake.php | 2 +- src/Queue/PersistentQueueFake.php | 2 +- tests/BusTest.php | 3 ++- tests/MailTest.php | 3 ++- tests/NotificationTest.php | 3 ++- tests/QueueTest.php | 4 ++-- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 050ac21..4ed3a5c 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,18 +12,13 @@ jobs: strategy: fail-fast: true matrix: - php: [8.2, 8.1, 8.0] - laravel: [10.*, 9.*] + php: [8.2, 8.1] + laravel: [10.*] os: [ubuntu-latest, windows-latest] stability: [prefer-lowest, prefer-stable] include: - laravel: 10.* testbench: 8.* - - laravel: 9.* - testbench: 7.* - exclude: - - laravel: 10.* - php: 8.0 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} diff --git a/composer.json b/composer.json index 8b493ff..74dc192 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^8.0|^8.1|^8.2", + "php": "^8.1|^8.2", "illuminate/contracts": "^10.0", "laravel/dusk": "^7.0", "spatie/invade": "^1.1" @@ -28,7 +28,7 @@ "orchestra/testbench": "^8.0", "pestphp/pest": "^1.21", "pestphp/pest-plugin-laravel": "^1.1", - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.5|^10.0" }, "autoload": { "psr-4": { diff --git a/src/Bus/PersistentBusFake.php b/src/Bus/PersistentBusFake.php index 3a176f8..caf5ab7 100644 --- a/src/Bus/PersistentBusFake.php +++ b/src/Bus/PersistentBusFake.php @@ -43,7 +43,7 @@ public function cleanStorage() public function loadBus(): self { $unserialized = file_exists($this->storage) - ? unserialize(file_get_contents($this->storage)) + ? rescue(fn () => unserialize(file_get_contents($this->storage)), [], false) : []; $this->jobsToFake = $unserialized['jobsToFake'] ?? []; diff --git a/src/Queue/PersistentQueueFake.php b/src/Queue/PersistentQueueFake.php index b9addfa..dd95c34 100644 --- a/src/Queue/PersistentQueueFake.php +++ b/src/Queue/PersistentQueueFake.php @@ -40,7 +40,7 @@ public function cleanStorage() public function loadQueue(): self { $unserialized = file_exists($this->storage) - ? unserialize(file_get_contents($this->storage)) + ? rescue(fn () => unserialize(file_get_contents($this->storage)), [], false) : []; $this->jobsToFake = Collection::wrap($unserialized['jobsToFake'] ?? []); diff --git a/tests/BusTest.php b/tests/BusTest.php index be21b08..dc4d8c6 100644 --- a/tests/BusTest.php +++ b/tests/BusTest.php @@ -13,7 +13,8 @@ use PersistentBus; }; -afterEach(fn () => $dummyTest->tearDownPersistentBus()); +beforeEach(fn () => app(PersistentBusFake::class)->cleanStorage()); +afterEach(fn () => app(PersistentBusFake::class)->cleanStorage()); it('can persist a queued job', function () use ($dummyTest) { expect(Bus::getFacadeRoot())->toBeInstanceOf(PersistentBusFake::class); diff --git a/tests/MailTest.php b/tests/MailTest.php index 0e689af..4cd46ed 100644 --- a/tests/MailTest.php +++ b/tests/MailTest.php @@ -11,7 +11,8 @@ use PersistentMails; }; -afterEach(fn () => $dummyTest->tearDownPersistentMails()); +beforeEach(fn () => app(PersistentMailFake::class)->cleanStorage()); +afterEach(fn () => app(PersistentMailFake::class)->cleanStorage()); it('can persist sent mails', function () use ($dummyTest) { expect(Mail::getFacadeRoot())->toBeInstanceOf(PersistentMailFake::class); diff --git a/tests/NotificationTest.php b/tests/NotificationTest.php index 23dfc61..012b4d3 100644 --- a/tests/NotificationTest.php +++ b/tests/NotificationTest.php @@ -12,7 +12,8 @@ use PersistentNotifications; }; -afterEach(fn () => $dummyTest->tearDownPersistentNotifications()); +beforeEach(fn () => app(PersistentNotificationFake::class)->cleanStorage()); +afterEach(fn () => app(PersistentNotificationFake::class)->cleanStorage()); it('can persist sent notifications', function () use ($dummyTest) { expect(Notification::getFacadeRoot())->toBeInstanceOf(PersistentNotificationFake::class); diff --git a/tests/QueueTest.php b/tests/QueueTest.php index c251888..cc77b6e 100644 --- a/tests/QueueTest.php +++ b/tests/QueueTest.php @@ -12,8 +12,8 @@ use PersistentQueue; }; -beforeEach(fn () => $dummyTest->tearDownPersistentQueue()); -afterEach(fn () => $dummyTest->tearDownPersistentQueue()); +beforeEach(fn () => app(PersistentQueueFake::class)->cleanStorage()); +afterEach(fn () => app(PersistentQueueFake::class)->cleanStorage()); it('can persist a queued job', function () use ($dummyTest) { expect(Queue::getFacadeRoot())->toBeInstanceOf(PersistentQueueFake::class);