1
0
mirror of https://github.com/danog/amp.git synced 2024-12-04 10:28:01 +01:00
amp/test/Loop/DriverStateTest.php

57 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace Amp\Test\Loop;
2017-03-15 08:40:58 +01:00
use Amp\Loop;
use Amp\Loop\Driver;
use PHPUnit\Framework\TestCase;
2018-06-18 20:00:01 +02:00
class DriverStateTest extends TestCase
{
private Driver $loop;
protected function setUp(): void
2018-06-18 20:00:01 +02:00
{
$this->loop = $this->getMockForAbstractClass(Driver::class);
}
/** @test */
public function defaultsToNull(): void
2018-06-18 20:00:01 +02:00
{
$this->assertNull($this->loop->getState("foobar"));
}
/**
* @test
* @dataProvider provideValues
*/
public function getsPreviouslySetValue($value): void
2018-06-18 20:00:01 +02:00
{
$this->loop->setState("foobar", $value);
$this->assertSame($value, $this->loop->getState("foobar"));
}
2017-03-15 08:40:58 +01:00
/**
* @test
* @dataProvider provideValues
*/
public function getsPreviouslySetValueViaAccessor($value): void
2018-06-18 20:00:01 +02:00
{
2017-03-15 08:40:58 +01:00
Loop::setState("foobar", $value);
$this->assertSame($value, Loop::getState("foobar"));
}
public function provideValues(): array
2018-06-18 20:00:01 +02:00
{
return [
["string"],
[42],
[1.001],
[true],
[false],
[null],
[new \StdClass],
];
}
}