1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-03 10:07:49 +01:00
parallel/test/Worker/JobTest.php
2019-08-27 12:17:41 -05:00

29 lines
795 B
PHP

<?php
namespace Amp\Parallel\Test\Worker;
use Amp\Parallel\Worker\Internal\Job;
use Amp\PHPUnit\AsyncTestCase;
class JobTest extends AsyncTestCase
{
public function testGetJob()
{
$task = new Fixtures\TestTask(42);
$job = new Job($task);
$this->assertSame($task, $job->getTask());
}
public function testUnserialiableClass()
{
$this->expectException(\Error::class);
$this->expectExceptionMessage('Classes implementing Amp\\Parallel\\Worker\\Task must be autoloadable by the Composer autoloader');
$task = new Fixtures\TestTask(42);
$job = new Job($task);
$serialized = \serialize($job);
$job = \unserialize($serialized, ['allowed_classes' => [Job::class]]);
$task = $job->getTask();
}
}