summaryrefslogtreecommitdiff
path: root/plugins/jobs/tests/Jobs/RegistryTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jobs/tests/Jobs/RegistryTest.php')
-rw-r--r--plugins/jobs/tests/Jobs/RegistryTest.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/plugins/jobs/tests/Jobs/RegistryTest.php b/plugins/jobs/tests/Jobs/RegistryTest.php
new file mode 100644
index 00000000..7abd75f7
--- /dev/null
+++ b/plugins/jobs/tests/Jobs/RegistryTest.php
@@ -0,0 +1,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');
+ }
+}