1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-12 09:09:35 +01:00
parallel/test/Worker/JobTest.php

30 lines
774 B
PHP
Raw Normal View History

2017-12-14 06:06:38 +01:00
<?php
namespace Amp\Parallel\Test\Worker;
use Amp\Parallel\Worker\Internal\Job;
use Amp\PHPUnit\TestCase;
2018-10-07 16:50:45 +02:00
class JobTest extends TestCase
{
public function testGetJob()
{
$task = new Fixtures\TestTask(42);
2017-12-14 06:06:38 +01:00
$job = new Job($task);
$this->assertSame($task, $job->getTask());
}
/**
* @expectedException \Error
* @expectedExceptionMessage Classes implementing Amp\Parallel\Worker\Task must be autoloadable by the Composer autoloader
*/
2018-10-07 16:50:45 +02:00
public function testUnserialiableClass()
{
$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();
}
}