Added test on ViewTest

pull/581/head
fadrian06 9 months ago
parent 17002a6f0d
commit 161a35a0a2

@ -121,6 +121,12 @@ class View
\extract($this->vars);
include $this->template;
if ($data !== null) {
foreach (array_keys($data) as $variable) {
unset($this->vars[$variable]);
}
}
}
/**

@ -152,4 +152,18 @@ class ViewTest extends TestCase
$viewMock::normalizePath('C:/xampp/htdocs/libs/Flight\core\index.php', '°')
);
}
public function testItDoesNotKeepThePreviousStateOfOneViewComponent(): void
{
$this->expectOutputString("<div>Hi</div>\n<div></div>\n");
$this->view->render('myComponent', ['prop' => 'Hi']);
set_error_handler(function (int $code, string $message): void {
$this->assertMatchesRegularExpression('/^Undefined variable:? \$?prop$/', $message);
});
$this->view->render('myComponent');
restore_error_handler();
}
}

@ -0,0 +1 @@
<div><?= $prop ?></div>
Loading…
Cancel
Save