This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/comment/test.php

105 lines
2.8 KiB
PHP
Raw Normal View History

<?php
2015-08-09 11:14:28 +00:00
class CommentListTest {
2009-10-26 10:50:48 +00:00
function setUp() {
$this->log_in_as_admin();
$this->get_page("setup");
$this->set_field("_config_comment_limit", "100");
$this->click("Save Settings");
$this->log_out();
}
function tearDown() {
$this->log_in_as_admin();
$this->get_page("setup");
$this->set_field("_config_comment_limit", "10");
$this->click("Save Settings");
$this->log_out();
}
function testCommentsPage() {
2009-07-15 16:09:50 +00:00
$this->log_in_as_user();
2015-08-09 11:14:28 +00:00
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
2009-07-15 16:09:50 +00:00
# a good comment
$this->get_page("post/view/$image_id");
2009-08-19 00:28:48 +00:00
$this->set_field('comment', "Test Comment ASDFASDF");
2009-07-15 16:09:50 +00:00
$this->click("Post Comment");
2009-08-19 00:28:48 +00:00
$this->assert_text("ASDFASDF");
2009-07-15 16:09:50 +00:00
# dupe
$this->get_page("post/view/$image_id");
2009-08-19 00:28:48 +00:00
$this->set_field('comment', "Test Comment ASDFASDF");
2009-07-15 16:09:50 +00:00
$this->click("Post Comment");
2009-08-19 00:28:48 +00:00
$this->assert_text("try and be more original");
2009-07-15 16:09:50 +00:00
# empty comment
$this->get_page("post/view/$image_id");
2009-08-19 00:28:48 +00:00
$this->set_field('comment', "");
2009-07-15 16:09:50 +00:00
$this->click("Post Comment");
2009-08-19 00:28:48 +00:00
$this->assert_text("Comments need text...");
2009-07-15 16:09:50 +00:00
# whitespace is still empty...
$this->get_page("post/view/$image_id");
2009-08-19 00:28:48 +00:00
$this->set_field('comment', " \t\r\n");
2009-07-15 16:09:50 +00:00
$this->click("Post Comment");
2009-08-19 00:28:48 +00:00
$this->assert_text("Comments need text...");
2009-07-15 16:09:50 +00:00
2009-08-03 09:18:40 +00:00
# repetitive (aka. gzip gives >= 10x improvement)
2009-07-15 16:09:50 +00:00
$this->get_page("post/view/$image_id");
2009-08-19 00:28:48 +00:00
$this->set_field('comment', str_repeat("U", 5000));
2009-07-15 16:09:50 +00:00
$this->click("Post Comment");
2009-08-19 00:28:48 +00:00
$this->assert_text("Comment too repetitive~");
2009-07-15 16:09:50 +00:00
2010-03-14 20:51:15 +00:00
# test UTF8
$this->get_page("post/view/$image_id");
$this->set_field('comment', "Test Comment むちむち");
$this->click("Post Comment");
$this->assert_text("むちむち");
2009-08-03 09:18:40 +00:00
# test that search by comment metadata works
$this->get_page("post/list/commented_by=test/1");
2009-08-19 00:28:48 +00:00
$this->assert_title("Image $image_id: pbx");
2010-03-22 04:00:26 +00:00
$this->get_page("post/list/comments=2/1");
2009-08-19 00:28:48 +00:00
$this->assert_title("Image $image_id: pbx");
2009-08-03 09:18:40 +00:00
2009-07-15 16:09:50 +00:00
$this->log_out();
$this->get_page('comment/list');
2009-08-19 00:28:48 +00:00
$this->assert_title('Comments');
$this->assert_text('ASDFASDF');
2009-07-15 16:09:50 +00:00
$this->get_page('comment/list/2');
2009-08-19 00:28:48 +00:00
$this->assert_title('Comments');
2009-07-15 16:09:50 +00:00
$this->log_in_as_admin();
$this->delete_image($image_id);
$this->log_out();
2009-10-23 13:26:40 +00:00
$this->get_page('comment/list');
$this->assert_title('Comments');
$this->assert_no_text('ASDFASDF');
2009-08-12 14:45:13 +00:00
}
function testSingleDel() {
$this->log_in_as_admin();
2015-08-09 11:14:28 +00:00
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
2009-08-12 14:45:13 +00:00
# make a comment
$this->get_page("post/view/$image_id");
2009-08-19 00:28:48 +00:00
$this->set_field('comment', "Test Comment ASDFASDF");
2009-08-12 14:45:13 +00:00
$this->click("Post Comment");
2009-08-19 00:28:48 +00:00
$this->assert_title("Image $image_id: pbx");
$this->assert_text("ASDFASDF");
2009-07-20 05:51:36 +00:00
2009-08-12 14:45:13 +00:00
# delete it
$this->click("Del");
2009-08-19 00:28:48 +00:00
$this->assert_title("Image $image_id: pbx");
$this->assert_no_text("ASDFASDF");
2009-08-12 14:45:13 +00:00
# tidy up
$this->delete_image($image_id);
$this->log_out();
}
}