mirror of
https://github.com/danog/parallel.git
synced 2025-01-22 14:01:14 +01:00
More tests for LocalObject
This commit is contained in:
parent
cac4bdf71e
commit
712a4b69d2
@ -12,6 +12,21 @@ class LocalObjectTest extends TestCase
|
||||
public function testConstructor()
|
||||
{
|
||||
$object = new LocalObject(new \stdClass());
|
||||
$this->assertInternalType('object', $object->deref());
|
||||
}
|
||||
|
||||
public function testClosureObject()
|
||||
{
|
||||
$object = new LocalObject(function () {});
|
||||
$this->assertInstanceOf('Closure', $object->deref());
|
||||
}
|
||||
|
||||
public function testResource()
|
||||
{
|
||||
$object = new LocalObject(new \stdClass());
|
||||
$object->deref()->resource = fopen(__FILE__, 'r');
|
||||
$this->assertInternalType('resource', $object->deref()->resource);
|
||||
fclose($object->deref()->resource);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,4 +80,15 @@ class LocalObjectTest extends TestCase
|
||||
$local = unserialize(serialize($local));
|
||||
$this->assertSame($object, $local->deref());
|
||||
}
|
||||
|
||||
public function testPromiseInThread()
|
||||
{
|
||||
$thread = \Thread::from(function () {
|
||||
require __DIR__.'../../vendor/autoload.php';
|
||||
$promise = new LocalObject(new Promise());
|
||||
});
|
||||
|
||||
$thread->start(PTHREADS_INHERIT_INI);
|
||||
$thread->join();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user