@@ -31,6 +31,80 @@ public function setUp()
3131 $ this ->router = new \Szenis \Router ();
3232 }
3333
34+ /**
35+ * Test the get method
36+ */
37+ public function testGet ()
38+ {
39+ $ this ->router ->get ('/get/route ' , function (){});
40+
41+ $ routes = $ this ->router ->getRoutesByMethod ('GET ' );
42+
43+ $ this ->assertEquals (1 , count ($ routes ));
44+ }
45+
46+ /**
47+ * Test the post method
48+ */
49+ public function testPost ()
50+ {
51+ $ this ->router ->post ('/post/route ' , function (){});
52+
53+ $ routes = $ this ->router ->getRoutesByMethod ('POST ' );
54+
55+ $ this ->assertEquals (1 , count ($ routes ));
56+ }
57+
58+ /**
59+ * Test the put method
60+ */
61+ public function testPut ()
62+ {
63+ $ this ->router ->put ('/put/route ' , function (){});
64+
65+ $ routes = $ this ->router ->getRoutesByMethod ('PUT ' );
66+
67+ $ this ->assertEquals (1 , count ($ routes ));
68+ }
69+
70+ /**
71+ * Test the patch method
72+ */
73+ public function testPatch ()
74+ {
75+ $ this ->router ->patch ('/patch/route ' , function (){});
76+
77+ $ routes = $ this ->router ->getRoutesByMethod ('PATCH ' );
78+
79+ $ this ->assertEquals (1 , count ($ routes ));
80+ }
81+
82+ /**
83+ * Test the delete method
84+ */
85+ public function testDelete ()
86+ {
87+ $ this ->router ->delete ('/delete/route ' , function (){});
88+
89+ $ routes = $ this ->router ->getRoutesByMethod ('DELETE ' );
90+
91+ $ this ->assertEquals (1 , count ($ routes ));
92+ }
93+
94+ /**
95+ * Test the any method
96+ */
97+ public function testAny ()
98+ {
99+ $ this ->router ->any ('/any/route ' , function (){});
100+
101+ $ getRoutes = $ this ->router ->getRoutesByMethod ('GET ' );
102+ $ putRoutes = $ this ->router ->getRoutesByMethod ('PUT ' );
103+
104+ $ this ->assertEquals (1 , count ($ getRoutes ));
105+ $ this ->assertEquals (1 , count ($ putRoutes ));
106+ }
107+
34108 /**
35109 * Test getAll method and expects 2 results
36110 */
@@ -39,7 +113,7 @@ public function testGetAll()
39113 $ this ->router ->add ('/ ' , 'GET ' , function (){});
40114 $ this ->router ->add ('/test ' , 'POST ' , function (){});
41115
42- $ routes = $ this ->router ->getAll ();
116+ $ routes = $ this ->router ->getAllRoutes ();
43117
44118 $ this ->assertEquals (2 , count ($ routes ));
45119 }
@@ -52,7 +126,7 @@ public function testGetByMethod()
52126 $ this ->router ->add ('/ ' , 'GET ' , function (){});
53127 $ this ->router ->add ('/test ' , 'POST ' , function (){});
54128
55- $ routes = $ this ->router ->getByMethod ('GET ' );
129+ $ routes = $ this ->router ->getRoutesByMethod ('GET ' );
56130
57131 $ this ->assertEquals (1 , count ($ routes ));
58132 }
@@ -64,7 +138,7 @@ public function testGetByMethodWithoutResults()
64138 {
65139 $ this ->router ->add ('/ ' , 'GET ' , function (){});
66140
67- $ routes = $ this ->router ->getByMethod ('POST ' );
141+ $ routes = $ this ->router ->getRoutesByMethod ('POST ' );
68142
69143 $ this ->assertEquals (0 , count ($ routes ));
70144 }
0 commit comments