|
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
|
|
|
|