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/index/test.php

95 lines
3 KiB
PHP
Raw Normal View History

<?php
class IndexTest extends ShimmieWebTestCase {
function testIndexPage() {
2009-07-15 16:09:50 +00:00
$this->get_page('post/list');
2009-08-19 00:28:48 +00:00
$this->assert_title("Welcome to Shimmie ".VERSION);
$this->assert_no_text("Prev | Index | Next");
2009-07-15 16:09:50 +00:00
$this->log_in_as_user();
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
$this->log_out();
$this->get_page('post/list');
2009-08-19 00:28:48 +00:00
$this->assert_title("Shimmie");
$this->assert_text("Prev | Index | Next");
$this->get_page('post/list/-1');
2009-08-19 00:28:48 +00:00
$this->assert_title("Shimmie");
$this->get_page('post/list/0');
2009-08-19 00:28:48 +00:00
$this->assert_title("Shimmie");
$this->get_page('post/list/1');
2009-08-19 00:28:48 +00:00
$this->assert_title("Shimmie");
$this->get_page('post/list/99999');
2009-08-19 00:28:48 +00:00
$this->assert_title("Shimmie");
$this->log_in_as_admin();
$this->delete_image($image_id);
$this->log_out();
2009-07-20 05:51:36 +00:00
# FIXME: test search box
}
function testSearches() {
$this->log_in_as_user();
$image_id_1 = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
$image_id_2 = $this->post_image("ext/simpletest/data/bedroom_workshop.jpg", "computer bedroom workshop");
$this->log_out();
# make sure both uploads were ok
$this->assertTrue($image_id_1 > 0);
$this->assertTrue($image_id_2 > 0);
# regular tag, no results
$this->get_page('post/list/maumaumau/1');
2009-08-19 00:28:48 +00:00
$this->assert_title("maumaumau");
$this->assert_text("No Images Found");
# regular tag, many results
$this->get_page('post/list/computer/1');
2009-08-19 00:28:48 +00:00
$this->assert_title("computer");
$this->assert_no_text("No Images Found");
# meta tag, many results
$this->get_page('post/list/size=640x480/1');
2009-08-19 00:28:48 +00:00
$this->assert_title("size=640x480");
$this->assert_no_text("No Images Found");
2009-07-19 16:39:07 +00:00
# meta tag, one result
$this->get_page("post/list/hash=feb01bab5698a11dd87416724c7a89e3/1");
2009-08-19 00:28:48 +00:00
$this->assert_title(new PatternExpectation("/^Image $image_id_1: /"));
$this->assert_no_text("No Images Found");
2009-07-19 16:39:07 +00:00
2009-08-02 07:59:19 +00:00
# meta tag, one result
$this->get_page("post/list/md5=feb01bab5698a11dd87416724c7a89e3/1");
2009-08-19 00:28:48 +00:00
$this->assert_title(new PatternExpectation("/^Image $image_id_1: /"));
$this->assert_no_text("No Images Found");
2009-08-02 07:59:19 +00:00
# multiple tags, many results
$this->get_page('post/list/computer%20size=640x480/1');
2009-08-19 00:28:48 +00:00
$this->assert_title("computer size=640x480");
$this->assert_no_text("No Images Found");
# multiple tags, single result; search with one result = direct to image
$this->get_page('post/list/screenshot%20computer/1');
2009-08-19 00:28:48 +00:00
$this->assert_title(new PatternExpectation("/^Image $image_id_1: /"));
# negative tag, should have one result
$this->get_page('post/list/computer%20-pbx/1');
2009-08-19 00:28:48 +00:00
$this->assert_title(new PatternExpectation("/^Image $image_id_2: /"));
2009-07-16 19:20:53 +00:00
# negative tag alone, should work
# FIXME: known broken in mysql
//$this->get_page('post/list/-pbx/1');
2009-08-19 00:28:48 +00:00
//$this->assert_title(new PatternExpectation("/^Image $image_id_2: /"));
2009-07-16 19:20:53 +00:00
$this->log_in_as_admin();
$this->delete_image($image_id_1);
$this->delete_image($image_id_2);
$this->log_out();
}
}
?>