File tree Expand file tree Collapse file tree 4 files changed +33
-5
lines changed Expand file tree Collapse file tree 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
7979 public function __construct (&$ parent )
8080 {
8181 $ this ->parent = &$ parent ;
82+ $ this ->id = md5 (microtime ());
8283 }
8384
8485 /**
@@ -90,7 +91,6 @@ public function __construct(&$parent)
9091 */
9192 public function parse ($ object )
9293 {
93- $ this ->id = md5 (microtime ());
9494 $ this ->method = $ object ->attributes ->method ;
9595 $ this ->title = isset ($ object ->meta ->title ) ? $ object ->meta ->title : NULL ;
9696
Original file line number Diff line number Diff line change @@ -65,8 +65,8 @@ class HTTPResponse implements Comparable
6565
6666 public function __construct ($ parent )
6767 {
68- $ this ->id = md5 (microtime ());
6968 $ this ->parent = &$ parent ;
69+ $ this ->id = md5 (microtime ());
7070 }
7171
7272 /**
Original file line number Diff line number Diff line change @@ -36,7 +36,9 @@ public function setUp()
3636 $ this ->parent = $ this ->getMockBuilder ('\PHPDraft\Model\Transition ' )
3737 ->disableOriginalConstructor ()
3838 ->getMock ();
39+ $ this ->mock_function ('microtime ' , 'test ' );
3940 $ this ->class = new HTTPRequest ($ parent );
41+ $ this ->unmock_function ('microtime ' );
4042 $ this ->reflection = new ReflectionClass ('PHPDraft\Model\HTTPRequest ' );
4143 }
4244
@@ -54,9 +56,21 @@ public function tearDown()
5456 */
5557 public function testSetupCorrectly ()
5658 {
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 ());
6074 }
6175
6276 /**
Original file line number Diff line number Diff line change @@ -33,7 +33,9 @@ public function setUp()
3333 $ parent = NULL ;
3434 $ this ->parent = $ this ->getMockBuilder ('\PHPDraft\Model\HierarchyElement ' )
3535 ->getMock ();
36+ $ this ->mock_function ('microtime ' , 'test ' );
3637 $ this ->class = new HTTPResponse ($ parent );
38+ $ this ->unmock_function ('microtime ' );
3739 $ this ->reflection = new ReflectionClass ('PHPDraft\Model\HTTPResponse ' );
3840 }
3941
@@ -54,6 +56,18 @@ public function testSetupCorrectly()
5456 $ property = $ this ->reflection ->getProperty ('parent ' );
5557 $ property ->setAccessible (TRUE );
5658 $ 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 ());
5771 }
5872
5973 /**
You can’t perform that action at this time.
0 commit comments