1
0
mirror of https://github.com/danog/amp.git synced 2024-12-03 18:07:57 +01:00
amp/test/RegistryTest.php

68 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2016-05-15 17:24:53 +02:00
namespace Interop\Async;
2016-05-16 11:33:58 +02:00
class RegistryTest extends \PHPUnit_Framework_TestCase
{
use Registry;
2016-05-16 11:33:58 +02:00
protected function setUp()
{
self::$registry = null;
}
/**
* @test
* @expectedException \RuntimeException
*/
2016-05-16 11:33:58 +02:00
public function fetchfailsOutsideOfLoop()
{
self::fetchState("foobar");
}
/**
* @test
* @expectedException \RuntimeException
*/
2016-05-16 11:33:58 +02:00
public function storefailsOutsideOfLoop()
{
self::fetchState("store");
}
/** @test */
2016-05-16 11:33:58 +02:00
public function defaultsToNull()
{
// emulate we're in an event loop…
self::$registry = [];
$this->assertNull(self::fetchState("foobar"));
}
/**
* @test
* @dataProvider provideValues
*/
2016-05-16 11:33:58 +02:00
public function fetchesStoredValue($value)
{
// emulate we're in an event loop…
self::$registry = [];
$this->assertNull(self::fetchState("foobar"));
self::storeState("foobar", $value);
$this->assertSame($value, self::fetchState("foobar"));
}
2016-05-16 11:33:58 +02:00
public function provideValues()
{
return [
["string"],
[42],
[1.001],
[true],
[false],
[null],
[new \StdClass],
];
}
}