From 92c5a9d538096ea2d89b362d556bbb97d0fb7744 Mon Sep 17 00:00:00 2001 From: IanM Date: Tue, 28 Nov 2023 20:38:27 +0000 Subject: [PATCH] test queue is marked as running --- tests/integration/api/StatsTest.php | 30 ++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/integration/api/StatsTest.php b/tests/integration/api/StatsTest.php index 0d9b77c..dc51788 100644 --- a/tests/integration/api/StatsTest.php +++ b/tests/integration/api/StatsTest.php @@ -12,9 +12,10 @@ namespace Blomstra\DatabaseQueue\Tests\integration\api; +use Flarum\Testing\integration\ConsoleTestCase; use Flarum\Testing\integration\TestCase; -class StatsTest extends TestCase +class StatsTest extends ConsoleTestCase { public function setUp(): void { @@ -56,4 +57,31 @@ public function admin_can_access_stats() $this->assertEquals(0, $body['pendingJobs']); $this->assertEquals(0, $body['failedJobs']); } + + /** + * @test + */ + public function admin_can_access_stats_with_queue() + { + $commandOutput = $this->runCommand(['command' => 'queue:work', '--stop-when-empty' => true]); + + $this->assertEmpty($commandOutput); + + $response = $this->send($this->request( + 'GET', + '/api/database-queue/stats', + [ + 'authenticatedAs' => 1, + ] + )); + + $this->assertEquals(200, $response->getStatusCode()); + + $body = json_decode($response->getBody(), true); + + $this->assertEquals('default', $body['queue']); + $this->assertEquals('running', $body['status']); + $this->assertEquals(0, $body['pendingJobs']); + $this->assertEquals(0, $body['failedJobs']); + } }