1
0
mirror of https://github.com/danog/amp.git synced 2024-11-30 04:29:08 +01:00
amp/test/Loop/DriverStateTest.php
2018-06-18 20:00:01 +02:00

58 lines
1.1 KiB
PHP

<?php
namespace Amp\Test\Loop;
use Amp\Loop;
use Amp\Loop\Driver;
use PHPUnit\Framework\TestCase;
class DriverStateTest extends TestCase
{
/** @var Driver */
private $loop;
protected function setUp()
{
$this->loop = $this->getMockForAbstractClass(Driver::class);
}
/** @test */
public function defaultsToNull()
{
$this->assertNull($this->loop->getState("foobar"));
}
/**
* @test
* @dataProvider provideValues
*/
public function getsPreviouslySetValue($value)
{
$this->loop->setState("foobar", $value);
$this->assertSame($value, $this->loop->getState("foobar"));
}
/**
* @test
* @dataProvider provideValues
*/
public function getsPreviouslySetValueViaAccessor($value)
{
Loop::setState("foobar", $value);
$this->assertSame($value, Loop::getState("foobar"));
}
public function provideValues()
{
return [
["string"],
[42],
[1.001],
[true],
[false],
[null],
[new \StdClass],
];
}
}