|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Dtc\QueueBundle\Tests\Doctrine; |
|
4
|
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* This test requires local mongodb running. |
|
9
|
|
|
*/ |
|
10
|
|
|
abstract class BaseLiveJobGridSourceTest extends TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
abstract protected function getLiveGridSource(); |
|
13
|
|
|
|
|
14
|
|
|
public function testLiveJobsGridSource() |
|
15
|
|
|
{ |
|
16
|
|
|
$liveJobsGridSource = $this->getLiveGridSource(); |
|
17
|
|
|
self::assertNull($liveJobsGridSource->getDefaultSort()); |
|
18
|
|
|
self::assertFalse($liveJobsGridSource->isRunning()); |
|
19
|
|
|
$count = $liveJobsGridSource->getCount(); |
|
20
|
|
|
$records = $liveJobsGridSource->getRecords(); |
|
21
|
|
|
self::assertEquals(0, $count); |
|
22
|
|
|
self::assertEmpty($records); |
|
23
|
|
|
|
|
24
|
|
|
$job = new BaseJobManagerTest::$jobClass(BaseJobManagerTest::$worker, false, null); |
|
25
|
|
|
$job->fibonacci(1); |
|
26
|
|
|
|
|
27
|
|
|
$count = $liveJobsGridSource->getCount(); |
|
28
|
|
|
$records = $liveJobsGridSource->getRecords(); |
|
29
|
|
|
self::assertEquals(1, $count); |
|
30
|
|
|
self::assertNotEmpty($records); |
|
31
|
|
|
|
|
32
|
|
|
$job = new BaseJobManagerTest::$jobClass(BaseJobManagerTest::$worker, false, null); |
|
33
|
|
|
$job->fibonacci(1); |
|
34
|
|
|
|
|
35
|
|
|
$count = $liveJobsGridSource->getCount(); |
|
36
|
|
|
$records = $liveJobsGridSource->getRecords(); |
|
37
|
|
|
self::assertEquals(2, $count); |
|
38
|
|
|
self::assertNotEmpty($records); |
|
39
|
|
|
|
|
40
|
|
|
$columns = $liveJobsGridSource->getColumns(); |
|
41
|
|
|
self::assertNotEmpty($columns); |
|
42
|
|
|
foreach ($columns as $column) { |
|
43
|
|
|
self::assertFalse($column->getOption('sortable')); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
$liveJobsGridSource->setRunning(true); |
|
47
|
|
|
self::assertTrue($liveJobsGridSource->isRunning()); |
|
48
|
|
|
$count = $liveJobsGridSource->getCount(); |
|
49
|
|
|
$records = $liveJobsGridSource->getRecords(); |
|
50
|
|
|
self::assertEquals(0, $count); |
|
51
|
|
|
self::assertEmpty($records); |
|
52
|
|
|
|
|
53
|
|
|
BaseJobManagerTest::$jobManager->getJob(); |
|
54
|
|
|
|
|
55
|
|
|
$count = $liveJobsGridSource->getCount(); |
|
56
|
|
|
$records = $liveJobsGridSource->getRecords(); |
|
57
|
|
|
self::assertEquals(1, $count); |
|
58
|
|
|
self::assertNotEmpty($records); |
|
59
|
|
|
|
|
60
|
|
|
BaseJobManagerTest::$jobManager->getJob(); |
|
61
|
|
|
|
|
62
|
|
|
$count = $liveJobsGridSource->getCount(); |
|
63
|
|
|
$records = $liveJobsGridSource->getRecords(); |
|
64
|
|
|
self::assertEquals(2, $count); |
|
65
|
|
|
self::assertNotEmpty($records); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|