[core] fix nicedebug
This commit is contained in:
parent
cf2edb91f5
commit
f9d06d5e7e
3 changed files with 14 additions and 4 deletions
|
@ -91,9 +91,7 @@ class PageRequestEvent extends Event
|
||||||
);
|
);
|
||||||
|
|
||||||
// break the path into parts
|
// break the path into parts
|
||||||
$args = explode('/', $path);
|
$this->args = explode('/', $path);
|
||||||
|
|
||||||
$this->args = $args;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_GET(string $key): ?string
|
public function get_GET(string $key): ?string
|
||||||
|
@ -165,6 +163,11 @@ class PageRequestEvent extends Event
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function page_starts_with(string $name): bool
|
||||||
|
{
|
||||||
|
return (count($this->args) >= 1) && ($this->args[0] == $name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if the requested path matches a given pattern.
|
* Test if the requested path matches a given pattern.
|
||||||
*
|
*
|
||||||
|
|
|
@ -324,7 +324,7 @@ class Setup extends Extension
|
||||||
{
|
{
|
||||||
global $config, $page, $user;
|
global $config, $page, $user;
|
||||||
|
|
||||||
if ($event->page_matches("nicedebug")) {
|
if ($event->page_starts_with("nicedebug")) {
|
||||||
$page->set_mode(PageMode::DATA);
|
$page->set_mode(PageMode::DATA);
|
||||||
$page->set_data(json_encode_ex([
|
$page->set_data(json_encode_ex([
|
||||||
"args" => $event->args,
|
"args" => $event->args,
|
||||||
|
|
|
@ -16,6 +16,13 @@ class SetupTest extends ShimmiePHPUnitTestCase
|
||||||
$this->assert_no_content("\n");
|
$this->assert_no_content("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNiceDebug(): void
|
||||||
|
{
|
||||||
|
// the automatic testing for shimmie2-examples depends on this
|
||||||
|
$page = $this->get_page('nicedebug/foo%2Fbar/1');
|
||||||
|
$this->assertEquals('{"args":["nicedebug","foo%2Fbar","1"]}', $page->data);
|
||||||
|
}
|
||||||
|
|
||||||
public function testAuthAnon(): void
|
public function testAuthAnon(): void
|
||||||
{
|
{
|
||||||
$this->assertException(PermissionDenied::class, function () {
|
$this->assertException(PermissionDenied::class, function () {
|
||||||
|
|
Reference in a new issue