MOAR TESTING.

This commit is contained in:
Shish 2009-07-20 06:51:36 +01:00
parent 4cb59929d3
commit aa7969cdde
32 changed files with 203 additions and 29 deletions

View File

@ -15,6 +15,16 @@ class BanWordsTest extends ShimmieWebTestCase {
$this->click("Post Comment");
$this->assertTitle("Comment Blocked");
$this->get_page("post/view/$image_id");
$this->setField('comment', "kittens and ViagrA");
$this->click("Post Comment");
$this->assertTitle("Comment Blocked");
$this->get_page("post/view/$image_id");
$this->setField('comment', "kittens and viagra!");
$this->click("Post Comment");
$this->assertTitle("Comment Blocked");
$this->get_page("post/view/$image_id");
$this->setField('comment', "some link to http://something.cn/");
$this->click("Post Comment");
@ -23,6 +33,7 @@ class BanWordsTest extends ShimmieWebTestCase {
$this->get_page('comment/list');
$this->assertTitle('Comments');
$this->assertNoText('viagra');
$this->assertNoText('ViagrA');
$this->assertNoText('http://something.cn/');
$this->log_out();

View File

@ -8,6 +8,8 @@ class BulkAddTest extends ShimmieWebTestCase {
$this->setField('dir', "contrib/simpletest");
$this->click("Add");
# FIXME: test that the output here makes sense, no "adding foo.php ... ok"
$this->get_page("post/list/hash=17fc89f372ed3636e28bd25cc7f3bac1/1");
$this->assertTitle(new PatternExpectation("/^Image \d+: data/"));
$this->click("Delete");

22
contrib/downtime/test.php Normal file
View File

@ -0,0 +1,22 @@
<?php
class DowntimeTest extends ShimmieWebTestCase {
function testDowntime() {
$this->log_in_as_admin();
$this->get_page("setup");
$this->setField("_config_downtime", true);
$this->setField("_config_downtime_message", "brb, unit testing");
$this->click("Save Settings");
$this->assertText("DOWNTIME MODE IS ON!");
$this->log_out();
$this->assertText("brb, unit testing");
$this->log_in_as_admin();
$this->get_page("setup");
$this->setField("_config_downtime", false);
$this->click("Save Settings");
$this->assertNoText("DOWNTIME MODE IS ON!");
$this->log_out();
}
}
?>

View File

@ -0,0 +1,19 @@
<?php
class EmoticonTest extends ShimmieWebTestCase {
function testEmoticons() {
$this->log_in_as_user();
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
$this->get_page("post/view/$image_id");
$this->setField('comment', ":cool: :beans:");
$this->click("Post Comment");
$this->assertNoText(":cool:"); # FIXME: test for working image link
#$this->assertText(":beans:"); # FIXME: this should be left as-is
$this->log_out();
$this->log_in_as_admin();
$this->delete_image($image_id);
$this->log_out();
}
}
?>

10
contrib/et/test.php Normal file
View File

@ -0,0 +1,10 @@
<?php
class ETTest extends ShimmieWebTestCase {
function testET() {
$this->log_in_as_admin();
$this->get_page("system_info");
$this->assertTitle("System Info");
$this->log_out();
}
}
?>

View File

@ -18,6 +18,8 @@ class FeaturedTest extends ShimmieWebTestCase {
# after deletion, there should be no feature
$this->get_page("post/list");
$this->assertNoText("Featured Image");
# FIXME: test changing from one feature to another
}
}
?>

View File

@ -9,6 +9,9 @@ class IcoHandlerTest extends ShimmieWebTestCase {
$this->log_in_as_admin();
$this->delete_image($image_id);
$this->log_out();
# FIXME: test that the thumb works
# FIXME: test that it gets displayed properly
}
}
?>

View File

@ -26,6 +26,9 @@ class SVGHandlerTest extends ShimmieWebTestCase {
$this->log_out();
unlink("test.svg");
# FIXME: test that the thumb works
# FIXME: test that it gets displayed properly
}
}
?>

View File

@ -4,6 +4,8 @@ class HomeTest extends ShimmieWebTestCase {
$this->get_page('home');
$this->assertTitle('Shimmie');
$this->assertText('Shimmie');
# FIXME: test search box
}
}
?>

View File

@ -1,23 +0,0 @@
<?php
class ImageHashBanTest extends ShimmieWebTestCase {}
if(!defined(VERSION)) return;
class ImageHashBanUnitTest extends UnitTestCase {
public function _broken_testUploadFailsWhenBanned() {
$ihb = new ImageHashBan();
$due = new DataUploadEvent();
try {
$ihb->receive_event($due);
$this->assertTrue(false); // shouldn't work
}
catch(DataUploadException $ex) {
$this->assertTrue(true); // should fail
}
catch(Exception $ex) {
$this->assertTrue(false); // but not with any other error
}
}
}
?>

View File

@ -19,6 +19,8 @@ class IPBanTest extends ShimmieWebTestCase {
$this->assertNoText("42.42.42.42");
$this->log_out();
# FIXME: test that the IP is actually banned
}
}
?>

View File

@ -0,0 +1,22 @@
<?php
class LinkImageTest extends ShimmieWebTestCase {
function testLinkImage() {
$this->log_in_as_user();
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pie");
# look in the "plain text link to post" box, follow the link
# in there, see if it takes us to the right page
$raw = $this->get_page("post/view/$image_id");
$matches = preg_match("/name='text_post-link'\s+value='([^']+)'/", $raw);
$this->assertTrue(count($matches) > 0);
$this->get($matches[1]);
$this->assertTitle("Image $image_id: pie");
$this->log_out();
$this->log_in_as_admin();
$this->delete_image($image_id);
$this->log_out();
}
}
?>

View File

@ -0,0 +1,21 @@
<?php
class NumericScoreTest extends ShimmieWebTestCase {
function testNumericScore() {
$this->log_in_as_user();
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
$this->get_page("post/view/$image_id");
$this->assertText("Current Score: 0");
$this->click("Vote Down");
$this->assertText("Current Score: -1");
$this->click("Vote Up");
$this->assertText("Current Score: 1");
# FIXME: "remove vote" button?
# FIXME: test that up and down are hidden if already voted up or down
$this->log_out();
$this->log_in_as_admin();
$this->delete_image($image_id);
$this->log_out();
}
}
?>

View File

@ -0,0 +1,19 @@
<?php
class RandomTest extends ShimmieWebTestCase {
function testRandom() {
$this->log_in_as_user();
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "test");
$this->log_out();
$this->get_page("random_image/view");
$this->assertTitle("Image $image_id: test");
$this->log_in_as_admin();
$this->delete_image($image_id);
$this->log_out();
# FIXME: test random_image/download
# FIXME: test random_image/ratio=4:3/download
}
}
?>

View File

@ -0,0 +1,15 @@
<?php
class RegenThumbTest extends ShimmieWebTestCase {
function testRegenThumb() {
$this->log_in_as_admin();
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
$this->get_page("post/view/$image_id");
$this->click("Regenerate");
$this->assertTitle("Thumbnail Regenerated");
$this->delete_image($image_id);
$this->log_out();
# FIXME: test that the thumb's modified time has been updated
}
}
?>

View File

@ -18,6 +18,9 @@ class ReportImageTest extends ShimmieWebTestCase {
$this->delete_image($image_id);
$this->log_out();
# FIXME: test delete image from report screen
# FIXME: test that >>123 works
}
}
?>

View File

@ -4,6 +4,8 @@ class RSSCommentsTest extends ShimmieWebTestCase {
$this->get_page('rss/comments');
$this->assertMime("application/rss+xml");
$this->assertNoText("Exception");
# FIXME: test that there are some comments here
}
}
?>

View File

@ -27,7 +27,7 @@ class SCoreWebTestCase extends WebTestCase {
}
protected function log_in_as_user() {
$this->get_page('post/list');
$this->get_page('user_admin/login');
$this->assertText("Login");
$this->setField('user', USER_NAME);
$this->setField('pass', USER_PASS);
@ -35,7 +35,7 @@ class SCoreWebTestCase extends WebTestCase {
}
protected function log_in_as_admin() {
$this->get_page('post/list');
$this->get_page('user_admin/login');
$this->assertText("Login");
$this->setField('user', ADMIN_NAME);
$this->setField('pass', ADMIN_PASS);
@ -96,6 +96,8 @@ class SimpleSCoreTest extends SimpleExtension {
public function onPageRequest($event) {
global $page;
if($event->page_matches("test")) {
set_time_limit(0);
$page->set_title("Test Results");
$page->set_heading("Test Results");
$page->add_block(new NavBlock());

View File

@ -5,7 +5,7 @@ class SiteDescriptionTest extends ShimmieWebTestCase {
$this->get_page('setup');
$this->assertTitle("Shimmie Setup");
$this->setField("_config_site_description", "A Shimmie testbed");
$this->click("Save Settings")
$this->click("Save Settings");
$raw_headers = $this->getBrowser()->getHeaders();
$header = '<meta name="description" content="A Shimmie testbed">';

View File

@ -5,6 +5,8 @@ class WikiTest extends ShimmieWebTestCase {
$this->get_page("wiki");
$this->assertTitle("Index");
$this->log_out();
# FIXME: needs a ton of tests...
}
}
?>

11
contrib/zoom/test.php Normal file
View File

@ -0,0 +1,11 @@
<?php
class ZoomTest extends ShimmieWebTestCase {
function testZoom() {
$this->log_in_as_admin();
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
$this->get("post/view/$image_id"); # just check that the page isn't borked
$this->delete_image($image_id);
$this->log_out();
}
}
?>

View File

@ -9,6 +9,7 @@ class ZoomTheme extends Themelet {
global $config;
$default = $zoom_by_default ? "scale(img);" : "";
return <<<EOD
<!-- rrcontent -->
<script type="text/javascript">
img = document.getElementById("main_image");

View File

@ -15,6 +15,8 @@ class AdminPageTest extends ShimmieWebTestCase {
$this->get_page('admin');
$this->assertTitle("Admin Tools");
$this->log_out();
# FIXME: make sure the admin tools actually work
}
}
?>

View File

@ -1,4 +1,5 @@
<?php
# FIXME: web test
class BBCodeTest extends ShimmieWebTestCase {}
if(!defined(VERSION)) return;

View File

@ -46,6 +46,8 @@ class CommentListTest extends ShimmieWebTestCase {
$this->log_in_as_admin();
$this->delete_image($image_id);
$this->log_out();
# FIXME: test deleting one comment at a time
}
}
?>

View File

@ -16,6 +16,8 @@ class ExtManagerTest extends ShimmieWebTestCase {
$this->assertTitle("Extensions");
$this->assertText("SimpleTest integration");
$this->log_out();
# FIXME: test that some extensions can be added and removed? :S
}
}
?>

View File

@ -9,6 +9,9 @@ class PixelHandlerTest extends ShimmieWebTestCase {
$this->log_in_as_admin();
$this->delete_image($image_id);
$this->log_out();
# FIXME: test that the thumb works
# FIXME: test that it gets displayed properly
}
}
?>

View File

@ -28,6 +28,8 @@ class IndexTest extends ShimmieWebTestCase {
$this->log_in_as_admin();
$this->delete_image($image_id);
$this->log_out();
# FIXME: test search box
}
function testSearches() {

View File

@ -79,11 +79,11 @@ EOD;
$h_search_string = html_escape(implode(" ", $search_terms));
$h_search_link = make_link();
$h_search = "
<script>
<script><!--
$(document).ready(function() {
$(\"#search_input\").DefaultValue(\"Search\");
});
</script>
//--></script>
<p><form action='$h_search_link' method='GET'>
<input id='search_input' name='search' type='text'
value='$h_search_string' autocomplete='off' />

View File

@ -8,11 +8,16 @@ class TagEditTest extends ShimmieWebTestCase {
$this->setField("tag_edit__tags", "new");
$this->click("Set");
$this->assertTitle("Image $image_id: new");
$this->setField("tag_edit__tags", "");
$this->click("Set");
$this->assertTitle("Image $image_id: tagme");
$this->log_out();
$this->log_in_as_admin();
$this->delete_image($image_id);
$this->log_out();
# FIXME: test mass tag editor
}
}
?>

View File

@ -12,6 +12,8 @@ class TagListTest extends ShimmieWebTestCase {
$this->get_page('tags/categories');
$this->assertTitle('Tag List');
# FIXME: test that these show the right stuff
}
}
?>

View File

@ -2,7 +2,7 @@
class UserPageTest extends ShimmieWebTestCase {
function testUserPage() {
$this->get_page('user');
$this->assertTitle("Anonymous's Page");
$this->assertTitle("Not Logged In");
$this->assertNoText("Options");
$this->assertNoText("More Options");
@ -25,6 +25,10 @@ class UserPageTest extends ShimmieWebTestCase {
$this->assertText("Options");
$this->assertText("More Options");
$this->log_out();
# FIXME: test user creation
# FIXME: test adminifying
# FIXME: test password reset
}
}
?>