2016-05-15 14:02:04 +02:00
|
|
|
<?php
|
|
|
|
|
2016-05-24 10:37:25 +02:00
|
|
|
namespace Interop\Async\Loop;
|
|
|
|
|
2016-05-16 11:33:58 +02:00
|
|
|
class RegistryTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
2016-05-27 18:38:19 +02:00
|
|
|
private $registry;
|
2016-05-15 14:02:04 +02:00
|
|
|
|
2016-05-16 11:33:58 +02:00
|
|
|
protected function setUp()
|
|
|
|
{
|
2016-08-04 21:08:52 +02:00
|
|
|
$this->registry = $this->getMockForAbstractClass(Driver::class);
|
2016-05-15 14:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** @test */
|
2016-05-16 11:33:58 +02:00
|
|
|
public function defaultsToNull()
|
|
|
|
{
|
2016-05-27 18:38:19 +02:00
|
|
|
$this->assertNull($this->registry->fetchState("foobar"));
|
2016-05-15 14:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @dataProvider provideValues
|
|
|
|
*/
|
2016-05-16 11:33:58 +02:00
|
|
|
public function fetchesStoredValue($value)
|
|
|
|
{
|
2016-05-27 18:38:19 +02:00
|
|
|
$this->assertNull($this->registry->fetchState("foobar"));
|
|
|
|
$this->registry->storeState("foobar", $value);
|
2016-05-15 14:02:04 +02:00
|
|
|
|
2016-05-27 18:38:19 +02:00
|
|
|
$this->assertSame($value, $this->registry->fetchState("foobar"));
|
2016-05-15 14:02:04 +02:00
|
|
|
}
|
|
|
|
|
2016-05-16 11:33:58 +02:00
|
|
|
public function provideValues()
|
|
|
|
{
|
2016-05-15 14:02:04 +02:00
|
|
|
return [
|
|
|
|
["string"],
|
|
|
|
[42],
|
|
|
|
[1.001],
|
|
|
|
[true],
|
|
|
|
[false],
|
|
|
|
[null],
|
|
|
|
[new \StdClass],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|