public function testSetParamThatDoesNotExist() { $this->setExpectedException('InvalidArgumentException'); $route = new \Slim\Route('/hello/:first/:last', function () { }); $route->matches('/hello/mr/anderson'); // <-- Parses params from argument $route->setParam('middle', 'smith'); // <-- Should trigger InvalidArgumentException }
/** * Test sets param when not exists */ public function testSetRouteParamWhenNotExists() { // Prepare route $requestUri = '/hello/mr/anderson'; $route = new \Slim\Route('/hello/:first/:last', 'fooCallable'); // Parse route params $this->assertTrue($route->matches($requestUri)); // Get param try { $param = $route->setParam('foo', 'bar'); $this->fail('Did not catch expected InvalidArgumentException'); } catch (\InvalidArgumentException $e) { } }