SimpleTest::testIdIsAlwaysUnique()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
3
namespace Pachico\SlimCorrelationId\Generator;
4
5
class SimpleTest extends \PHPUnit_Framework_TestCase
6
{
7
8
    /**
9
     * @var Simple
10
     */
11
    private $sut;
12
13
    public function setUp()
14
    {
15
        $this->sut = new Simple();
16
    }
17
18
    public function testCreateReturnsString()
19
    {
20
        // Act
21
        $id = $this->sut->create();
22
        // Assert
23
        $this->assertInternalType('string', $id);
24
        $this->assertSame(10, strlen($id));
25
    }
26
27
    public function testIdIsAlwaysUnique()
28
    {
29
        // Arrange
30
        $ids = [];
31
        for ($index = 0; $index < 100; $index++) {
32
            $ids[] = $this->sut->create();
33
        }
34
        $uniqueIds = array_unique($ids);
35
        // Assert
36
        $this->assertSame(100, count($uniqueIds));
37
    }
38
}
39