[]]); Router::reload(); } /** * test the parsing of routes. */ public function testParsing(): void { $route = new PluginShortRoute('/{plugin}', ['action' => 'index'], ['plugin' => 'foo|bar']); $result = $route->parse('/foo', 'GET'); $this->assertSame('Foo', $result['plugin']); $this->assertSame('Foo', $result['controller']); $this->assertSame('index', $result['action']); $result = $route->parse('/wrong', 'GET'); $this->assertNull($result, 'Wrong plugin name matched %s'); } /** * test the reverse routing of the plugin shortcut URLs. */ public function testMatch(): void { $route = new PluginShortRoute('/{plugin}', ['action' => 'index'], ['plugin' => 'foo|bar']); $result = $route->match(['plugin' => 'Foo', 'controller' => 'Posts', 'action' => 'index']); $this->assertNull($result, 'plugin controller mismatch was converted. %s'); $result = $route->match(['plugin' => 'Foo', 'controller' => 'Foo', 'action' => 'index']); $this->assertSame('/foo', $result); } }