2009-07-19 03:48:25 +00:00
|
|
|
<?php
|
2009-07-21 06:36:12 +00:00
|
|
|
class WikiTest extends SCoreWebTestCase {
|
2009-07-28 08:40:37 +00:00
|
|
|
function testIndex() {
|
2009-07-19 03:48:25 +00:00
|
|
|
$this->get_page("wiki");
|
|
|
|
$this->assertTitle("Index");
|
2009-07-28 08:40:37 +00:00
|
|
|
$this->assertText("This is a default page");
|
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
$this->setField("_config_wiki_edit_$user", $allowed);
|
|
|
|
$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");
|
|
|
|
$this->assertTitle("test");
|
|
|
|
$this->assertText("This is a default page");
|
|
|
|
if($allowed || $user == "admin") {
|
|
|
|
$this->click("Edit");
|
|
|
|
$this->assertText("Editor");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$this->click("Edit");
|
|
|
|
$this->assertNoText("Editor");
|
|
|
|
}
|
|
|
|
|
|
|
|
if($user == "user" || $user == "admin") {$this->log_out();}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function testLock() {
|
|
|
|
$this->log_in_as_admin();
|
|
|
|
$this->get_page("setup");
|
|
|
|
$this->setField("_config_wiki_Edit_anon", false);
|
|
|
|
$this->setField("_config_wiki_Edit_user", true);
|
|
|
|
$this->click("Save Settings");
|
|
|
|
|
|
|
|
$this->get_page("wiki/test_locked");
|
|
|
|
$this->assertTitle("test_locked");
|
|
|
|
$this->assertText("This is a default page");
|
|
|
|
$this->click("Edit");
|
|
|
|
$this->setField("body", "test_locked content");
|
|
|
|
$this->setField("lock", true);
|
|
|
|
$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");
|
|
|
|
$this->assertTitle("test_locked");
|
|
|
|
$this->assertText("test_locked content");
|
|
|
|
$this->assertNoText("Edit");
|
|
|
|
$this->log_out();
|
|
|
|
|
|
|
|
$this->get_page("wiki/test_locked");
|
|
|
|
$this->assertTitle("test_locked");
|
|
|
|
$this->assertText("test_locked content");
|
|
|
|
$this->assertNoText("Edit");
|
|
|
|
|
|
|
|
$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");
|
|
|
|
$this->assertTitle("wiki:default");
|
|
|
|
$this->assertText("This is a default page");
|
|
|
|
$this->click("Edit");
|
|
|
|
$this->setField("body", "Empty page! Fill it!");
|
|
|
|
$this->click("Save");
|
|
|
|
|
|
|
|
$this->get_page("wiki/something");
|
|
|
|
$this->assertText("Empty page! Fill it!");
|
|
|
|
|
|
|
|
$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");
|
|
|
|
$this->assertTitle("test");
|
|
|
|
$this->assertText("This is a default page");
|
|
|
|
$this->click("Edit");
|
|
|
|
$this->setField("body", "Mooooo 1");
|
|
|
|
$this->click("Save");
|
|
|
|
$this->assertText("Mooooo 1");
|
|
|
|
$this->assertText("Revision 1");
|
|
|
|
$this->click("Edit");
|
|
|
|
$this->setField("body", "Mooooo 2");
|
|
|
|
$this->click("Save");
|
|
|
|
$this->assertText("Mooooo 2");
|
|
|
|
$this->assertText("Revision 2");
|
|
|
|
$this->click("Delete This Version");
|
|
|
|
$this->assertText("Mooooo 1");
|
|
|
|
$this->assertText("Revision 1");
|
|
|
|
$this->click("Delete All");
|
|
|
|
$this->log_out();
|
2009-07-19 03:48:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|