Exemple #1
0
 public function testGroup()
 {
     $success = false;
     $handler = function (Group $group) use(&$success) {
         $this->assertSame('foo', $group->getPrefix());
         $success = true;
     };
     $this->router->group('foo', $handler);
     $this->assertTrue($success);
 }
Exemple #2
0
 public function testAny()
 {
     $handler = function () {
     };
     $refl = new \ReflectionClass($this->router);
     $collector = $refl->getProperty('collector');
     $collector->setAccessible(true);
     $collector = $collector->getValue($this->router);
     $this->assertEmpty($collector->getData()[0]);
     $this->router->any('/foo', $handler);
     $expectedHandler = new Route('/foo', $handler);
     $this->assertNotEmpty($collector->getData()[0]);
     $this->assertEquals(['/foo' => $expectedHandler], $collector->getData()[0]['GET']);
     $this->assertEquals(['/foo' => $expectedHandler], $collector->getData()[0]['POST']);
     $this->assertEquals(['/foo' => $expectedHandler], $collector->getData()[0]['PATCH']);
     $this->assertEquals(['/foo' => $expectedHandler], $collector->getData()[0]['PUT']);
     $this->assertEquals(['/foo' => $expectedHandler], $collector->getData()[0]['DELETE']);
     $this->assertEquals(['/foo' => $expectedHandler], $collector->getData()[0]['HEAD']);
     $this->assertEquals(['/foo' => $expectedHandler], $collector->getData()[0]['OPTIONS']);
 }