fembooru/ext/comment/test.php

79 lines
2.2 KiB
PHP
Raw Normal View History

<?php
class CommentListTest extends ShimmieWebTestCase {
function testCommentsPage() {
2009-07-15 17:09:50 +01:00
$this->log_in_as_user();
2009-08-03 10:18:40 +01:00
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx");
2009-07-15 17:09:50 +01:00
# a good comment
$this->get_page("post/view/$image_id");
$this->setField('comment', "Test Comment ASDFASDF");
$this->click("Post Comment");
$this->assertText("ASDFASDF");
# dupe
$this->get_page("post/view/$image_id");
$this->setField('comment', "Test Comment ASDFASDF");
$this->click("Post Comment");
$this->assertText("try and be more original");
# empty comment
$this->get_page("post/view/$image_id");
$this->setField('comment', "");
$this->click("Post Comment");
$this->assertText("Comments need text...");
# whitespace is still empty...
$this->get_page("post/view/$image_id");
$this->setField('comment', " \t\r\n");
$this->click("Post Comment");
$this->assertText("Comments need text...");
2009-08-03 10:18:40 +01:00
# repetitive (aka. gzip gives >= 10x improvement)
2009-07-15 17:09:50 +01:00
$this->get_page("post/view/$image_id");
$this->setField('comment', str_repeat("U", 5000));
$this->click("Post Comment");
$this->assertText("Comment too repetitive~");
2009-08-03 10:18:40 +01:00
# test that search by comment metadata works
$this->get_page("post/list/commented_by=test/1");
$this->assertTitle("Image $image_id: pbx");
$this->get_page("post/list/comments=1/1");
$this->assertTitle("Image $image_id: pbx");
2009-07-15 17:09:50 +01:00
$this->log_out();
$this->get_page('comment/list');
$this->assertTitle('Comments');
$this->assertText('ASDFASDF');
$this->get_page('comment/list/2');
$this->assertTitle('Comments');
$this->log_in_as_admin();
$this->delete_image($image_id);
$this->log_out();
2009-08-12 15:45:13 +01:00
}
function testSingleDel() {
$this->log_in_as_admin();
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx");
# make a comment
$this->get_page("post/view/$image_id");
$this->setField('comment', "Test Comment ASDFASDF");
$this->click("Post Comment");
$this->assertTitle("Image $image_id: pbx");
$this->assertText("ASDFASDF");
2009-07-20 06:51:36 +01:00
2009-08-12 15:45:13 +01:00
# delete it
$this->click("Del");
$this->assertTitle("Image $image_id: pbx");
$this->assertNoText("ASDFASDF");
# tidy up
$this->delete_image($image_id);
$this->log_out();
}
}
?>