1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
<?php
namespace PhpConsole\Test;
abstract class Storage extends Test {
/** @var \PhpConsole\Storage */ protected $storage;
/** * @return \PhpConsole\Storage */ abstract protected function initStorage();
protected function setUp() { parent::setUp(); $this->storage = $this->initStorage(); }
protected function generateKey() { return mt_rand() . mt_rand() . mt_rand(); }
public function testPush() { $key = $this->generateKey(); $data = $this->generateKey(); $this->storage->push($key, $data); $this->assertEquals($data, $this->storage->pop($key)); }
public function testPop() { $key = $this->generateKey(); $data = $this->generateKey(); $this->storage->push($key, $data); $this->storage->pop($key); $this->assertNull($this->storage->pop($key)); }
/** * @group slow */ public function testSetKeyLifetime() { $key = $this->generateKey(); $this->storage->setKeyLifetime(1); $this->storage->push($key, 123); sleep(2); $this->storage->push($this->generateKey(), 123); $this->assertNull($this->storage->pop($key)); } }
|