TestTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 51
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 11 1
A testValid() 0 22 1
A testCreatedAtIsImmutable() 0 7 1
1
<?php
2
3
namespace Overwatch\TestBundle\Tests\Entity;
4
5
use Overwatch\TestBundle\Entity\Test;
6
7
/**
8
 * TestTest
9
 * A unit test for the Test Entity. Test!
10
 */
11
class TestTest extends \PHPUnit_Framework_TestCase
12
{
13
    private $test;
14
    
15
    const TEST_NAME = 'TestTest! Testing!';
16
    const TEST_ACTUAL = '1.2.3.4';
17
    const TEST_EXPECTATION = 'toBeAnAwesomeIP';
18
    
19
    public function setUp()
20
    {
21
        $this->test = new Test;
22
        $this->test
23
            ->setName(self::TEST_NAME)
24
            ->setActual(self::TEST_ACTUAL)
25
            ->setExpectation(self::TEST_EXPECTATION)
26
            ->setCreatedAt()
27
            ->setUpdatedAt()
28
        ;
29
    }
30
    
31
    public function testValid()
32
    {
33
        $this->assertEquals(self::TEST_NAME, $this->test->getName());
34
        $this->assertEquals(self::TEST_NAME, (string) $this->test);
35
        $this->assertEquals(self::TEST_ACTUAL, $this->test->getActual());
36
        $this->assertEquals(self::TEST_EXPECTATION, $this->test->getExpectation());
37
        $this->assertInstanceOf('\DateTime', $this->test->getCreatedAt());
38
        $this->assertInstanceOf('\DateTime', $this->test->getUpdatedAt());
39
        $this->assertJsonStringEqualsJsonString(
40
            json_encode([
41
                'id'          => null,
42
                'name'        => self::TEST_NAME,
43
                'actual'      => self::TEST_ACTUAL,
44
                'expectation' => self::TEST_EXPECTATION,
45
                'expected'    => null,
46
                'result'      => null,
47
                'createdAt'   => $this->test->getCreatedAt()->getTimestamp(),
48
                'updatedAt'   => $this->test->getUpdatedAt()->getTimestamp()
49
            ]),
50
            json_encode($this->test)
51
        );
52
    }
53
    
54
    public function testCreatedAtIsImmutable()
55
    {
56
        $expected = $this->test->getCreatedAt();
57
        
58
        $this->test->setCreatedAt();
59
        $this->assertEquals($expected, $this->test->getCreatedAt());
60
    }
61
}
62