fix tests
This commit is contained in:
parent
eebb4c53e6
commit
9ba9bf0fdf
4 changed files with 27 additions and 21 deletions
|
@ -25,12 +25,11 @@ class UrlsTest extends TestCase
|
|||
* @param array<string> $vars
|
||||
* @return array<string>
|
||||
*/
|
||||
function _gst(array $terms): array
|
||||
{
|
||||
$gst = function (array $terms): array {
|
||||
$pre = new PageRequestEvent("GET", _get_query(search_link($terms)));
|
||||
$pre->page_matches("post/list");
|
||||
return $pre->get_search_terms();
|
||||
}
|
||||
};
|
||||
|
||||
global $config;
|
||||
foreach([true, false] as $nice_urls) {
|
||||
|
@ -38,15 +37,15 @@ class UrlsTest extends TestCase
|
|||
|
||||
$this->assertEquals(
|
||||
["bar", "foo"],
|
||||
_gst(["foo", "bar"])
|
||||
$gst(["foo", "bar"])
|
||||
);
|
||||
$this->assertEquals(
|
||||
["AC/DC"],
|
||||
_gst(["AC/DC"])
|
||||
$gst(["AC/DC"])
|
||||
);
|
||||
$this->assertEquals(
|
||||
["cat*", "rating=?"],
|
||||
_gst(["rating=?", "cat*"]),
|
||||
$gst(["rating=?", "cat*"]),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -264,4 +263,11 @@ class UrlsTest extends TestCase
|
|||
referer_or("foo", ["cake"])
|
||||
);
|
||||
}
|
||||
|
||||
public function tearDown(): void
|
||||
{
|
||||
global $config;
|
||||
$config->set_bool('nice_urls', true);
|
||||
parent::tearDown();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ class DownloadTest extends ShimmiePHPUnitTestCase
|
|||
{
|
||||
global $page;
|
||||
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||
$this->get_page("/image/$image_id");
|
||||
$this->get_page("image/$image_id");
|
||||
$this->assertEquals(PageMode::FILE, $page->mode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class LinkScanTest extends ShimmiePHPUnitTestCase
|
|||
|
||||
But there is no http://example.com/post/view/65432
|
||||
";
|
||||
$page = $this->post_page("post/list", ["search" => $text]);
|
||||
$page = $this->get_page("post/list", ["search" => $text]);
|
||||
|
||||
$this->assertEquals(PageMode::REDIRECT, $page->mode);
|
||||
$this->assertEquals("/test/post/list/id%3D{$image_id_1}%2C{$image_id_2}/1", $page->redirect);
|
||||
|
@ -35,7 +35,7 @@ class LinkScanTest extends ShimmiePHPUnitTestCase
|
|||
Look at http://example.com/_images/feb01bab5698a11dd87416724c7a89e3/foobar.jpg
|
||||
there is an image or search for e106ea2983e1b77f11e00c0c54e53805 but one that
|
||||
doesn't exist is e106ea2983e1b77f11e00c0c54e50000 o.o";
|
||||
$page = $this->post_page("post/list", ["search" => $text]);
|
||||
$page = $this->get_page("post/list", ["search" => $text]);
|
||||
|
||||
$this->assertEquals(PageMode::REDIRECT, $page->mode);
|
||||
$this->assertEquals("/test/post/list/id%3D{$image_id_1}%2C{$image_id_2}/1", $page->redirect);
|
||||
|
@ -48,7 +48,7 @@ class LinkScanTest extends ShimmiePHPUnitTestCase
|
|||
$this->post_image("tests/favicon.png", "TeStCase");
|
||||
|
||||
$text = "Look at feb01bab5698a11dd87416724c7a89e3/foobar.jpg";
|
||||
$page = $this->post_page("post/list", ["search" => $text]);
|
||||
$page = $this->get_page("post/list", ["search" => $text]);
|
||||
|
||||
$this->assertEquals(PageMode::REDIRECT, $page->mode);
|
||||
$this->assertEquals("/test/post/list/at%20feb01bab5698a11dd87416724c7a89e3%2Ffoobar.jpg%20Look/1", $page->redirect);
|
||||
|
|
Reference in a new issue