|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Bdf\QueueBundle\Tests\FailerFactory; |
|
4
|
|
|
|
|
5
|
|
|
use Bdf\Dsn\Dsn; |
|
6
|
|
|
use Bdf\Prime\Prime; |
|
7
|
|
|
use Bdf\Queue\Connection\Prime\PrimeConnection; |
|
|
|
|
|
|
8
|
|
|
use \Bdf\Queue\Failer\DbFailedJobRepository; |
|
|
|
|
|
|
9
|
|
|
use Bdf\Queue\Failer\DbFailedJobStorage; |
|
|
|
|
|
|
10
|
|
|
use Bdf\Queue\Failer\FailedJobRepositoryAdapter; |
|
11
|
|
|
use Bdf\QueueBundle\FailerFactory\PrimeFailerFactory; |
|
12
|
|
|
use PHPUnit\Framework\TestCase; |
|
13
|
|
|
|
|
14
|
|
|
class PrimeFailerFactoryTest extends TestCase |
|
15
|
|
|
{ |
|
16
|
|
|
protected function setUp(): void |
|
17
|
|
|
{ |
|
18
|
|
|
if (!class_exists(PrimeConnection::class)) { |
|
19
|
|
|
$this->markTestSkipped('b2pweb/bdf-queue-prime-adapter not installed'); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
if (!Prime::isConfigured()) { |
|
23
|
|
|
Prime::configure([ |
|
24
|
|
|
'connection' => [ |
|
25
|
|
|
'config' => [ |
|
26
|
|
|
'test' => [ |
|
27
|
|
|
'adapter' => 'sqlite', |
|
28
|
|
|
'memory' => true |
|
29
|
|
|
], |
|
30
|
|
|
] |
|
31
|
|
|
], |
|
32
|
|
|
]); |
|
33
|
|
|
} |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
protected function tearDown(): void |
|
37
|
|
|
{ |
|
38
|
|
|
Prime::configure(null); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @return void |
|
43
|
|
|
*/ |
|
44
|
|
|
public function test_scheme() |
|
45
|
|
|
{ |
|
46
|
|
|
$factory = new PrimeFailerFactory(Prime::service()); |
|
47
|
|
|
|
|
48
|
|
|
$this->assertSame('prime', $factory->scheme()); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @return void |
|
53
|
|
|
*/ |
|
54
|
|
|
public function test_create_success() |
|
55
|
|
|
{ |
|
56
|
|
|
$factory = new PrimeFailerFactory(Prime::service()); |
|
57
|
|
|
|
|
58
|
|
|
$repository = $factory->create(Dsn::parse('prime://test/failed_jobs?maxRows=15')); |
|
59
|
|
|
|
|
60
|
|
|
if (class_exists(DbFailedJobRepository::class)) { |
|
61
|
|
|
$this->assertInstanceOf(DbFailedJobRepository::class, $repository); |
|
62
|
|
|
$this->assertEquals(DbFailedJobRepository::make(Prime::service(), ['connection' => 'test', 'table' => 'failed_jobs'], 15)); |
|
|
|
|
|
|
63
|
|
|
} else { |
|
64
|
|
|
$this->assertInstanceOf(FailedJobRepositoryAdapter::class, $repository); |
|
65
|
|
|
$this->assertEquals( |
|
66
|
|
|
FailedJobRepositoryAdapter::adapt(DbFailedJobStorage::make(Prime::service(), ['connection' => 'test', 'table' => 'failed_jobs'], 15)), |
|
67
|
|
|
$repository |
|
68
|
|
|
); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @return void |
|
74
|
|
|
*/ |
|
75
|
|
|
public function test_create_missing_host() |
|
76
|
|
|
{ |
|
77
|
|
|
$this->expectException(\InvalidArgumentException::class); |
|
78
|
|
|
$this->expectExceptionMessage('The connection name is required on prime failer DSN'); |
|
79
|
|
|
|
|
80
|
|
|
$factory = new PrimeFailerFactory(Prime::service()); |
|
81
|
|
|
|
|
82
|
|
|
$factory->create(Dsn::parse('prime:')); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @return void |
|
87
|
|
|
*/ |
|
88
|
|
|
public function test_create_missing_table() |
|
89
|
|
|
{ |
|
90
|
|
|
$this->expectException(\InvalidArgumentException::class); |
|
91
|
|
|
$this->expectExceptionMessage('The table name is required on prime failer DSN'); |
|
92
|
|
|
|
|
93
|
|
|
$factory = new PrimeFailerFactory(Prime::service()); |
|
94
|
|
|
|
|
95
|
|
|
$factory->create(Dsn::parse('prime://connection/')); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths