From 446e7e08419587768d6eafd552ebb8dab8645b25 Mon Sep 17 00:00:00 2001 From: Shish Date: Fri, 31 Jul 2020 15:27:38 +0100 Subject: [PATCH] add not-a-tag tests --- ext/not_a_tag/test.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 ext/not_a_tag/test.php diff --git a/ext/not_a_tag/test.php b/ext/not_a_tag/test.php new file mode 100644 index 00000000..a75f0a77 --- /dev/null +++ b/ext/not_a_tag/test.php @@ -0,0 +1,39 @@ +execute("DELETE FROM untags"); + $database->execute("INSERT INTO untags(tag, redirect) VALUES (:tag, :redirect)", ["tag"=>"face", "redirect"=>"no-body-parts.html"]); + + $this->log_in_as_user(); + $image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx"); + $image = Image::by_id($image_id); + + // Original + $this->get_page("post/view/$image_id"); + $this->assert_title("Image $image_id: pbx"); + + // Modified OK + send_event(new TagSetEvent($image, ["two"])); + $this->get_page("post/view/$image_id"); + $this->assert_title("Image $image_id: two"); + + // Modified Bad as user - redirect + try { + send_event(new TagSetEvent($image, ["three", "face"])); + $this->assertTrue(false, "Should've had an exception"); + } catch (TagSetException $e) { + $this->assertTrue(true); + } + $this->get_page("post/view/$image_id"); + $this->assert_title("Image $image_id: two"); + + // Modified Bad as admin - ignore (should warn?) + $this->log_in_as_admin(); + send_event(new TagSetEvent($image, ["four", "face"])); + $this->get_page("post/view/$image_id"); + $this->assert_title("Image $image_id: four"); + } +}