Completed
Push — master ( f7e2e6...df6590 )
by Tomasz
03:07
created

LocalClientTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 38
wmc 2
lcom 1
cbo 7
rs 10
1
<?php
2
3
namespace Gendoria\CruftFlake;
4
5
use Gendoria\CruftFlake\Config\FixedConfig;
6
use Gendoria\CruftFlake\Generator\Generator;
7
use Gendoria\CruftFlake\Local\LocalClient;
8
use Gendoria\CruftFlake\Timer\Timer;
9
use PHPUnit_Framework_TestCase;
10
11
/**
12
 * Description of LocalClientTest
13
 *
14
 * @author Tomasz Struczyński <[email protected]>
15
 */
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