This repository was archived by the owner on Oct 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5858
5959 ob_end_clean ();
6060});
61+
62+ test ('get route data + group ' , function () {
63+ $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
64+ $ _SERVER ['REQUEST_URI ' ] = '/thatpath ' ;
65+
66+ $ lr = new Router ;
67+
68+ $ lr ->group ('/ ' , function () use ($ lr ) {
69+ $ lr ->get ('/thatpath ' , ['name ' => 'thatroutename ' , function () use ($ lr ) {
70+ echo json_encode ($ lr ->getRoute ());
71+ }]);
72+ });
73+
74+ ob_start ();
75+ $ lr ->run ();
76+
77+ $ data = json_decode (ob_get_contents (), true );
78+
79+ expect ($ data ['path ' ])->toBe ('/thatpath ' );
80+ expect ($ data ['name ' ])->toBe ('thatroutename ' );
81+ expect ($ data ['method ' ])->toBe ('GET ' );
82+
83+ ob_end_clean ();
84+ });
85+
86+ test ('get route data + dynamic routes ' , function () {
87+ $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
88+ $ _SERVER ['REQUEST_URI ' ] = '/myusers/2 ' ;
89+
90+ $ lr = new Router ;
91+
92+ $ lr ->get ('/myusers/{id} ' , ['name ' => 'myusersroutename ' , function () use ($ lr ) {
93+ echo json_encode ($ lr ->getRoute ());
94+ }]);
95+
96+ ob_start ();
97+ $ lr ->run ();
98+
99+ $ data = json_decode (ob_get_contents (), true );
100+
101+ expect ($ data ['path ' ])->toBe ('/myusers/2 ' );
102+ expect ($ data ['name ' ])->toBe ('myusersroutename ' );
103+ expect ($ data ['method ' ])->toBe ('GET ' );
104+
105+ ob_end_clean ();
106+ });
You can’t perform that action at this time.
0 commit comments