Passed
Pull Request — master (#464)
by Kirill
12:51
created

RegistryTest::testMakeJob()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Jobs\Tests;
13
14
use PHPUnit\Framework\TestCase;
15
use Spiral\Core\Container;
16
use Spiral\Jobs\Registry\ContainerRegistry;
17
use Spiral\Jobs\Tests\Local\Job;
18
19
class RegistryTest extends TestCase
20
{
21
    public function testMakeJob(): void
22
    {
23
        $factory = new ContainerRegistry(new Container());
24
25
        $j = $factory->getHandler('spiral.jobs.tests.local.job');
26
        $this->assertInstanceOf(Job::class, $j);
27
28
        $this->assertSame(json_encode(['data' => 200]), $j->serialize(
0 ignored issues
show
Bug introduced by
The method serialize() does not exist on Spiral\Jobs\HandlerInterface. It seems like you code against a sub-type of Spiral\Jobs\HandlerInterface such as Spiral\Jobs\JobHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        $this->assertSame(json_encode(['data' => 200]), $j->/** @scrutinizer ignore-call */ serialize(
Loading history...
29
            'spiral.jobs.tests.local.job',
30
            ['data' => 200]
31
        ));
32
    }
33
34
    /**
35
     * @expectedException \Spiral\Jobs\Exception\JobException
36
     */
37
    public function testMakeUndefined(): void
38
    {
39
        $factory = new ContainerRegistry(new Container());
40
41
        $factory->getHandler('spiral.jobs.undefined');
42
    }
43
}
44