summaryrefslogtreecommitdiff
path: root/plugins/jobs/oooold/tests/Jobs/RegistryTest.php
blob: 7abd75f71c0d0e473037ee527fcffc4ea2dbc1ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

/**
 * Spiral Framework.
 *
 * @license   MIT
 * @author    Anton Titov (Wolfy-J)
 */

declare(strict_types=1);

namespace Spiral\Jobs\Tests;

use PHPUnit\Framework\TestCase;
use Spiral\Core\Container;
use Spiral\Jobs\Registry\ContainerRegistry;
use Spiral\Jobs\Tests\Local\Job;

class RegistryTest extends TestCase
{
    public function testMakeJob(): void
    {
        $factory = new ContainerRegistry(new Container());

        $j = $factory->getHandler('spiral.jobs.tests.local.job');
        $this->assertInstanceOf(Job::class, $j);

        $this->assertSame(json_encode(['data' => 200]), $j->serialize(
            'spiral.jobs.tests.local.job',
            ['data' => 200]
        ));
    }

    /**
     * @expectedException \Spiral\Jobs\Exception\JobException
     */
    public function testMakeUndefined(): void
    {
        $factory = new ContainerRegistry(new Container());

        $factory->getHandler('spiral.jobs.undefined');
    }
}