1 | <?php |
||
16 | class LocalClientTest extends PHPUnit_Framework_TestCase |
||
17 | { |
||
18 | |||
19 | public function testGenerate() |
||
20 | { |
||
21 | $timer = new Timer(); |
||
22 | $config = new FixedConfig(1); |
||
23 | $generator = new Generator($config, $timer); |
||
24 | |||
25 | $cf = new LocalClient($generator); |
||
26 | |||
27 | $id = $cf->generateId(); |
||
28 | |||
29 | $this->assertInternalType('string', $id); |
||
30 | } |
||
31 | |||
32 | public function testStatus() |
||
33 | { |
||
34 | $timer = $this->getMockBuilder('\Gendoria\CruftFlake\Timer\TimerInterface') |
||
35 | ->disableOriginalConstructor() |
||
36 | ->getMock(); |
||
37 | $timer->expects($this->any()) |
||
38 | ->method('getUnixTimestamp') |
||
39 | ->will($this->returnValue(1341246960000)); |
||
40 | $config = new FixedConfig(1); |
||
41 | $generator = new Generator($config, $timer); |
||
42 | |||
43 | $cf = new LocalClient($generator); |
||
44 | |||
45 | $cf->generateId(); |
||
46 | $cf->generateId(); |
||
47 | |||
48 | $status = $cf->status(); |
||
49 | |||
50 | $this->assertInstanceOf('Gendoria\CruftFlake\Generator\GeneratorStatus', $status); |
||
51 | $this->assertEquals(1, $status->sequence); |
||
52 | } |
||
53 | } |
||
54 |