2008-10-11 07:09:42 +00:00
|
|
|
<?php
|
2015-09-20 17:37:36 +00:00
|
|
|
class CommentListTest extends ShimmiePHPUnitTestCase {
|
2015-09-26 10:17:13 +00:00
|
|
|
public function setUp() {
|
2015-09-20 17:37:36 +00:00
|
|
|
global $config;
|
|
|
|
parent::setUp();
|
|
|
|
$config->set_int("comment_limit", 100);
|
2009-10-26 10:50:48 +00:00
|
|
|
$this->log_out();
|
|
|
|
}
|
|
|
|
|
2015-09-26 10:17:13 +00:00
|
|
|
public function tearDown() {
|
2015-09-20 17:37:36 +00:00
|
|
|
global $config;
|
|
|
|
$config->set_int("comment_limit", 10);
|
|
|
|
parent::tearDown();
|
2009-10-26 10:50:48 +00:00
|
|
|
}
|
|
|
|
|
2015-09-26 10:17:13 +00:00
|
|
|
public function testCommentsPage() {
|
2015-09-20 17:37:36 +00:00
|
|
|
global $user;
|
|
|
|
|
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");
|
2008-10-11 07:09:42 +00:00
|
|
|
|
2009-07-15 16:09:50 +00:00
|
|
|
# a good comment
|
2015-09-20 17:37:36 +00:00
|
|
|
send_event(new CommentPostingEvent($image_id, $user, "Test Comment ASDFASDF"));
|
2009-07-15 16:09:50 +00:00
|
|
|
$this->get_page("post/view/$image_id");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_text("ASDFASDF");
|
2009-07-15 16:09:50 +00:00
|
|
|
|
|
|
|
# dupe
|
2015-09-20 17:37:36 +00:00
|
|
|
try {
|
|
|
|
send_event(new CommentPostingEvent($image_id, $user, "Test Comment ASDFASDF"));
|
|
|
|
}
|
|
|
|
catch(CommentPostingException $e) {
|
|
|
|
$this->assertContains("try and be more original", $e->getMessage());
|
|
|
|
}
|
2009-07-15 16:09:50 +00:00
|
|
|
|
|
|
|
# empty comment
|
2015-09-20 17:37:36 +00:00
|
|
|
try {
|
|
|
|
send_event(new CommentPostingEvent($image_id, $user, ""));
|
|
|
|
}
|
|
|
|
catch(CommentPostingException $e) {
|
|
|
|
$this->assertContains("Comments need text", $e->getMessage());
|
|
|
|
}
|
2009-07-15 16:09:50 +00:00
|
|
|
|
|
|
|
# whitespace is still empty...
|
2015-09-20 17:37:36 +00:00
|
|
|
try {
|
|
|
|
send_event(new CommentPostingEvent($image_id, $user, " \t\r\n"));
|
|
|
|
}
|
|
|
|
catch(CommentPostingException $e) {
|
|
|
|
$this->assertContains("Comments need text", $e->getMessage());
|
|
|
|
}
|
2009-07-15 16:09:50 +00:00
|
|
|
|
2009-08-03 09:18:40 +00:00
|
|
|
# repetitive (aka. gzip gives >= 10x improvement)
|
2015-09-20 17:37:36 +00:00
|
|
|
try {
|
|
|
|
send_event(new CommentPostingEvent($image_id, $user, str_repeat("U", 5000)));
|
|
|
|
}
|
|
|
|
catch(CommentPostingException $e) {
|
|
|
|
$this->assertContains("Comment too repetitive", $e->getMessage());
|
|
|
|
}
|
2009-07-15 16:09:50 +00:00
|
|
|
|
2010-03-14 20:51:15 +00:00
|
|
|
# test UTF8
|
2015-09-20 17:37:36 +00:00
|
|
|
send_event(new CommentPostingEvent($image_id, $user, "Test Comment むちむち"));
|
2010-03-14 20:51:15 +00:00
|
|
|
$this->get_page("post/view/$image_id");
|
|
|
|
$this->assert_text("むちむち");
|
|
|
|
|
2009-08-03 09:18:40 +00:00
|
|
|
# test that search by comment metadata works
|
2015-09-20 17:37:36 +00:00
|
|
|
// $this->get_page("post/list/commented_by=test/1");
|
|
|
|
// $this->assert_title("Image $image_id: pbx");
|
|
|
|
// $this->get_page("post/list/comments=2/1");
|
|
|
|
// $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
|
|
|
}
|
|
|
|
|
2015-09-26 10:17:13 +00:00
|
|
|
public function testSingleDel() {
|
2015-09-24 22:16:38 +00:00
|
|
|
$this->markTestIncomplete();
|
|
|
|
|
2009-08-12 14:45:13 +00:00
|
|
|
$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();
|
2008-10-11 07:09:42 +00:00
|
|
|
}
|
|
|
|
}
|