This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/wiki/test.php

123 lines
3.1 KiB
PHP
Raw Normal View History

2009-07-19 03:48:25 +00:00
<?php
2015-09-12 11:24:18 +00:00
class WikiTest extends ShimmiePHPUnitTestCase {
2015-09-26 10:17:13 +00:00
public 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
}
2015-09-26 10:17:13 +00:00
public function testAccess() {
$this->markTestIncomplete();
2015-09-12 11:24:18 +00:00
global $config;
2009-07-28 08:40:37 +00:00
foreach(array("anon", "user", "admin") as $user) {
foreach(array(false, true) as $allowed) {
// admin has no settings to set
if($user != "admin") {
2015-09-12 11:24:18 +00:00
$config->set_bool("wiki_edit_$user", $allowed);
2009-07-28 08:40:37 +00:00
}
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");
2015-09-12 11:24:18 +00:00
2009-07-28 08:40:37 +00:00
if($allowed || $user == "admin") {
2015-09-12 11:24:18 +00:00
$this->get_page("wiki/test", array('edit'=>'on'));
2009-08-19 00:28:48 +00:00
$this->assert_text("Editor");
2009-07-28 08:40:37 +00:00
}
else {
2015-09-12 11:24:18 +00:00
$this->get_page("wiki/test", array('edit'=>'on'));
2009-08-19 00:28:48 +00:00
$this->assert_no_text("Editor");
2009-07-28 08:40:37 +00:00
}
2015-09-12 11:24:18 +00:00
if($user == "user" || $user == "admin") {
$this->log_out();
}
2009-07-28 08:40:37 +00:00
}
}
}
2015-09-26 10:17:13 +00:00
public function testLock() {
$this->markTestIncomplete();
2015-09-12 11:24:18 +00:00
global $config;
$config->set_bool("wiki_edit_anon", true);
$config->set_bool("wiki_edit_user", false);
2009-07-28 08:40:37 +00:00
$this->log_in_as_admin();
$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();
}
2015-09-26 10:17:13 +00:00
public function testDefault() {
$this->markTestIncomplete();
2009-07-28 08:40:37 +00:00
$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();
}
2015-09-26 10:17:13 +00:00
public function testRevisions() {
$this->markTestIncomplete();
2009-07-28 08:40:37 +00:00
$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
}
}