File tree 4 files changed +33
-5
lines changed
4 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ class HTTPRequest implements Comparable
79
79
public function __construct (&$ parent )
80
80
{
81
81
$ this ->parent = &$ parent ;
82
+ $ this ->id = md5 (microtime ());
82
83
}
83
84
84
85
/**
@@ -90,7 +91,6 @@ public function __construct(&$parent)
90
91
*/
91
92
public function parse ($ object )
92
93
{
93
- $ this ->id = md5 (microtime ());
94
94
$ this ->method = $ object ->attributes ->method ;
95
95
$ this ->title = isset ($ object ->meta ->title ) ? $ object ->meta ->title : NULL ;
96
96
Original file line number Diff line number Diff line change @@ -65,8 +65,8 @@ class HTTPResponse implements Comparable
65
65
66
66
public function __construct ($ parent )
67
67
{
68
- $ this ->id = md5 (microtime ());
69
68
$ this ->parent = &$ parent ;
69
+ $ this ->id = md5 (microtime ());
70
70
}
71
71
72
72
/**
Original file line number Diff line number Diff line change @@ -36,7 +36,9 @@ public function setUp()
36
36
$ this ->parent = $ this ->getMockBuilder ('\PHPDraft\Model\Transition ' )
37
37
->disableOriginalConstructor ()
38
38
->getMock ();
39
+ $ this ->mock_function ('microtime ' , 'test ' );
39
40
$ this ->class = new HTTPRequest ($ parent );
41
+ $ this ->unmock_function ('microtime ' );
40
42
$ this ->reflection = new ReflectionClass ('PHPDraft\Model\HTTPRequest ' );
41
43
}
42
44
@@ -54,9 +56,21 @@ public function tearDown()
54
56
*/
55
57
public function testSetupCorrectly ()
56
58
{
57
- $ property = $ this ->reflection ->getProperty ('parent ' );
58
- $ property ->setAccessible (TRUE );
59
- $ this ->assertNull ($ property ->getValue ($ this ->class ));
59
+ $ parent_property = $ this ->reflection ->getProperty ('parent ' );
60
+ $ parent_property ->setAccessible (TRUE );
61
+ $ this ->assertNull ($ parent_property ->getValue ($ this ->class ));
62
+
63
+ $ id_property = $ this ->reflection ->getProperty ('id ' );
64
+ $ id_property ->setAccessible (TRUE );
65
+ $ this ->assertSame ('098f6bcd4621d373cade4e832627b4f6 ' , $ id_property ->getValue ($ this ->class ));
66
+ }
67
+
68
+ /**
69
+ * Tests if get_id returns the correct ID.
70
+ */
71
+ public function testGetId ()
72
+ {
73
+ $ this ->assertSame ('098f6bcd4621d373cade4e832627b4f6 ' , $ this ->class ->get_id ());
60
74
}
61
75
62
76
/**
Original file line number Diff line number Diff line change @@ -33,7 +33,9 @@ public function setUp()
33
33
$ parent = NULL ;
34
34
$ this ->parent = $ this ->getMockBuilder ('\PHPDraft\Model\HierarchyElement ' )
35
35
->getMock ();
36
+ $ this ->mock_function ('microtime ' , 'test ' );
36
37
$ this ->class = new HTTPResponse ($ parent );
38
+ $ this ->unmock_function ('microtime ' );
37
39
$ this ->reflection = new ReflectionClass ('PHPDraft\Model\HTTPResponse ' );
38
40
}
39
41
@@ -54,6 +56,18 @@ public function testSetupCorrectly()
54
56
$ property = $ this ->reflection ->getProperty ('parent ' );
55
57
$ property ->setAccessible (TRUE );
56
58
$ this ->assertNull ($ property ->getValue ($ this ->class ));
59
+
60
+ $ id_property = $ this ->reflection ->getProperty ('id ' );
61
+ $ id_property ->setAccessible (TRUE );
62
+ $ this ->assertSame ('098f6bcd4621d373cade4e832627b4f6 ' , $ id_property ->getValue ($ this ->class ));
63
+ }
64
+
65
+ /**
66
+ * Tests if get_id returns the correct ID.
67
+ */
68
+ public function testGetId ()
69
+ {
70
+ $ this ->assertSame ('098f6bcd4621d373cade4e832627b4f6 ' , $ this ->class ->get_id ());
57
71
}
58
72
59
73
/**
You can’t perform that action at this time.
0 commit comments