2009-07-19 03:48:25 +00:00
|
|
|
<?php
|
2015-08-09 11:14:28 +00:00
|
|
|
class WikiTest {
|
2009-07-28 08:40:37 +00:00
|
|
|
function testIndex() {
|
2009-07-19 03:48:25 +00:00
|
|
|
$this->get_page("wiki");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_title("Index");
|
|
|
|
$this->assert_text("This is a default page");
|
2009-07-28 08:40:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testAccess() {
|
|
|
|
foreach(array("anon", "user", "admin") as $user) {
|
|
|
|
foreach(array(false, true) as $allowed) {
|
|
|
|
// admin has no settings to set
|
|
|
|
if($user != "admin") {
|
|
|
|
$this->log_in_as_admin();
|
|
|
|
$this->get_page("setup");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->set_field("_config_wiki_edit_$user", $allowed);
|
2009-07-28 08:40:37 +00:00
|
|
|
$this->click("Save Settings");
|
|
|
|
$this->log_out();
|
|
|
|
}
|
|
|
|
|
|
|
|
if($user == "user") {$this->log_in_as_user();}
|
|
|
|
if($user == "admin") {$this->log_in_as_admin();}
|
|
|
|
|
|
|
|
$this->get_page("wiki/test");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_title("test");
|
|
|
|
$this->assert_text("This is a default page");
|
2009-07-28 08:40:37 +00:00
|
|
|
if($allowed || $user == "admin") {
|
|
|
|
$this->click("Edit");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_text("Editor");
|
2009-07-28 08:40:37 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$this->click("Edit");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_no_text("Editor");
|
2009-07-28 08:40:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if($user == "user" || $user == "admin") {$this->log_out();}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function testLock() {
|
|
|
|
$this->log_in_as_admin();
|
|
|
|
$this->get_page("setup");
|
2009-08-19 00:33:00 +00:00
|
|
|
$this->set_field("_config_wiki_edit_anon", false);
|
|
|
|
$this->set_field("_config_wiki_edit_user", true);
|
2009-07-28 08:40:37 +00:00
|
|
|
$this->click("Save Settings");
|
|
|
|
|
|
|
|
$this->get_page("wiki/test_locked");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_title("test_locked");
|
|
|
|
$this->assert_text("This is a default page");
|
2009-07-28 08:40:37 +00:00
|
|
|
$this->click("Edit");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->set_field("body", "test_locked content");
|
|
|
|
$this->set_field("lock", true);
|
2009-07-28 08:40:37 +00:00
|
|
|
$this->click("Save");
|
2009-07-19 03:48:25 +00:00
|
|
|
$this->log_out();
|
2009-07-20 05:51:36 +00:00
|
|
|
|
2009-07-28 08:40:37 +00:00
|
|
|
$this->log_in_as_user();
|
|
|
|
$this->get_page("wiki/test_locked");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_title("test_locked");
|
|
|
|
$this->assert_text("test_locked content");
|
|
|
|
$this->assert_no_text("Edit");
|
2009-07-28 08:40:37 +00:00
|
|
|
$this->log_out();
|
|
|
|
|
|
|
|
$this->get_page("wiki/test_locked");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_title("test_locked");
|
|
|
|
$this->assert_text("test_locked content");
|
|
|
|
$this->assert_no_text("Edit");
|
2009-07-28 08:40:37 +00:00
|
|
|
|
|
|
|
$this->log_in_as_admin();
|
|
|
|
$this->get_page("wiki/test_locked");
|
|
|
|
$this->click("Delete All");
|
|
|
|
$this->log_out();
|
|
|
|
}
|
|
|
|
|
|
|
|
function testDefault() {
|
|
|
|
$this->log_in_as_admin();
|
|
|
|
$this->get_page("wiki/wiki:default");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_title("wiki:default");
|
|
|
|
$this->assert_text("This is a default page");
|
2009-07-28 08:40:37 +00:00
|
|
|
$this->click("Edit");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->set_field("body", "Empty page! Fill it!");
|
2009-07-28 08:40:37 +00:00
|
|
|
$this->click("Save");
|
|
|
|
|
|
|
|
$this->get_page("wiki/something");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_text("Empty page! Fill it!");
|
2009-07-28 08:40:37 +00:00
|
|
|
|
|
|
|
$this->get_page("wiki/wiki:default");
|
|
|
|
$this->click("Delete All");
|
|
|
|
$this->log_out();
|
|
|
|
}
|
|
|
|
|
|
|
|
function testRevisions() {
|
|
|
|
$this->log_in_as_admin();
|
|
|
|
$this->get_page("wiki/test");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_title("test");
|
|
|
|
$this->assert_text("This is a default page");
|
2009-07-28 08:40:37 +00:00
|
|
|
$this->click("Edit");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->set_field("body", "Mooooo 1");
|
2009-07-28 08:40:37 +00:00
|
|
|
$this->click("Save");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_text("Mooooo 1");
|
|
|
|
$this->assert_text("Revision 1");
|
2009-07-28 08:40:37 +00:00
|
|
|
$this->click("Edit");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->set_field("body", "Mooooo 2");
|
2009-07-28 08:40:37 +00:00
|
|
|
$this->click("Save");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_text("Mooooo 2");
|
|
|
|
$this->assert_text("Revision 2");
|
2009-07-28 08:40:37 +00:00
|
|
|
$this->click("Delete This Version");
|
2009-08-19 00:28:48 +00:00
|
|
|
$this->assert_text("Mooooo 1");
|
|
|
|
$this->assert_text("Revision 1");
|
2009-07-28 08:40:37 +00:00
|
|
|
$this->click("Delete All");
|
|
|
|
$this->log_out();
|
2009-07-19 03:48:25 +00:00
|
|
|
}
|
|
|
|
}
|
2014-04-26 02:54:51 +00:00
|
|
|
|