1
0
mirror of https://github.com/danog/amp.git synced 2024-12-12 09:29:45 +01:00
amp/test/Loop/DriverStateTest.php
Aaron Piotrowski 9f68bd4046
Remove Driver::run() and stop()
Added Driver::isRunning().

Driver now must be started and stopped through an instance of DriverControl.
2020-09-26 12:50:30 -05:00

57 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
{
private Driver $loop;
protected function setUp(): void
{
$this->loop = $this->getMockForAbstractClass(Driver::class);
}
/** @test */
public function defaultsToNull(): void
{
$this->assertNull($this->loop->getState("foobar"));
}
/**
* @test
* @dataProvider provideValues
*/
public function getsPreviouslySetValue($value): void
{
$this->loop->setState("foobar", $value);
$this->assertSame($value, $this->loop->getState("foobar"));
}
/**
* @test
* @dataProvider provideValues
*/
public function getsPreviouslySetValueViaAccessor($value): void
{
Loop::setState("foobar", $value);
$this->assertSame($value, Loop::getState("foobar"));
}
public function provideValues(): array
{
return [
["string"],
[42],
[1.001],
[true],
[false],
[null],
[new \StdClass],
];
}
}