log_in_as_user(); $image_id_1 = $this->post_image("tests/pbx_screenshot.jpg", "test"); $image_id_2 = $this->post_image("tests/bedroom_workshop.jpg", "test2"); $image_id_3 = $this->post_image("tests/favicon.png", "test"); $idp1 = $image_id_3 + 1; $this->get_page("post/view/$image_id_1"); $this->assert_title("Image $image_id_1: test"); } public function testPrevNext() { $this->log_in_as_user(); $image_id_1 = $this->post_image("tests/pbx_screenshot.jpg", "test"); $image_id_2 = $this->post_image("tests/bedroom_workshop.jpg", "test2"); $image_id_3 = $this->post_image("tests/favicon.png", "test"); // Front image: no next, has prev $page = $this->get_page("post/next/$image_id_1"); $this->assertEquals(404, $page->code); $page = $this->get_page("post/prev/$image_id_1"); $this->assertEquals("/post/view/$image_id_2", $page->redirect); // When searching, we skip the middle $page = $this->get_page("post/prev/$image_id_1?search=test"); $this->assertEquals("/post/view/$image_id_2", $page->redirect); // Middle image: has next and prev $page = $this->get_page("post/next/$image_id_2"); $this->assertEquals("/post/view/$image_id_1", $page->redirect); $page = $this->get_page("post/prev/$image_id_2"); $this->assertEquals("/post/view/$image_id_3", $page->redirect); // Last image has next, no prev $page = $this->get_page("post/next/$image_id_3"); $this->assertEquals("/post/view/$image_id_2", $page->redirect); $page = $this->get_page("post/prev/$image_id_3"); $this->assertEquals(404, $page->code); } public function testView404() { $this->log_in_as_user(); $image_id_1 = $this->post_image("tests/pbx_screenshot.jpg", "test"); $image_id_2 = $this->post_image("tests/bedroom_workshop.jpg", "test2"); $image_id_3 = $this->post_image("tests/favicon.png", "test"); $idp1 = $image_id_3 + 1; $this->get_page("post/view/$idp1"); $this->assert_title('Image not found'); $this->get_page('post/view/-1'); $this->assert_title('Image not found'); } }