/** * @coversNothing */ public function test_no_aprroved_banner() { global $conf; $conf['plugin']['publish']['hide_approved_banner'] = 1; saveWikiText('foo', 'bar', 'foobar'); $request = new TestRequest(); $response = $request->get(array(), '/doku.php?id=foo&publish_approve=1'); $this->assertTrue(strpos($response->getContent(), '<div class="approval') === false, 'The approved banner is still showing even so it is supposed not to show.'); }
/** * Verify the toolstrip button was correctly rendered. */ public function test_render_toolstrip_button() { $thisPlugin = plugin_load('action', 'door43obsdocupload_ExportButtons'); $request = new TestRequest(); $response = $request->get(array('id' => 'en:obs'), '/doku.php'); $content = $response->getContent(); // output check $this->assertNotEmpty($content); $this->assertContains($thisPlugin->lang['getTemplate'], $content); }
/** * Verify the button was correctly rendered. */ public function test_render_button() { $thisPlugin = plugin_load('syntax', 'door43obs_CreateNow'); $request = new TestRequest(); $response = $request->get(array('id' => 'obs-setup'), '/doku.php'); $content = $response->getContent(); // output check $this->assertNotEmpty($content); $this->assertContains($thisPlugin->lang['createButtonText'], $content); }
public function setUp() { parent::setUp(); saveWikiText('foo', "====== Page-Heading ======", 'summary'); $req = new TestRequest(); $req->get(array(), '/doku.php?id=foo'); saveWikiText('testpage', "---- dataentry Testentry ----\n" . "test1_title: foo|bar\n" . "----\n", 'summary'); //trigger save to db $req = new TestRequest(); $req->get(array(), '/doku.php?id=testpage'); }
/** * Verify the button was correctly rendered. */ public function test_render_button() { // TODO: fix this test $this->markTestSkipped('The test needs fixed'); $thisPlugin = plugin_load('syntax', 'door43obs_CreateObsNotes'); $request = new TestRequest(); $response = $request->get(array('id' => 'obs-setup'), '/doku.php'); $content = $response->getContent(); // output check $this->assertNotEmpty($content); $this->assertContains($thisPlugin->lang['createObsNotesButtonText'], $content); }
function testTitle() { global $conf; $request = new TestRequest(); $response = $request->get(); $content = $response->queryHTML('title'); $this->assertTrue(strpos($content, $conf['title']) > 0); $conf['title'] = 'Foo'; $request = new TestRequest(); $response = $request->get(); $content = $response->queryHTML('title'); $this->assertTrue(strpos($content, 'Foo') > 0); }
/** * Verify the button was correctly rendered. */ public function test_setChapterLabel_bug() { plugin_load('syntax', 'usfmtag'); $request = new TestRequest(); $response = $request->get(array('id' => 'psalm1-1test'), '/doku.php'); $content = $response->getContent(); // output check $this->assertNotEmpty($content); $this->assertContains('<h1 class="sectionedit1" id="psalms_0011-2">Psalms 001:1-2</h1>', $content); $this->assertNotContains('<usfm>', $content); $this->assertNotContains('\\c', $content); $this->assertNotContains('\\v', $content); }
public function test_edit_page_with_schema() { $page = 'test_edit_page_with_schema'; $assignment = new meta\Assignments(); $schema = 'Schema2'; $assignment->addPattern($page, $schema); $request = new \TestRequest(); $response = $request->get(array('id' => $page, 'do' => 'edit'), '/doku.php'); $test_html = trim($response->queryHTML('.struct_entry_form')->html()); $pq = \phpQuery::newDocument($test_html); $this->assertEquals('Schema2', $pq->find('legend')->text()); $this->checkField($pq, 'Schema2', 'afirst', ''); $this->checkField($pq, 'Schema2', 'asecond', ''); $this->checkField($pq, 'Schema2', 'athird', ''); $this->checkField($pq, 'Schema2', 'afourth', ''); }
function testGet() { $request = new TestRequest(); $input = array('string' => 'A string', 'array' => array(1, 2, 3), 'test' => 'bar'); $response = $request->get($input, '/doku.php?id=wiki:dokuwiki&test=foo'); // server var check $this->assertEquals('GET', $request->getServer('REQUEST_METHOD')); $this->assertEquals('?id=wiki:dokuwiki&test=bar&string=A+string&array[0]=1&array[1]=2&array[2]=3', $request->getServer('QUERY_STRING')); $this->assertEquals('/doku.php?id=wiki:dokuwiki&test=bar&string=A+string&array[0]=1&array[1]=2&array[2]=3', $request->getServer('REQUEST_URI')); // variable setup check $this->assertEquals('A string', $request->getGet('string')); $this->assertEquals(array(1, 2, 3), $request->getGet('array')); $this->assertEquals('wiki:dokuwiki', $request->getGet('id')); $this->assertEquals('bar', $request->getGet('test')); // output check $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0); }
/** * Blackbox integration test of action_plugin_publish_mail::getLastApproved * * @coversNothing */ public function test_getLastApproved() { global $ID; $ID = 'foo'; saveWikiText('foo', 'bar old', 'foobar'); saveWikiText('foo', 'bar approved', 'foobar'); $data = pageinfo(); $expected_revision = $data['currentrev']; //Make sure we have the rights to actully approve a revision $this->assertSame(255, auth_quickaclcheck('foo')); $request = new TestRequest(); $request->get(array(), '/doku.php?id=foo&publish_approve'); saveWikiText('foo', 'bar new', 'foobar'); /** @var helper_plugin_publish $helper */ $helper = plugin_load('helper', 'publish'); $actual_lastapproved_helper = $helper->getLatestApprovedRevision($ID); $this->assertSame($expected_revision, $actual_lastapproved_helper); }
/** * Regression test: run activity by namespace report, verify correct values * appear * * @return nothing */ public function test_activity_by_namespace() { $request = new TestRequest(); $response = $request->get(array('id' => 'test_activity_by_namespace'), '/doku.php'); $content = $response->getContent(); $this->assertNotEmpty($content); // Verify totals $this->assertRegExp("/TOTAL<[^>]*><[^>]*>6<[^>]*><[^>]*>35<[^>]*><[^>]*>30/", $content); // need to do this because strtotime uses the timezone on the server $start_timestamp = strtotime('2015-07-01'); $end_timestamp = strtotime('2015-07-04'); // Verify timestamps were understood correctly $this->assertRegExp("/start_timestamp<[^>]*><[^>]*>{$start_timestamp}/", $content); $this->assertRegExp("/end_timestamp<[^>]*><[^>]*>{$end_timestamp}/", $content); // Verify page counts $this->assertRegExp("/debug_num_pages_in_ns<[^>]*><[^>]*>70/", $content); $this->assertRegExp("/debug_num_revisions_in_ns<[^>]*><[^>]*>2039/", $content); $this->assertRegExp("/debug_num_revisions_within_dates<[^>]*><[^>]*>169/", $content); }
function testHeaders() { header('X-Test: check headers working'); $header_check = function_exists('xdebug_get_headers') ? xdebug_get_headers() : headers_list(); if (empty($header_check)) { $this->markTestSkipped('headers not returned, perhaps your sapi does not return headers, try xdebug'); } else { header_remove('X-Test'); } $request = new TestRequest(); $response = $request->get(array(), '/lib/exe/fetch.php?media=wiki:dokuwiki-128.png'); $headers = $response->getHeaders(); $this->assertTrue(!empty($headers)); }
/** * Test that, if provided, an IP address is logged. * @link https://github.com/samwilson/dokuwiki-plugin-log404/issues/1 */ public function test_ip_address() { $log = plugin_load('helper', 'log404'); // Reset the log @unlink($log->filename()); // Request a page. $request1 = new TestRequest(); //$request1->setServer('HTTP_USER_AGENT', '198.51.100.35'); $request1->get(array('id' => 'page-that-does-not-exist')); // Check the log. This IP is set in _test/bootstrap.php $log->load(); $a = $log->getRecord('page-that-does-not-exist'); $this->assertEquals('87.142.120.6', $a['hits'][0]['ip']); }
function fetchResponse($token) { $request = new TestRequest(); return $request->get(array(), str_replace('{%token%}', $token, $this->getUri())); }
function testINPUT() { $request = new TestRequest(); $response = $request->get(array('id' => 'mailinglist'), '/doku.php'); // output check // 2015-07-03, Phil Hopper: this is silly and also failing //$this->assertTrue(strpos($response->getContent(), 'Netiquette') !== false); }
/** * This is an integration test, which checks the correct working of an entire namespace move. * Hence it is not an unittest, hence it @coversNothing * * @group slow */ function test_move_large_ns() { $this->markTestSkipped('This test randomly fails with the page "testns:start" being moved, but "start" not being rewritten in the request.'); global $conf; $test = '[[testns:start]] [[testns:test_page17]]'; $summary = 'testsetup'; saveWikiText(':start', $test, $summary); idx_addPage(':start'); saveWikiText('testns:start', $test, $summary); idx_addPage('testns:start'); saveWikiText('testns:test_page1', $test, $summary); idx_addPage('testns:test_page1'); saveWikiText('testns:test_page2', $test, $summary); idx_addPage('testns:test_page2'); saveWikiText('testns:test_page3', $test, $summary); idx_addPage('testns:test_page3'); saveWikiText('testns:test_page4', $test, $summary); idx_addPage('testns:test_page4'); saveWikiText('testns:test_page5', $test, $summary); idx_addPage('testns:test_page5'); saveWikiText('testns:test_page6', $test, $summary); idx_addPage('testns:test_page6'); saveWikiText('testns:test_page7', $test, $summary); idx_addPage('testns:test_page7'); saveWikiText('testns:test_page8', $test, $summary); idx_addPage('testns:test_page8'); saveWikiText('testns:test_page9', $test, $summary); idx_addPage('testns:test_page9'); saveWikiText('testns:test_page10', $test, $summary); idx_addPage('testns:test_page10'); saveWikiText('testns:test_page11', $test, $summary); idx_addPage('testns:test_page11'); saveWikiText('testns:test_page12', $test, $summary); idx_addPage('testns:test_page12'); saveWikiText('testns:test_page13', $test, $summary); idx_addPage('testns:test_page13'); saveWikiText('testns:test_page14', $test, $summary); idx_addPage('testns:test_page14'); saveWikiText('testns:test_page15', $test, $summary); idx_addPage('testns:test_page15'); saveWikiText('testns:test_page16', $test, $summary); idx_addPage('testns:test_page16'); saveWikiText('testns:test_page17', $test, $summary); idx_addPage('testns:test_page17'); saveWikiText('testns:test_page18', $test, $summary); idx_addPage('testns:test_page18'); saveWikiText('testns:test_page19', $test, $summary); idx_addPage('testns:test_page19'); $conf['plugin']['move']['autorewrite'] = 0; /** @var helper_plugin_move_plan $plan */ $plan = plugin_load('helper', 'move_plan'); $this->assertFalse($plan->inProgress()); $plan->addPageNamespaceMove('testns', 'foo:testns'); $plan->commit(); global $conf; $lockfile = $conf['lockdir'] . 'move.lock'; $this->assertSame(10, $plan->nextStep(), "After processing first chunk of pages, 10 steps should be left"); $request = new TestRequest(); $response = $request->get(); $actual_response = $response->getContent(); //clean away clutter $actual_response = substr($actual_response, strpos($actual_response, "<!-- wikipage start -->") + 23); $actual_response = substr($actual_response, strpos($actual_response, 'doku.php')); $actual_response = substr($actual_response, 0, strpos($actual_response, "<!-- wikipage stop -->")); $actual_response = trim($actual_response); $actual_response = rtrim($actual_response, "</p>"); $actual_response = trim($actual_response); $expected_response = 'doku.php?id=foo:testns:start" class="wikilink1" title="foo:testns:start">testns</a> <a href="/./doku.php?id=testns:test_page17" class="wikilink1" title="testns:test_page17">test_page17</a>'; $this->assertSame($expected_response, $actual_response); // todo: this assert fails occaisionally, but not reproduciably. It then has the following oputput: <a href="/./doku.php?id=testns:start" class="wikilink2" title="testns:start" rel="nofollow">testns</a> <a href="/./doku.php?id=testns:test_page17" class="wikilink1" title="testns:test_page17">test_page17</a> $expected_file_contents = '[[testns:start]] [[testns:test_page17]]'; $start_file = file(TMP_DIR . '/data/pages/start.txt'); $actual_file_contents = $start_file[0]; $this->assertSame($expected_file_contents, $actual_file_contents); /** @var helper_plugin_move_rewrite $rewrite */ $rewrite = plugin_load('helper', 'move_rewrite'); $expected_move_meta = array('origin' => 'testns:start', 'pages' => array(array('testns:start', 'foo:testns:start')), 'media' => array()); $actual_move_media = $rewrite->getMoveMeta('foo:testns:start'); $this->assertSame($expected_move_meta, $actual_move_media); $this->assertFileExists($lockfile); }
function testINPUT() { $request = new TestRequest(); $response = $request->get(array('id' => 'mailinglist'), '/doku.php'); // output check $this->assertTrue(strpos($response->getContent(), 'Netiquette') !== false); }