| @@ 12-26 (lines=15) @@ | ||
| 9 | ||
| 10 | class MemoryDriverTest extends PHPUnit_Framework_TestCase |
|
| 11 | { |
|
| 12 | public function testValuesNotSet() |
|
| 13 | { |
|
| 14 | // create a coroutine to wrap the generator |
|
| 15 | ||
| 16 | Coroutine\create(function() { |
|
| 17 | $cache = new MemoryDriver(); |
|
| 18 | $actual = (yield $cache->get("foo")); |
|
| 19 | ||
| 20 | $this->assertEqualsAfterDelay(null, $actual); |
|
| 21 | })->done(); |
|
| 22 | ||
| 23 | // start the loop, so the coroutine runs |
|
| 24 | ||
| 25 | Loop\run(); |
|
| 26 | } |
|
| 27 | ||
| 28 | /** |
|
| 29 | * @param mixed $expected |
|
| @@ 45-55 (lines=11) @@ | ||
| 42 | }); |
|
| 43 | } |
|
| 44 | ||
| 45 | public function testValueSet() |
|
| 46 | { |
|
| 47 | Coroutine\create(function() { |
|
| 48 | $cache = new MemoryDriver(); |
|
| 49 | $actual = (yield $cache->set("foo", "bar")); |
|
| 50 | ||
| 51 | $this->assertEqualsAfterDelay("bar", $actual); |
|
| 52 | })->done(); |
|
| 53 | ||
| 54 | Loop\run(); |
|
| 55 | } |
|
| 56 | ||
| 57 | public function testCallbackValuesSet() |
|
| 58 | { |
|
| @@ 57-69 (lines=13) @@ | ||
| 54 | Loop\run(); |
|
| 55 | } |
|
| 56 | ||
| 57 | public function testCallbackValuesSet() |
|
| 58 | { |
|
| 59 | Coroutine\create(function() { |
|
| 60 | $cache = new MemoryDriver(); |
|
| 61 | $actual = (yield $cache->set("foo", function() { |
|
| 62 | yield "bar"; |
|
| 63 | })); |
|
| 64 | ||
| 65 | $this->assertEqualsAfterDelay("bar", $actual); |
|
| 66 | })->done(); |
|
| 67 | ||
| 68 | Loop\run(); |
|
| 69 | } |
|
| 70 | ||
| 71 | public function testValueForgotten() |
|
| 72 | { |
|