fix tests

This commit is contained in:
Shish 2024-02-10 00:00:02 +00:00
parent 77b755e68b
commit 09774416c3
2 changed files with 3 additions and 34 deletions

View file

@ -162,35 +162,4 @@ class UtilTest extends TestCase
path_to_tags("/category:/tag/baz.jpg") path_to_tags("/category:/tag/baz.jpg")
); );
} }
public function test_get_query(): void
{
// niceurls
$_SERVER["REQUEST_URI"] = "/test/tasty/cake";
$this->assertEquals("/tasty/cake", _get_query());
// no niceurls
$_SERVER["REQUEST_URI"] = "/test/index.php?q=/tasty/cake";
$this->assertEquals("/tasty/cake", _get_query());
// leave url encoding alone
$_SERVER["REQUEST_URI"] = "/test/index.php?q=/tasty/cake%20pie";
$this->assertEquals("/tasty/cake%20pie", _get_query());
// if just viewing index.php
$_SERVER["REQUEST_URI"] = "/test/index.php";
$this->assertEquals("/", _get_query());
// niceurl root
$_SERVER["REQUEST_URI"] = "/test/";
$this->assertEquals("/", _get_query());
// niceurls with encoded slashes
$_SERVER["REQUEST_URI"] = "/test/post/list/tasty%2Fcake/1";
$this->assertEquals("/post/list/tasty%2Fcake/1", _get_query());
// query string with encoded slashes
$_SERVER["REQUEST_URI"] = "/test/index.php?q=/post/list/tasty%2Fcake/1";
$this->assertEquals("/post/list/tasty%2Fcake/1", _get_query());
}
} }

View file

@ -19,7 +19,7 @@ class LinkScanTest extends ShimmiePHPUnitTestCase
But there is no http://example.com/post/view/65432 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(PageMode::REDIRECT, $page->mode);
$this->assertEquals("/test/post/list/id%3D{$image_id_1}%2C{$image_id_2}/1", $page->redirect); $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 Look at http://example.com/_images/feb01bab5698a11dd87416724c7a89e3/foobar.jpg
there is an image or search for e106ea2983e1b77f11e00c0c54e53805 but one that there is an image or search for e106ea2983e1b77f11e00c0c54e53805 but one that
doesn't exist is e106ea2983e1b77f11e00c0c54e50000 o.o"; 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(PageMode::REDIRECT, $page->mode);
$this->assertEquals("/test/post/list/id%3D{$image_id_1}%2C{$image_id_2}/1", $page->redirect); $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"); $this->post_image("tests/favicon.png", "TeStCase");
$text = "Look at feb01bab5698a11dd87416724c7a89e3/foobar.jpg"; $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(PageMode::REDIRECT, $page->mode);
$this->assertEquals("/test/post/list/at%20feb01bab5698a11dd87416724c7a89e3%2Ffoobar.jpg%20Look/1", $page->redirect); $this->assertEquals("/test/post/list/at%20feb01bab5698a11dd87416724c7a89e3%2Ffoobar.jpg%20Look/1", $page->redirect);