A ton of tests, figured out how to test uploads \o/
This commit is contained in:
parent
8dac266af4
commit
c88ecebb7b
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
class HomeTest extends WebTestCase {
|
class HomeTest extends ShimmieWebTestCase {
|
||||||
function testHomePage() {
|
function testHomePage() {
|
||||||
$this->get(TEST_BASE.'/home');
|
$this->get_page('home');
|
||||||
$this->assertTitle('Shimmie Testbed');
|
$this->assertTitle('Shimmie');
|
||||||
$this->assertText('Shimmie Testbed');
|
$this->assertText('Shimmie');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
class ImageHashBanTest extends WebTestCase {}
|
class ImageHashBanTest extends ShimmieWebTestCase {}
|
||||||
|
|
||||||
if(!defined(VERSION)) return;
|
if(!defined(VERSION)) return;
|
||||||
|
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
class IPBanTest extends WebTestCase {
|
class IPBanTest extends ShimmieWebTestCase {
|
||||||
function testIPBan() {
|
function testIPBan() {
|
||||||
$this->get(TEST_BASE.'/ip_ban/list');
|
$this->get_page('ip_ban/list');
|
||||||
$this->assertResponse(403);
|
$this->assertResponse(403);
|
||||||
$this->assertTitle("Permission Denied");
|
$this->assertTitle("Permission Denied");
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/user');
|
$this->log_in_as_admin();
|
||||||
$this->assertText("Login");
|
|
||||||
$this->setField('user', ADMIN_NAME);
|
|
||||||
$this->setField('pass', ADMIN_PASS);
|
|
||||||
$this->click("Log In");
|
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/ip_ban/list');
|
$this->get_page('ip_ban/list');
|
||||||
$this->assertNoText("42.42.42.42");
|
$this->assertNoText("42.42.42.42");
|
||||||
$this->setField('ip', '42.42.42.42');
|
$this->setField('ip', '42.42.42.42');
|
||||||
$this->setField('reason', 'unit testing');
|
$this->setField('reason', 'unit testing');
|
||||||
@ -22,7 +18,7 @@ class IPBanTest extends WebTestCase {
|
|||||||
$this->click("Remove"); // FIXME: remove which ban? :S
|
$this->click("Remove"); // FIXME: remove which ban? :S
|
||||||
$this->assertNoText("42.42.42.42");
|
$this->assertNoText("42.42.42.42");
|
||||||
|
|
||||||
$this->click('Log Out');
|
$this->log_out();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
class RSSCommentsTest extends WebTestCase {
|
class RSSCommentsTest extends ShimmieWebTestCase {
|
||||||
function testImageFeed() {
|
function testImageFeed() {
|
||||||
$this->get(TEST_BASE.'/rss/comments');
|
$this->get_page('rss/comments');
|
||||||
$this->assertMime("application/rss+xml");
|
$this->assertMime("application/rss+xml");
|
||||||
$this->assertNoText("Exception");
|
$this->assertNoText("Exception");
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
class RSSImagesTest extends WebTestCase {
|
class RSSImagesTest extends ShimmieWebTestCase {
|
||||||
function testImageFeed() {
|
function testImageFeed() {
|
||||||
$this->get(TEST_BASE.'/rss/images');
|
$this->log_in_as_user();
|
||||||
|
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||||
|
$this->log_out();
|
||||||
|
|
||||||
|
$this->assertTitle("Upload Status");
|
||||||
|
$this->assertText("already has hash");
|
||||||
|
|
||||||
|
$this->get_page('rss/images');
|
||||||
$this->assertMime("application/rss+xml");
|
$this->assertMime("application/rss+xml");
|
||||||
$this->assertNoText("Exception");
|
$this->assertNoText("Exception");
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/rss/images/1');
|
$this->get_page('rss/images/1');
|
||||||
$this->assertMime("application/rss+xml");
|
$this->assertMime("application/rss+xml");
|
||||||
$this->assertNoText("Exception");
|
$this->assertNoText("Exception");
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/rss/images/tagme/1');
|
$this->get_page('rss/images/tagme/1');
|
||||||
$this->assertMime("application/rss+xml");
|
$this->assertMime("application/rss+xml");
|
||||||
$this->assertNoText("Exception");
|
$this->assertNoText("Exception");
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/rss/images/tagme/2');
|
$this->get_page('rss/images/tagme/2');
|
||||||
$this->assertMime("application/rss+xml");
|
$this->assertMime("application/rss+xml");
|
||||||
$this->assertNoText("Exception");
|
$this->assertNoText("Exception");
|
||||||
|
|
||||||
|
$this->log_in_as_admin();
|
||||||
|
$this->delete_image($image_id);
|
||||||
|
$this->log_out();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
BIN
contrib/simpletest/data/bedroom_workshop.jpg
Normal file
BIN
contrib/simpletest/data/bedroom_workshop.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
BIN
contrib/simpletest/data/pbx_screenshot.jpg
Normal file
BIN
contrib/simpletest/data/pbx_screenshot.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
@ -10,6 +10,68 @@ require_once('simpletest/web_tester.php');
|
|||||||
require_once('simpletest/unit_tester.php');
|
require_once('simpletest/unit_tester.php');
|
||||||
require_once('simpletest/reporter.php');
|
require_once('simpletest/reporter.php');
|
||||||
|
|
||||||
|
define('TEST_BASE', "http://shimmie.shishnet.org/branch_2.3/index.php?q=");
|
||||||
|
define('USER_NAME', "test");
|
||||||
|
define('USER_PASS', "test");
|
||||||
|
define('ADMIN_NAME', "demo");
|
||||||
|
define('ADMIN_PASS', "demo");
|
||||||
|
|
||||||
|
class ShimmieWebTestCase extends WebTestCase {
|
||||||
|
protected function get_page($page) {
|
||||||
|
$this->get(TEST_BASE.'/'.$page);
|
||||||
|
}
|
||||||
|
protected function log_in_as_user() {
|
||||||
|
$this->get_page('post/list');
|
||||||
|
$this->assertText("Login");
|
||||||
|
$this->setField('user', USER_NAME);
|
||||||
|
$this->setField('pass', USER_PASS);
|
||||||
|
$this->click("Log In");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function log_in_as_admin() {
|
||||||
|
$this->get_page('post/list');
|
||||||
|
$this->assertText("Login");
|
||||||
|
$this->setField('user', ADMIN_NAME);
|
||||||
|
$this->setField('pass', ADMIN_PASS);
|
||||||
|
$this->click("Log In");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function log_out() {
|
||||||
|
$this->get_page('post/list');
|
||||||
|
$this->click('Log Out');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function post_image($filename, $tags) {
|
||||||
|
$image_id = -1;
|
||||||
|
$this->setMaximumRedirects(0);
|
||||||
|
|
||||||
|
$this->get_page('post/list');
|
||||||
|
$this->assertText("Upload");
|
||||||
|
$this->setField("data0", $filename);
|
||||||
|
$this->setField("tags", $tags);
|
||||||
|
$this->click("Post");
|
||||||
|
|
||||||
|
$raw_headers = $this->getBrowser()->getHeaders();
|
||||||
|
$headers = explode("\n", $raw_headers);
|
||||||
|
foreach($headers as $header) {
|
||||||
|
$parts = explode(":", $header);
|
||||||
|
if(trim($parts[0]) == "X-Shimmie-Image-ID") {
|
||||||
|
$image_id = int_escape(trim($parts[1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setMaximumRedirects(5);
|
||||||
|
return $image_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function delete_image($image_id) {
|
||||||
|
if($image_id > 0) {
|
||||||
|
$this->get_page('post/view/'.$image_id);
|
||||||
|
$this->click("Delete");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class TestFinder extends TestSuite {
|
class TestFinder extends TestSuite {
|
||||||
function TestFinder($hint) {
|
function TestFinder($hint) {
|
||||||
$dir = "*";
|
$dir = "*";
|
||||||
|
@ -4,7 +4,7 @@ class SimpleSCoreTestTheme extends Themelet {
|
|||||||
|
|
||||||
class SCoreReporter extends HtmlReporter {
|
class SCoreReporter extends HtmlReporter {
|
||||||
var $current_html = "";
|
var $current_html = "";
|
||||||
var $clear_modules = "";
|
var $clear_modules = array();
|
||||||
var $page;
|
var $page;
|
||||||
|
|
||||||
public function SCoreReporter(Page $page) {
|
public function SCoreReporter(Page $page) {
|
||||||
@ -19,8 +19,7 @@ class SCoreReporter extends HtmlReporter {
|
|||||||
|
|
||||||
function paintFooter($test_name) {
|
function paintFooter($test_name) {
|
||||||
//parent::paintFooter($test_name);
|
//parent::paintFooter($test_name);
|
||||||
$fail = $this->getFailCount() > 0;
|
if($this->getFailCount() > 0) {
|
||||||
if($fail) {
|
|
||||||
$style = "background: red;";
|
$style = "background: red;";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -29,7 +28,7 @@ class SCoreReporter extends HtmlReporter {
|
|||||||
$html = "<div style=\"padding: 4px; $style\">".
|
$html = "<div style=\"padding: 4px; $style\">".
|
||||||
$this->getPassCount() . " passes, " .
|
$this->getPassCount() . " passes, " .
|
||||||
$this->getFailCount() . " failures" .
|
$this->getFailCount() . " failures" .
|
||||||
"<br>Passed modules: " . $this->clear_modules .
|
"<br>Passed modules: " . implode(", ", $this->clear_modules) .
|
||||||
"</div>";
|
"</div>";
|
||||||
$this->page->add_block(new Block("Results", $html, "main", 40));
|
$this->page->add_block(new Block("Results", $html, "main", 40));
|
||||||
}
|
}
|
||||||
@ -47,7 +46,7 @@ class SCoreReporter extends HtmlReporter {
|
|||||||
}
|
}
|
||||||
parent::paintGroupEnd($name);
|
parent::paintGroupEnd($name);
|
||||||
if($this->current_html == "") {
|
if($this->current_html == "") {
|
||||||
$this->clear_modules .= "$name, ";
|
$this->clear_modules[] = $name;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->current_html .= "<p>$link";
|
$this->current_html .= "<p>$link";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
class WordFiterTest extends WebTestCase {}
|
class WordFiterTest extends ShimmieWebTestCase {}
|
||||||
|
|
||||||
if(!defined(VERSION)) return;
|
if(!defined(VERSION)) return;
|
||||||
|
|
||||||
|
@ -1,26 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
class AdminPageTest extends WebTestCase {
|
class AdminPageTest extends ShimmieWebTestCase {
|
||||||
function testAuth() {
|
function testAuth() {
|
||||||
$this->get(TEST_BASE.'/admin');
|
$this->get_page('admin');
|
||||||
$this->assertResponse(403);
|
$this->assertResponse(403);
|
||||||
$this->assertTitle("Permission Denied");
|
$this->assertTitle("Permission Denied");
|
||||||
|
|
||||||
$this->assertText("Login");
|
$this->log_in_as_user();
|
||||||
$this->setField('user', USER_NAME);
|
$this->get_page('admin');
|
||||||
$this->setField('pass', USER_PASS);
|
|
||||||
$this->click("Log In");
|
|
||||||
$this->get(TEST_BASE.'/admin');
|
|
||||||
$this->assertResponse(403);
|
$this->assertResponse(403);
|
||||||
$this->assertTitle("Permission Denied");
|
$this->assertTitle("Permission Denied");
|
||||||
$this->click('Log Out');
|
$this->log_out();
|
||||||
|
|
||||||
$this->assertText("Login");
|
$this->log_in_as_admin();
|
||||||
$this->setField('user', ADMIN_NAME);
|
$this->get_page('admin');
|
||||||
$this->setField('pass', ADMIN_PASS);
|
|
||||||
$this->click("Log In");
|
|
||||||
$this->get(TEST_BASE.'/admin');
|
|
||||||
$this->assertTitle("Admin Tools");
|
$this->assertTitle("Admin Tools");
|
||||||
$this->click('Log Out');
|
$this->log_out();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,28 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
class AliasEditorTest extends WebTestCase {
|
class AliasEditorTest extends ShimmieWebTestCase {
|
||||||
function testAliasEditor() {
|
function testAliasEditor() {
|
||||||
/*
|
$this->get_page('alias/list');
|
||||||
$this->get(TEST_BASE.'/admin');
|
$this->assertTitle("Alias List");
|
||||||
$this->assertResponse(403);
|
|
||||||
$this->assertTitle("Permission Denied");
|
|
||||||
|
|
||||||
$this->assertText("Login");
|
$this->log_in_as_admin();
|
||||||
$this->setField('user', USER_NAME);
|
$this->get_page('alias/list');
|
||||||
$this->setField('pass', USER_PASS);
|
$this->assertTitle("Alias List");
|
||||||
$this->click("Log In");
|
$this->log_out();
|
||||||
$this->get(TEST_BASE.'/admin');
|
|
||||||
$this->assertResponse(403);
|
|
||||||
$this->assertTitle("Permission Denied");
|
|
||||||
$this->click('Log Out');
|
|
||||||
|
|
||||||
$this->assertText("Login");
|
|
||||||
$this->setField('user', ADMIN_NAME);
|
|
||||||
$this->setField('pass', ADMIN_PASS);
|
|
||||||
$this->click("Log In");
|
|
||||||
$this->get(TEST_BASE.'/admin');
|
|
||||||
$this->assertTitle("Admin Tools");
|
|
||||||
$this->click('Log Out');
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
class BBCodeTest extends WebTestCase {}
|
class BBCodeTest extends ShimmieWebTestCase {}
|
||||||
|
|
||||||
if(!defined(VERSION)) return;
|
if(!defined(VERSION)) return;
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
class CommentListTest extends WebTestCase {
|
class CommentListTest extends ShimmieWebTestCase {
|
||||||
function testCommentsPage() {
|
function testCommentsPage() {
|
||||||
$this->get(TEST_BASE.'/comment/list');
|
$this->get_page('comment/list');
|
||||||
$this->assertTitle('Comments');
|
$this->assertTitle('Comments');
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/comment/list/2');
|
$this->get_page('comment/list/2');
|
||||||
$this->assertTitle('Comments');
|
$this->assertTitle('Comments');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
class ExtManagerTest extends WebTestCase {
|
class ExtManagerTest extends ShimmieWebTestCase {
|
||||||
function testAuth() {
|
function testAuth() {
|
||||||
$this->get(TEST_BASE.'/ext_manager');
|
$this->get_page('ext_manager');
|
||||||
$this->assertResponse(403);
|
$this->assertResponse(403);
|
||||||
$this->assertTitle("Permission Denied");
|
$this->assertTitle("Permission Denied");
|
||||||
|
|
||||||
$this->assertText("Login");
|
$this->log_in_as_user();
|
||||||
$this->setField('user', USER_NAME);
|
$this->get_page('ext_manager');
|
||||||
$this->setField('pass', USER_PASS);
|
|
||||||
$this->click("Log In");
|
|
||||||
$this->get(TEST_BASE.'/ext_manager');
|
|
||||||
$this->assertResponse(403);
|
$this->assertResponse(403);
|
||||||
$this->assertTitle("Permission Denied");
|
$this->assertTitle("Permission Denied");
|
||||||
$this->click('Log Out');
|
$this->log_out();
|
||||||
|
|
||||||
$this->assertText("Login");
|
$this->log_in_as_admin();
|
||||||
$this->setField('user', ADMIN_NAME);
|
$this->get_page('ext_manager');
|
||||||
$this->setField('pass', ADMIN_PASS);
|
|
||||||
$this->click("Log In");
|
|
||||||
$this->get(TEST_BASE.'/ext_manager');
|
|
||||||
$this->assertTitle("Extensions");
|
$this->assertTitle("Extensions");
|
||||||
$this->assertText("SimpleTest integration");
|
$this->assertText("SimpleTest integration");
|
||||||
$this->click('Log Out');
|
$this->log_out();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
class Handle404Test extends WebTestCase {
|
class Handle404Test extends ShimmieWebTestCase {
|
||||||
function test404Handler() {
|
function test404Handler() {
|
||||||
$this->get(TEST_BASE.'/not/a/page');
|
$this->get_page('not/a/page');
|
||||||
$this->assertResponse(404);
|
$this->assertResponse(404);
|
||||||
$this->assertTitle('404');
|
$this->assertTitle('404');
|
||||||
$this->assertText("No handler could be found for the page 'not/a/page'");
|
$this->assertText("No handler could be found for the page 'not/a/page'");
|
||||||
|
@ -24,6 +24,7 @@ class PixelFileHandler implements Extension {
|
|||||||
|
|
||||||
$iae = new ImageAdditionEvent($event->user, $image);
|
$iae = new ImageAdditionEvent($event->user, $image);
|
||||||
send_event($iae); // this might raise an exception, but all we'd do is re-throw it...
|
send_event($iae); // this might raise an exception, but all we'd do is re-throw it...
|
||||||
|
$event->image_id = $iae->image->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($event instanceof ThumbnailGenerationEvent) && $this->supported_ext($event->type)) {
|
if(($event instanceof ThumbnailGenerationEvent) && $this->supported_ext($event->type)) {
|
||||||
|
@ -15,6 +15,13 @@ class ImageAdditionEvent extends Event {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ImageAdditionException extends SCoreException {
|
||||||
|
var $error;
|
||||||
|
|
||||||
|
public function __construct($error) {
|
||||||
|
$this->error = $error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ImageDeletionEvent:
|
* ImageDeletionEvent:
|
||||||
@ -104,8 +111,12 @@ class ImageIO extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onImageAddition($event) {
|
public function onImageAddition($event) {
|
||||||
$error = $this->add_image($event->image);
|
try {
|
||||||
if(!empty($error)) throw new UploadException($error);
|
$this->add_image($event->image);
|
||||||
|
}
|
||||||
|
catch(ImageAdditionException $e) {
|
||||||
|
throw new UploadException($e->error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onImageDeletion($event) {
|
public function onImageDeletion($event) {
|
||||||
@ -158,8 +169,7 @@ class ImageIO extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
if(!empty($image->source)) {
|
if(!empty($image->source)) {
|
||||||
if(!preg_match("#^(https?|ftp)://#", $image->source)) {
|
if(!preg_match("#^(https?|ftp)://#", $image->source)) {
|
||||||
$error = "Image's source isn't a valid URL";
|
throw new ImageAdditionException("Image's source isn't a valid URL");
|
||||||
return $error;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +187,7 @@ class ImageIO extends SimpleExtension {
|
|||||||
else {
|
else {
|
||||||
$error = "Image <a href='".make_link("post/view/{$existing->id}")."'>{$existing->id}</a> ".
|
$error = "Image <a href='".make_link("post/view/{$existing->id}")."'>{$existing->id}</a> ".
|
||||||
"already has hash {$image->hash}:<p>".Themelet::build_thumb_html($existing);
|
"already has hash {$image->hash}:<p>".Themelet::build_thumb_html($existing);
|
||||||
return $error;
|
throw new ImageAdditionException($error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,8 +204,6 @@ class ImageIO extends SimpleExtension {
|
|||||||
log_info("image", "Uploaded Image #{$image->id} ({$image->hash})");
|
log_info("image", "Uploaded Image #{$image->id} ({$image->hash})");
|
||||||
|
|
||||||
send_event(new TagSetEvent($image, $image->get_tag_array()));
|
send_event(new TagSetEvent($image, $image->get_tag_array()));
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
// fetch image {{{
|
// fetch image {{{
|
||||||
|
@ -1,42 +1,70 @@
|
|||||||
<?php
|
<?php
|
||||||
class IndexTest extends WebTestCase {
|
class IndexTest extends ShimmieWebTestCase {
|
||||||
function testIndexPage() {
|
function testIndexPage() {
|
||||||
$this->get(TEST_BASE.'/post/list');
|
$this->log_in_as_user();
|
||||||
$this->assertTitle("Shimmie Testbed");
|
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||||
|
$this->log_out();
|
||||||
|
|
||||||
|
$this->get_page('post/list');
|
||||||
|
$this->assertTitle("Shimmie");
|
||||||
$this->assertText("Prev | Index | Next");
|
$this->assertText("Prev | Index | Next");
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/post/list/-1');
|
$this->get_page('post/list/-1');
|
||||||
$this->assertTitle("Shimmie Testbed");
|
$this->assertTitle("Shimmie");
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/post/list/0');
|
$this->get_page('post/list/0');
|
||||||
$this->assertTitle("Shimmie Testbed");
|
$this->assertTitle("Shimmie");
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/post/list/1');
|
$this->get_page('post/list/1');
|
||||||
$this->assertTitle("Shimmie Testbed");
|
$this->assertTitle("Shimmie");
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/post/list/99999');
|
$this->get_page('post/list/99999');
|
||||||
$this->assertTitle("Shimmie Testbed");
|
$this->assertTitle("Shimmie");
|
||||||
|
|
||||||
|
$this->log_in_as_admin();
|
||||||
|
$this->delete_image($image_id);
|
||||||
|
$this->log_out();
|
||||||
}
|
}
|
||||||
|
|
||||||
function testSearches() {
|
function testSearches() {
|
||||||
$this->get(TEST_BASE.'/post/list/maumaumau/1');
|
$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');
|
||||||
$this->assertTitle("maumaumau");
|
$this->assertTitle("maumaumau");
|
||||||
$this->assertText("No Images Found");
|
$this->assertText("No Images Found");
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/post/list/screenshot/1');
|
# regular tag, many results
|
||||||
$this->assertTitle("screenshot");
|
$this->get_page('post/list/computer/1');
|
||||||
|
$this->assertTitle("computer");
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/post/list/size=1024x768/1');
|
# meta tag, many results
|
||||||
$this->assertTitle("size=1024x768");
|
$this->get_page('post/list/size=640x480/1');
|
||||||
|
$this->assertTitle("size=640x480");
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/post/list/screenshot%20size=1024x768/1');
|
# multiple tags, many results
|
||||||
$this->assertTitle("screenshot size=1024x768");
|
$this->get_page('post/list/computer%20size=640x480/1');
|
||||||
|
$this->assertTitle("computer size=640x480");
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/post/list/screenshot%20computer/1');
|
# multiple tags, single result; search with one result = direct to image
|
||||||
$this->assertTitle("screenshot computer");
|
$this->get_page('post/list/screenshot%20computer/1');
|
||||||
|
$this->assertTitle(new PatternExpectation("/^Image $image_id_1: /"));
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/post/list/screenshot%20computer%20-pbx/1');
|
# negative tag, should have one result
|
||||||
$this->assertTitle("screenshot computer -pbx");
|
$this->get_page('post/list/computer%20-pbx/1');
|
||||||
|
$this->assertTitle(new PatternExpectation("/^Image $image_id_2: /"));
|
||||||
|
|
||||||
|
$this->log_in_as_admin();
|
||||||
|
$this->delete_image($image_id_1);
|
||||||
|
$this->delete_image($image_id_2);
|
||||||
|
$this->log_out();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,27 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
class SetupTest extends WebTestCase {
|
class SetupTest extends ShimmieWebTestCase {
|
||||||
function testAuth() {
|
function testAuth() {
|
||||||
$this->get(TEST_BASE.'/setup');
|
$this->get_page('setup');
|
||||||
$this->assertResponse(403);
|
$this->assertResponse(403);
|
||||||
$this->assertTitle("Permission Denied");
|
$this->assertTitle("Permission Denied");
|
||||||
|
|
||||||
$this->assertText("Login");
|
$this->log_in_as_user();
|
||||||
$this->setField('user', USER_NAME);
|
$this->get_page('setup');
|
||||||
$this->setField('pass', USER_PASS);
|
|
||||||
$this->click("Log In");
|
|
||||||
$this->get(TEST_BASE.'/setup');
|
|
||||||
$this->assertResponse(403);
|
$this->assertResponse(403);
|
||||||
$this->assertTitle("Permission Denied");
|
$this->assertTitle("Permission Denied");
|
||||||
$this->click('Log Out');
|
$this->log_out();
|
||||||
|
|
||||||
$this->assertText("Login");
|
$this->log_in_as_admin();
|
||||||
$this->setField('user', ADMIN_NAME);
|
$this->get_page('setup');
|
||||||
$this->setField('pass', ADMIN_PASS);
|
|
||||||
$this->click("Log In");
|
|
||||||
$this->get(TEST_BASE.'/setup');
|
|
||||||
$this->assertTitle("Shimmie Setup");
|
$this->assertTitle("Shimmie Setup");
|
||||||
$this->assertText("General");
|
$this->assertText("General");
|
||||||
$this->click('Log Out');
|
$this->log_out();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
class TagListTest extends WebTestCase {
|
class TagListTest extends ShimmieWebTestCase {
|
||||||
function testTagList() {
|
function testTagList() {
|
||||||
$this->get(TEST_BASE.'/tags/map');
|
$this->get_page('tags/map');
|
||||||
$this->assertTitle('Tag List');
|
$this->assertTitle('Tag List');
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/tags/alphabetic');
|
$this->get_page('tags/alphabetic');
|
||||||
$this->assertTitle('Tag List');
|
$this->assertTitle('Tag List');
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/tags/popularity');
|
$this->get_page('tags/popularity');
|
||||||
$this->assertTitle('Tag List');
|
$this->assertTitle('Tag List');
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/tags/categories');
|
$this->get_page('tags/categories');
|
||||||
$this->assertTitle('Tag List');
|
$this->assertTitle('Tag List');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Some data is being uploaded. Should be caught by a file handler.
|
* Some data is being uploaded. Should be caught by a file handler.
|
||||||
*/
|
*/
|
||||||
class DataUploadEvent extends Event {
|
class DataUploadEvent extends Event {
|
||||||
var $user, $tmpname, $metadata, $hash, $type;
|
var $user, $tmpname, $metadata, $hash, $type, $image_id = -1;
|
||||||
|
|
||||||
public function DataUploadEvent($user, $tmpname, $metadata) {
|
public function DataUploadEvent($user, $tmpname, $metadata) {
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
@ -150,6 +150,7 @@ class Upload implements Extension {
|
|||||||
$event = new DataUploadEvent($user, $file['tmp_name'], $metadata);
|
$event = new DataUploadEvent($user, $file['tmp_name'], $metadata);
|
||||||
try {
|
try {
|
||||||
send_event($event);
|
send_event($event);
|
||||||
|
header("X-Shimmie-Image-ID: ".int_escape($event->image_id));
|
||||||
}
|
}
|
||||||
catch(UploadException $ex) {
|
catch(UploadException $ex) {
|
||||||
$this->theme->display_upload_error($page, "Error with ".html_escape($file['name']),
|
$this->theme->display_upload_error($page, "Error with ".html_escape($file['name']),
|
||||||
|
21
ext/upload/test.php
Normal file
21
ext/upload/test.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
class UploadTest extends ShimmieWebTestCase {
|
||||||
|
function testUpload() {
|
||||||
|
$this->log_in_as_user();
|
||||||
|
|
||||||
|
$image_id_1 = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||||
|
$this->assertResponse(302);
|
||||||
|
|
||||||
|
$image_id_2 = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
|
||||||
|
$this->assertTitle("Upload Status");
|
||||||
|
$this->assertText("already has hash");
|
||||||
|
|
||||||
|
$this->log_out();
|
||||||
|
|
||||||
|
$this->log_in_as_admin();
|
||||||
|
$this->delete_image($image_id_1);
|
||||||
|
$this->delete_image($image_id_2);
|
||||||
|
$this->log_out();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -1,36 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
class UserPageTest extends WebTestCase {
|
class UserPageTest extends ShimmieWebTestCase {
|
||||||
function testUserPage() {
|
function testUserPage() {
|
||||||
$this->get(TEST_BASE.'/user');
|
$this->get_page('user');
|
||||||
$this->assertTitle("Anonymous's Page");
|
$this->assertTitle("Anonymous's Page");
|
||||||
$this->assertNoText("Options");
|
$this->assertNoText("Options");
|
||||||
$this->assertNoText("More Options");
|
$this->assertNoText("More Options");
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/user/Shish');
|
$this->get_page('user/demo');
|
||||||
$this->assertTitle("Shish's Page");
|
$this->assertTitle("demo's Page");
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/user/MauMau');
|
$this->get_page('user/MauMau');
|
||||||
$this->assertTitle("No Such User");
|
$this->assertTitle("No Such User");
|
||||||
|
|
||||||
$this->assertText("Login");
|
$this->log_in_as_user();
|
||||||
$this->setField('user', USER_NAME);
|
|
||||||
$this->setField('pass', USER_PASS);
|
|
||||||
$this->click("Log In");
|
|
||||||
// should be on the user page
|
// should be on the user page
|
||||||
$this->assertTitle("test's Page");
|
$this->assertTitle(USER_NAME+"'s Page");
|
||||||
$this->assertText("Options");
|
$this->assertText("Options");
|
||||||
$this->assertNoText("More Options");
|
$this->assertNoText("More Options");
|
||||||
$this->click('Log Out');
|
$this->log_out();
|
||||||
|
|
||||||
$this->assertText("Login");
|
$this->log_in_as_admin();
|
||||||
$this->setField('user', ADMIN_NAME);
|
|
||||||
$this->setField('pass', ADMIN_PASS);
|
|
||||||
$this->click("Log In");
|
|
||||||
// should be on the user page
|
// should be on the user page
|
||||||
$this->assertTitle(ADMIN_NAME+"'s Page");
|
$this->assertTitle(ADMIN_NAME+"'s Page");
|
||||||
$this->assertText("Options");
|
$this->assertText("Options");
|
||||||
$this->assertText("More Options");
|
$this->assertText("More Options");
|
||||||
$this->click('Log Out');
|
$this->log_out();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,14 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
class ViewTest extends WebTestCase {
|
class ViewTest extends ShimmieWebTestCase {
|
||||||
function testViewPage() {
|
function testViewPage() {
|
||||||
$this->get(TEST_BASE.'/post/view/1914');
|
$this->log_in_as_user();
|
||||||
$this->assertTitle('Image 1914: test');
|
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "test");
|
||||||
|
$idp1 = $image_id + 1;
|
||||||
|
$this->log_out();
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/post/view/1');
|
$this->get_page("post/view/$image_id");
|
||||||
|
$this->assertTitle("Image $image_id: test");
|
||||||
|
|
||||||
|
$this->get_page("post/view/$idp1");
|
||||||
$this->assertTitle('Image not found');
|
$this->assertTitle('Image not found');
|
||||||
|
|
||||||
$this->get(TEST_BASE.'/post/view/-1');
|
$this->get_page('post/view/-1');
|
||||||
$this->assertTitle('Image not found');
|
$this->assertTitle('Image not found');
|
||||||
|
|
||||||
|
$this->log_in_as_admin();
|
||||||
|
$this->delete_image($image_id);
|
||||||
|
$this->log_out();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user