A bunch of testing / fixes
This commit is contained in:
parent
c94e16f814
commit
46ce762949
@ -12,12 +12,14 @@ class AdminPageTest extends ShimmieWebTestCase {
|
||||
$this->log_out();
|
||||
}
|
||||
|
||||
function testPurge() {
|
||||
function testLowercase() {
|
||||
$ts = time(); // we need a tag that hasn't been used before
|
||||
|
||||
$this->log_in_as_admin();
|
||||
$image_id_1 = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "TeSt");
|
||||
$image_id_1 = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "TeStCase$ts");
|
||||
|
||||
$this->get_page("post/view/$image_id_1");
|
||||
$this->assert_title("Image $image_id_1: TeSt");
|
||||
$this->assert_title("Image $image_id_1: TeStCase$ts");
|
||||
|
||||
$this->get_page('admin');
|
||||
$this->assert_title("Admin Tools");
|
||||
@ -26,7 +28,7 @@ class AdminPageTest extends ShimmieWebTestCase {
|
||||
$this->log_out();
|
||||
|
||||
$this->get_page("post/view/$image_id_1");
|
||||
$this->assert_title("Image $image_id_1: test");
|
||||
$this->assert_title("Image $image_id_1: testcase$ts");
|
||||
|
||||
$this->delete_image($image_id_1);
|
||||
$this->log_out();
|
||||
|
@ -7,6 +7,9 @@
|
||||
* Documentation:
|
||||
*/
|
||||
|
||||
class PoolCreationException extends SCoreException {
|
||||
}
|
||||
|
||||
class Pools extends SimpleExtension {
|
||||
public function onInitExt($event) {
|
||||
global $config, $database;
|
||||
@ -81,12 +84,13 @@ class Pools extends SimpleExtension {
|
||||
break;
|
||||
|
||||
case "create": // ADD _POST
|
||||
if(!$user->is_anonymous()) {
|
||||
try {
|
||||
$newPoolID = $this->add_pool();
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("pool/view/".$newPoolID));
|
||||
} else {
|
||||
$this->theme->display_error("You must be registered and logged in to add a image.");
|
||||
}
|
||||
catch(PoolCreationException $pce) {
|
||||
$this->theme->display_error($pce->getMessage());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -269,14 +273,15 @@ class Pools extends SimpleExtension {
|
||||
|
||||
$poolsPerPage = $config->get_int("poolsListsPerPage");
|
||||
|
||||
$pools = $database->get_all(
|
||||
"SELECT p.id, p.user_id, p.public, p.title, p.description, p.posts, u.name as user_name ".
|
||||
"FROM pools AS p ".
|
||||
"INNER JOIN users AS u ".
|
||||
"ON p.user_id = u.id ".
|
||||
"ORDER BY p.date DESC ".
|
||||
"OFFSET ? LIMIT ?"
|
||||
, array($pageNumber * $poolsPerPage, $poolsPerPage)
|
||||
$pools = $database->get_all("
|
||||
SELECT p.id, p.user_id, p.public, p.title, p.description,
|
||||
p.posts, u.name as user_name
|
||||
FROM pools AS p
|
||||
INNER JOIN users AS u
|
||||
ON p.user_id = u.id
|
||||
ORDER BY p.date DESC
|
||||
LIMIT ? OFFSET ?
|
||||
", array($poolsPerPage, $pageNumber * $poolsPerPage)
|
||||
);
|
||||
|
||||
$totalPages = ceil($database->db->GetOne("SELECT COUNT(*) FROM pools") / $poolsPerPage);
|
||||
@ -291,6 +296,13 @@ class Pools extends SimpleExtension {
|
||||
private function add_pool() {
|
||||
global $user, $database;
|
||||
|
||||
if($user->is_anonymous()) {
|
||||
throw new PoolCreationException("You must be registered and logged in to add a image.");
|
||||
}
|
||||
if(empty($_POST["title"])) {
|
||||
throw new PoolCreationException("Pool needs a title");
|
||||
}
|
||||
|
||||
$public = $_POST["public"] == "Y" ? "Y" : "N";
|
||||
$database->execute("
|
||||
INSERT INTO pools (user_id, public, title, description, date)
|
||||
@ -452,8 +464,8 @@ class Pools extends SimpleExtension {
|
||||
INNER JOIN images AS i ON i.id = p.image_id
|
||||
WHERE p.pool_id = ? AND i.rating IN ($rating)
|
||||
ORDER BY p.image_order ASC
|
||||
OFFSET ? LIMIT ?",
|
||||
array($poolID, $pageNumber * $imagesPerPage, $imagesPerPage));
|
||||
LIMIT ? OFFSET ?",
|
||||
array($poolID, $imagesPerPage, $pageNumber * $imagesPerPage));
|
||||
|
||||
$totalPages = ceil($database->db->GetOne("
|
||||
SELECT COUNT(*)
|
||||
@ -468,8 +480,8 @@ class Pools extends SimpleExtension {
|
||||
FROM pool_images
|
||||
WHERE pool_id=?
|
||||
ORDER BY image_order ASC
|
||||
OFFSET ? LIMIT ?",
|
||||
array($poolID, $pageNumber * $imagesPerPage, $imagesPerPage));
|
||||
LIMIT ? OFFSET ?",
|
||||
array($poolID, $imagesPerPage, $pageNumber * $imagesPerPage));
|
||||
$totalPages = ceil($database->db->GetOne("SELECT COUNT(*) FROM pool_images WHERE pool_id=?", array($poolID)) / $imagesPerPage);
|
||||
}
|
||||
|
||||
@ -580,16 +592,17 @@ class Pools extends SimpleExtension {
|
||||
|
||||
$historiesPerPage = $config->get_int("poolsUpdatedPerPage");
|
||||
|
||||
$history = $database->get_all(
|
||||
"SELECT h.id, h.pool_id, h.user_id, h.action, h.images, h.count, h.date, u.name as user_name, p.title as title ".
|
||||
"FROM pool_history AS h ".
|
||||
"INNER JOIN pools AS p ".
|
||||
"ON p.id = h.pool_id ".
|
||||
"INNER JOIN users AS u ".
|
||||
"ON h.user_id = u.id ".
|
||||
"ORDER BY h.date DESC ".
|
||||
"OFFSET ? LIMIT ?"
|
||||
, array($pageNumber * $historiesPerPage, $historiesPerPage));
|
||||
$history = $database->get_all("
|
||||
SELECT h.id, h.pool_id, h.user_id, h.action, h.images,
|
||||
h.count, h.date, u.name as user_name, p.title as title
|
||||
FROM pool_history AS h
|
||||
INNER JOIN pools AS p
|
||||
ON p.id = h.pool_id
|
||||
INNER JOIN users AS u
|
||||
ON h.user_id = u.id
|
||||
ORDER BY h.date DESC
|
||||
LIMIT ? OFFSET ?
|
||||
", array($historiesPerPage, $pageNumber * $historiesPerPage));
|
||||
|
||||
$totalPages = ceil($database->db->GetOne("SELECT COUNT(*) FROM pool_history") / $historiesPerPage);
|
||||
|
||||
|
@ -11,7 +11,7 @@ class PoolsTest extends ShimmieWebTestCase {
|
||||
$this->log_in_as_user();
|
||||
|
||||
$this->get_page('pool/list');
|
||||
$this->click("Create New");
|
||||
$this->click("Create Pool");
|
||||
$this->assert_title("Create Pool");
|
||||
$this->click("Create");
|
||||
$this->assert_title("Error");
|
||||
@ -31,7 +31,7 @@ class PoolsTest extends ShimmieWebTestCase {
|
||||
$this->get_page('pool/list');
|
||||
$this->click("Test Pool Title");
|
||||
$this->assert_title("Pool: Test Pool Title");
|
||||
$this->click("Delete");
|
||||
$this->click("Delete Pool");
|
||||
$this->assert_title("Pools");
|
||||
$this->assert_no_text("Test Pool Title");
|
||||
|
||||
|
@ -86,7 +86,7 @@ class PoolsTheme extends Themelet {
|
||||
<tr><td>Title:</td><td><input type='text' name='title'></td></tr>
|
||||
<tr><td>Public?</td><td><input name='public' type='checkbox' value='Y' checked='checked'/></td></tr>
|
||||
<tr><td>Description:</td><td><textarea name='description'></textarea></td></tr>
|
||||
<tr><td colspan='2'><input type='submit' value='Submit' /></td></tr>
|
||||
<tr><td colspan='2'><input type='submit' value='Create' /></td></tr>
|
||||
</table>
|
||||
";
|
||||
|
||||
@ -147,7 +147,7 @@ class PoolsTheme extends Themelet {
|
||||
public function view_pool($pools, $images, $pageNumber, $totalPages) {
|
||||
global $user, $page;
|
||||
|
||||
$this->display_top($pools, "Viewing Pool");
|
||||
$this->display_top($pools, "Pool: ".$pools[0]['title']);
|
||||
|
||||
$pool_images = '';
|
||||
foreach($images as $image) {
|
||||
|
@ -176,6 +176,8 @@ class ShimmieWebTestCase extends SCoreWebTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertTrue($image_id > 0);
|
||||
|
||||
$this->setMaximumRedirects(5);
|
||||
return $image_id;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ class ExtManagerTest extends SCoreWebTestCase {
|
||||
$this->assert_title("Extensions");
|
||||
|
||||
$this->get_page('ext_doc');
|
||||
$this->assert_response(404);
|
||||
$this->assert_title("Extensions");
|
||||
|
||||
$this->get_page('ext_doc/ext_manager');
|
||||
$this->assert_title("Documentation for Extension Manager");
|
||||
|
@ -155,8 +155,15 @@ class Index extends SimpleExtension {
|
||||
$search_terms = $event->get_search_terms();
|
||||
$page_number = $event->get_page_number();
|
||||
$page_size = $event->get_page_size();
|
||||
$total_pages = Image::count_pages($search_terms);
|
||||
$images = Image::find_images(($page_number-1)*$page_size, $page_size, $search_terms);
|
||||
try {
|
||||
$total_pages = Image::count_pages($search_terms);
|
||||
$images = Image::find_images(($page_number-1)*$page_size, $page_size, $search_terms);
|
||||
}
|
||||
catch(SearchTermParseException $stpe) {
|
||||
// FIXME: display the error somewhere
|
||||
$total_pages = 0;
|
||||
$images = array();
|
||||
}
|
||||
|
||||
if(count($search_terms) == 0 && count($images) == 0 && $page_number == 1) {
|
||||
$this->theme->display_intro($page);
|
||||
|
Loading…
x
Reference in New Issue
Block a user