public function testApiErase_ErasesRulesAndDefaults()
{
$router = $this->createRouter();
$matcher = function () {
};
$handler = function () {
};
$rule = $this->getMock(RouterRule::class, [], [$router, $matcher, $handler]);
$rule->expects($this->once())->method('cancel');
$default = $this->getMock(RouterRule::class, [], [$router, function () {
}, $handler]);
$default->expects($this->once())->method('cancel');
$this->callProtectedMethod($router, 'addRuleHandler', [$rule]);
$this->callProtectedMethod($router, 'addDefaultHandler', [$default]);
$rules = $this->getProtectedProperty($router, 'rules');
$rulesPointer = $this->getProtectedProperty($router, 'rulesPointer');
$this->assertCount(1, $rules);
$this->assertSame(1, $rulesPointer);
$rules = $this->getProtectedProperty($router, 'anchors');
$rulesPointer = $this->getProtectedProperty($router, 'anchorsPointer');
$this->assertCount(1, $rules);
$this->assertSame(1, $rulesPointer);
$router->erase();
$rules = $this->getProtectedProperty($router, 'rules');
$rulesPointer = $this->getProtectedProperty($router, 'rulesPointer');
$this->assertCount(0, $rules);
$this->assertSame(0, $rulesPointer);
$rules = $this->getProtectedProperty($router, 'anchors');
$rulesPointer = $this->getProtectedProperty($router, 'anchorsPointer');
$this->assertCount(0, $rules);
$this->assertSame(0, $rulesPointer);
}