1<?php 2 3require_once(__DIR__ . '/../webcomponent.php'); 4 5 6 7/** 8 * Test the component plugin 9 * 10 * @group plugin_webcomponent 11 * @group plugins 12 */ 13class plugin_webcomponent_js_test extends DokuWikiTest 14{ 15 16 protected $pluginsEnabled = [webcomponent::PLUGIN_NAME]; 17 18 19 /** 20 * 21 * Should not work 22 * Test is only manual with the browser by hitting 23 * http://localhost:81/lib/exe/js.php?t=dokuwiki 24 * 25 */ 26 public function test_base() 27 { 28 29 $message = ""; 30 try { 31 $request = new TestRequest(); 32 $request->get(array('t' => 'dokuwiki'), '/lib/exe/js.php'); 33 } catch (Exception $e) { 34 $message = $e->getMessage(); 35 } 36 $this->assertEquals("/lib/exe/js.php \n--- only /doku.php, /lib/exe/fetch.php, /lib/exe/detail.php, /lib/exe/ajax.php are supported currently",$message); 37 38 } 39 40 /** 41 * Add a query string to make a difference between public and editor 42 */ 43 public function test_js_show_query_string() 44 { 45 46 $test_name = 'test_js_show_query_string'; 47 $pageId = webcomponent::getNameSpace() . $test_name; 48 $doku_text = 'whatever'; 49 saveWikiText($pageId, $doku_text, $test_name); 50 idx_addPage($pageId); 51 $testRequest = new TestRequest(); 52 $testResponse = $testRequest->get(array('id' => $pageId)); 53 $jsSrcAttribute = $testResponse->queryHTML('script[src*="js.php"]' )->attr('src'); 54 $pos = strpos($jsSrcAttribute,action_plugin_webcomponent_js::ACCESS.'=public'); 55 $this->assertEquals(true, $pos > 0); 56 57 58 } 59 60 61} 62