Passed
Pull Request — master (#2)
by Vincent
04:15 queued 01:21
created

WithPrimeTest::test_prime_failer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 15
rs 10
1
<?php
2
namespace Bdf\QueueBundle\Tests;
3
4
require_once __DIR__.'/TestKernel.php';
5
6
use Bdf\Queue\Connection\Prime\PrimeConnection;
0 ignored issues
show
Bug introduced by
The type Bdf\Queue\Connection\Prime\PrimeConnection was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Bdf\Queue\Console\Command\Failer\AbstractFailerCommand;
8
use Bdf\Queue\Failer\DbFailedJobStorage;
0 ignored issues
show
Bug introduced by
The type Bdf\Queue\Failer\DbFailedJobStorage was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Bdf\Queue\Failer\FailedJobRepositoryAdapter;
10
use Bdf\Queue\Failer\FailedJobStorageInterface;
11
use PHPUnit\Framework\TestCase;
12
use Symfony\Bundle\FrameworkBundle\Console\Application;
13
14
class WithPrimeTest 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
23
    /**
24
     * @return void
25
     */
26
    public function test_prime_failer()
27
    {
28
        $kernel = new \TestKernel(__DIR__ . '/Fixtures/conf_with_prime_failer.yaml');
29
        $kernel->boot();
30
        $console = new Application($kernel);
31
32
        $command = $console->get('queue:failer:delete');
33
34
        $r = new \ReflectionProperty(AbstractFailerCommand::class, 'repository');
35
        $r->setAccessible(true);
36
37
        /** @var FailedJobStorageInterface $failer */
38
        $failer = $r->getValue($command);
39
40
        $this->assertTrue($this->isPrimeFailer($failer));
41
    }
42
43
    private function isPrimeFailer($storage): bool
44
    {
45
        if ($storage instanceof DbFailedJobRepository) {
0 ignored issues
show
Bug introduced by
The type Bdf\QueueBundle\Tests\DbFailedJobRepository was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
46
            return true;
47
        }
48
49
        if ($storage instanceof FailedJobRepositoryAdapter) {
50
            $r = new \ReflectionProperty(FailedJobRepositoryAdapter::class, 'storage');
51
            $r->setAccessible(true);
52
53
            return $r->getValue($storage) instanceof DbFailedJobStorage;
54
        }
55
56
        return false;
57
    }
58
}
59