2008-10-11 07:09:42 +00:00
|
|
|
<?php
|
2015-08-09 11:14:28 +00:00
|
|
|
class AdminPageTest extends ShimmiePHPUnitTestCase {
|
2015-09-26 10:17:13 +00:00
|
|
|
public function testAuth() {
|
2009-07-15 01:42:18 +00:00
|
|
|
$this->get_page('admin');
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_response(403);
|
|
|
|
$this->assert_title("Permission Denied");
|
2008-10-11 07:09:42 +00:00
|
|
|
|
2009-07-15 01:42:18 +00:00
|
|
|
$this->log_in_as_user();
|
|
|
|
$this->get_page('admin');
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_response(403);
|
|
|
|
$this->assert_title("Permission Denied");
|
2015-08-09 11:14:28 +00:00
|
|
|
|
|
|
|
$this->log_in_as_admin();
|
|
|
|
$this->get_page('admin');
|
|
|
|
$this->assert_response(200);
|
|
|
|
$this->assert_title("Admin Tools");
|
2010-03-24 12:32:04 +00:00
|
|
|
}
|
|
|
|
|
2015-09-26 10:17:13 +00:00
|
|
|
public function testLowercase() {
|
2010-05-04 19:10:37 +00:00
|
|
|
$ts = time(); // we need a tag that hasn't been used before
|
|
|
|
|
2010-03-24 12:32:04 +00:00
|
|
|
$this->log_in_as_admin();
|
2015-08-09 11:14:28 +00:00
|
|
|
$image_id_1 = $this->post_image("tests/pbx_screenshot.jpg", "TeStCase$ts");
|
2010-03-24 12:32:04 +00:00
|
|
|
|
2012-03-09 22:08:55 +00:00
|
|
|
$this->get_page("post/view/$image_id_1");
|
|
|
|
$this->assert_title("Image $image_id_1: TeStCase$ts");
|
2010-03-24 12:32:04 +00:00
|
|
|
|
|
|
|
$this->get_page('admin');
|
|
|
|
$this->assert_title("Admin Tools");
|
2015-08-09 11:14:28 +00:00
|
|
|
//$this->click("All tags to lowercase");
|
|
|
|
send_event(new AdminActionEvent('lowercase_all_tags'));
|
2010-03-24 12:32:04 +00:00
|
|
|
|
2012-03-09 22:08:55 +00:00
|
|
|
$this->get_page("post/view/$image_id_1");
|
2012-03-11 00:17:09 +00:00
|
|
|
$this->assert_title("Image $image_id_1: testcase$ts");
|
2010-03-24 12:32:04 +00:00
|
|
|
|
|
|
|
$this->delete_image($image_id_1);
|
|
|
|
}
|
|
|
|
|
|
|
|
# FIXME: make sure the admin tools actually work
|
2015-09-26 10:17:13 +00:00
|
|
|
public function testRecount() {
|
2010-03-24 12:32:04 +00:00
|
|
|
$this->log_in_as_admin();
|
|
|
|
$this->get_page('admin');
|
|
|
|
$this->assert_title("Admin Tools");
|
2008-10-11 07:09:42 +00:00
|
|
|
|
2015-08-09 11:14:28 +00:00
|
|
|
//$this->click("Recount tag use");
|
|
|
|
send_event(new AdminActionEvent('recount_tag_use'));
|
2010-03-24 12:32:04 +00:00
|
|
|
}
|
2009-07-20 05:51:36 +00:00
|
|
|
|
2015-09-26 10:17:13 +00:00
|
|
|
public function testDump() {
|
2010-03-24 12:32:04 +00:00
|
|
|
$this->log_in_as_admin();
|
|
|
|
$this->get_page('admin');
|
|
|
|
$this->assert_title("Admin Tools");
|
2015-08-09 11:14:28 +00:00
|
|
|
|
|
|
|
// this calls mysqldump which jams up travis prompting for a password
|
|
|
|
//$this->click("Download database contents");
|
|
|
|
//send_event(new AdminActionEvent('database_dump'));
|
|
|
|
//$this->assert_response(200);
|
2012-03-11 14:02:00 +00:00
|
|
|
}
|
|
|
|
|
2015-09-26 10:17:13 +00:00
|
|
|
public function testDBQ() {
|
2012-03-11 14:02:00 +00:00
|
|
|
$this->log_in_as_user();
|
2015-08-09 11:14:28 +00:00
|
|
|
$image_id_1 = $this->post_image("tests/pbx_screenshot.jpg", "test");
|
|
|
|
$image_id_2 = $this->post_image("tests/bedroom_workshop.jpg", "test2");
|
|
|
|
$image_id_3 = $this->post_image("tests/favicon.png", "test");
|
2012-03-11 14:02:00 +00:00
|
|
|
|
|
|
|
$this->get_page("post/list/test/1");
|
2015-08-09 11:14:28 +00:00
|
|
|
//$this->click("Delete All These Images");
|
|
|
|
$_POST['query'] = 'test';
|
|
|
|
//$_POST['reason'] = 'reason'; // non-null-reason = add a hash ban
|
|
|
|
send_event(new AdminActionEvent('delete_by_query'));
|
2012-03-11 14:02:00 +00:00
|
|
|
|
|
|
|
$this->get_page("post/view/$image_id_1");
|
|
|
|
$this->assert_response(404);
|
|
|
|
$this->get_page("post/view/$image_id_2");
|
|
|
|
$this->assert_response(200);
|
|
|
|
$this->get_page("post/view/$image_id_3");
|
|
|
|
$this->assert_response(404);
|
|
|
|
|
2012-04-01 17:17:33 +00:00
|
|
|
$this->delete_image($image_id_1);
|
2012-03-11 14:02:00 +00:00
|
|
|
$this->delete_image($image_id_2);
|
2012-04-01 17:17:33 +00:00
|
|
|
$this->delete_image($image_id_3);
|
2010-03-24 12:32:04 +00:00
|
|
|
}
|
2008-10-11 07:09:42 +00:00
|
|
|
}
|
2014-04-25 02:34:45 +00:00
|
|
|
|