$route =
new Route('/{foo}'
);
$this->
assertFalse($route->
hasOption('foo'
), '->hasOption() return false if option is not set'
);
$this->
assertEquals($route,
$route->
setOption('foo', 'bar'
), '->setOption() implements a fluent interface'
);
$this->
assertEquals('bar',
$route->
getOption('foo'
), '->setOption() sets the option'
);
$this->
assertTrue($route->
hasOption('foo'
), '->hasOption() return true if option is set'
);
} public function testDefaults() { $route =
new Route('/{foo}'
);
$route->
setDefaults(['foo' => 'bar'
]);
$this->
assertEquals(['foo' => 'bar'
],
$route->
getDefaults(), '->setDefaults() sets the defaults'
);
$this->
assertEquals($route,
$route->
setDefaults([]), '->setDefaults() implements a fluent interface'
);
$route->
setDefault('foo', 'bar'
);
$this->
assertEquals('bar',
$route->
getDefault('foo'
), '->setDefault() sets a default value'
);
$route->
setDefault('foo2', 'bar2'
);
$this->
assertEquals('bar2',
$route->
getDefault('foo2'
), '->getDefault() return the default value'
);
$this->
assertNull($route->
getDefault('not_defined'
), '->getDefault() return null if default value is not set'
);
$route->
setDefault('_controller',
$closure =
fn () => 'Hello'
);