2017-12-14 06:06:38 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp\Parallel\Test\Worker;
|
|
|
|
|
|
|
|
use Amp\Parallel\Worker\Internal\Job;
|
2019-08-27 19:17:41 +02:00
|
|
|
use Amp\PHPUnit\AsyncTestCase;
|
2017-12-14 06:06:38 +01:00
|
|
|
|
2019-08-27 19:17:41 +02:00
|
|
|
class JobTest extends AsyncTestCase
|
2018-10-07 16:50:45 +02:00
|
|
|
{
|
|
|
|
public function testGetJob()
|
|
|
|
{
|
2019-01-25 21:29:32 +01:00
|
|
|
$task = new Fixtures\TestTask(42);
|
2017-12-14 06:06:38 +01:00
|
|
|
$job = new Job($task);
|
|
|
|
$this->assertSame($task, $job->getTask());
|
|
|
|
}
|
|
|
|
|
2018-10-07 16:50:45 +02:00
|
|
|
public function testUnserialiableClass()
|
|
|
|
{
|
2019-08-27 19:17:41 +02:00
|
|
|
$this->expectException(\Error::class);
|
|
|
|
$this->expectExceptionMessage('Classes implementing Amp\\Parallel\\Worker\\Task must be autoloadable by the Composer autoloader');
|
|
|
|
|
2019-01-25 21:29:32 +01:00
|
|
|
$task = new Fixtures\TestTask(42);
|
2017-12-14 06:06:38 +01:00
|
|
|
$job = new Job($task);
|
|
|
|
$serialized = \serialize($job);
|
|
|
|
$job = \unserialize($serialized, ['allowed_classes' => [Job::class]]);
|
|
|
|
$task = $job->getTask();
|
|
|
|
}
|
|
|
|
}
|