Skip to content

Commit

Permalink
test queue is marked as running
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Nov 28, 2023
1 parent c1b43e5 commit 92c5a9d
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/integration/api/StatsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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']);
}
}

0 comments on commit 92c5a9d

Please sign in to comment.