$this->
assertEquals($closure,
$route->
getDefault('_controller'
), '->setDefault() sets a default value'
);
$route->
setDefaults(['foo' => 'foo'
]);
$route->
addDefaults(['bar' => 'bar'
]);
$this->
assertEquals($route,
$route->
addDefaults([]), '->addDefaults() implements a fluent interface'
);
$this->
assertEquals(['foo' => 'foo', 'bar' => 'bar'
],
$route->
getDefaults(), '->addDefaults() keep previous defaults'
);
} public function testRequirements() { $route =
new Route('/{foo}'
);
$route->
setRequirements(['foo' => '\d+'
]);
$this->
assertEquals(['foo' => '\d+'
],
$route->
getRequirements(), '->setRequirements() sets the requirements'
);
$this->
assertEquals('\d+',
$route->
getRequirement('foo'
), '->getRequirement() returns a requirement'
);
$this->
assertNull($route->
getRequirement('bar'
), '->getRequirement() returns null if a requirement is not defined'
);
$route->
setRequirements(['foo' => '^\d+$'
]);
$this->
assertEquals('\d+',
$route->
getRequirement('foo'
), '->getRequirement() removes ^ and $ from the path'
);
$this->
assertEquals($route,
$route->
setRequirements([]), '->setRequirements() implements a fluent interface'
);
$route->
setRequirements(['foo' => '\d+'
]);
$route->
addRequirements(['bar' => '\d+'
]);
$this->
assertEquals($route,
$route->
addRequirements([]), '->addRequirements() implements a fluent interface'
);
$this->
assertEquals(['foo' => '\d+', 'bar' => '\d+'
],
$route->
getRequirements(), '->addRequirement() keep previous requirements'
);
}