| @@ 24-117 (lines=94) @@ | ||
| 21 | * @group plugin_backlinks |
|
| 22 | * @group plugins |
|
| 23 | */ |
|
| 24 | class syntax_exclude_plugin_backlinks_test extends DokuWikiTest { |
|
| 25 | ||
| 26 | protected $pluginsEnabled = array('backlinks'); |
|
| 27 | ||
| 28 | /** |
|
| 29 | * copy data. |
|
| 30 | */ |
|
| 31 | public static function setUpBeforeClass(){ |
|
| 32 | parent::setUpBeforeClass(); |
|
| 33 | global $conf; |
|
| 34 | $conf['allowdebug'] = 1; |
|
| 35 | ||
| 36 | TestUtils::rcopy(TMP_DIR, dirname(__FILE__) . '/data/'); |
|
| 37 | ||
| 38 | dbglog("\nset up class syntax_plugin_backlinks_test"); |
|
| 39 | } |
|
| 40 | ||
| 41 | function setUp() { |
|
| 42 | parent::setUp(); |
|
| 43 | ||
| 44 | global $conf; |
|
| 45 | $conf['allowdebug'] = 1; |
|
| 46 | $conf['cachetime'] = -1; |
|
| 47 | ||
| 48 | $data = array(); |
|
| 49 | search($data, $conf['datadir'], 'search_allpages', array('skipacl' => true)); |
|
| 50 | ||
| 51 | //dbglog($data, "pages for indexing"); |
|
| 52 | ||
| 53 | $verbose = false; |
|
| 54 | $force = false; |
|
| 55 | foreach($data as $val) { |
|
| 56 | idx_addPage($val['id'], $verbose, $force); |
|
| 57 | } |
|
| 58 | ||
| 59 | if($conf['allowdebug']) { |
|
| 60 | touch(DOKU_TMP_DATA.'cache/debug.log'); |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||
| 64 | public function tearDown() { |
|
| 65 | parent::tearDown(); |
|
| 66 | ||
| 67 | global $conf; |
|
| 68 | // try to get the debug log after running the test, print and clear |
|
| 69 | if($conf['allowdebug']) { |
|
| 70 | print "\n"; |
|
| 71 | readfile(DOKU_TMP_DATA.'cache/debug.log'); |
|
| 72 | unlink(DOKU_TMP_DATA.'cache/debug.log'); |
|
| 73 | } |
|
| 74 | } |
|
| 75 | ||
| 76 | ||
| 77 | public function testExclude() { |
|
| 78 | $request = new TestRequest(); |
|
| 79 | $response = $request->get(array('id'=>'backlinks_exclude_syntax'), '/doku.php'); |
|
| 80 | ||
| 81 | ||
| 82 | ||
| 83 | $this->assertTrue( |
|
| 84 | strpos($response->getContent(), 'Backlinks to what Bob Ross says (excluding exclude namespace)') !== false, |
|
| 85 | '"Backlinks to what Bob Ross says (excluding exclude namespace)" was not in the output' |
|
| 86 | ); |
|
| 87 | ||
| 88 | $this->assertTrue( |
|
| 89 | strpos($response->getContent(), 'An excluded link to Bob Ross') == false, |
|
| 90 | '"An excluded link to Bob Ross" should not be in the output' |
|
| 91 | ); |
|
| 92 | ||
| 93 | $doc = phpQuery::newDocument($response->getContent()); |
|
| 94 | // look for id="plugin__backlinks" |
|
| 95 | $this->assertEquals( |
|
| 96 | 1, |
|
| 97 | pq('#plugin__backlinks', $doc)->length, |
|
| 98 | 'There should be one backlinks element' |
|
| 99 | ); |
|
| 100 | ||
| 101 | $wikilinks = pq('#plugin__backlinks ul li', $doc); |
|
| 102 | dbglog($wikilinks->text(), 'found backlinks'); |
|
| 103 | $this->assertEquals( |
|
| 104 | 3, |
|
| 105 | $wikilinks->contents()->length, |
|
| 106 | 'There should be 3 backlinks' |
|
| 107 | ); |
|
| 108 | ||
| 109 | $lastlink = pq('a:last',$wikilinks); |
|
| 110 | dbglog($lastlink->text(),"last backlink"); |
|
| 111 | $this->assertEquals( |
|
| 112 | 'A link to Bob Ross', |
|
| 113 | $lastlink->text(), |
|
| 114 | 'The last backlink should be "A link to Bob Ross"' |
|
| 115 | ); |
|
| 116 | } |
|
| 117 | } |
|
| 118 | ||
| @@ 24-116 (lines=93) @@ | ||
| 21 | * @group plugin_backlinks |
|
| 22 | * @group plugins |
|
| 23 | */ |
|
| 24 | class syntax_include_deep_plugin_backlinks_test extends DokuWikiTest { |
|
| 25 | ||
| 26 | protected $pluginsEnabled = array('backlinks'); |
|
| 27 | ||
| 28 | /** |
|
| 29 | * copy data. |
|
| 30 | */ |
|
| 31 | public static function setUpBeforeClass(){ |
|
| 32 | parent::setUpBeforeClass(); |
|
| 33 | global $conf; |
|
| 34 | $conf['allowdebug'] = 1; |
|
| 35 | ||
| 36 | TestUtils::rcopy(TMP_DIR, dirname(__FILE__) . '/data/'); |
|
| 37 | ||
| 38 | dbglog("\nset up class syntax_plugin_backlinks_test"); |
|
| 39 | } |
|
| 40 | ||
| 41 | function setUp() { |
|
| 42 | parent::setUp(); |
|
| 43 | ||
| 44 | global $conf; |
|
| 45 | $conf['allowdebug'] = 1; |
|
| 46 | $conf['cachetime'] = -1; |
|
| 47 | ||
| 48 | $data = array(); |
|
| 49 | search($data, $conf['datadir'], 'search_allpages', array('skipacl' => true)); |
|
| 50 | ||
| 51 | //dbglog($data, "pages for indexing"); |
|
| 52 | ||
| 53 | $verbose = false; |
|
| 54 | $force = false; |
|
| 55 | foreach($data as $val) { |
|
| 56 | idx_addPage($val['id'], $verbose, $force); |
|
| 57 | } |
|
| 58 | ||
| 59 | if($conf['allowdebug']) { |
|
| 60 | touch(DOKU_TMP_DATA.'cache/debug.log'); |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||
| 64 | public function tearDown() { |
|
| 65 | parent::tearDown(); |
|
| 66 | ||
| 67 | global $conf; |
|
| 68 | // try to get the debug log after running the test, print and clear |
|
| 69 | if($conf['allowdebug']) { |
|
| 70 | print "\n"; |
|
| 71 | readfile(DOKU_TMP_DATA.'cache/debug.log'); |
|
| 72 | unlink(DOKU_TMP_DATA.'cache/debug.log'); |
|
| 73 | } |
|
| 74 | } |
|
| 75 | ||
| 76 | public function testInclude() { |
|
| 77 | $request = new TestRequest(); |
|
| 78 | $response = $request->get(array('id'=>'mmm:nnn:ooo:start'), '/doku.php'); |
|
| 79 | ||
| 80 | $this->assertTrue( |
|
| 81 | strpos($response->getContent(), 'Backlinks from pages in /aaa/bbb/cc/') !== false, |
|
| 82 | '"Backlinks from pages in /aaa/bbb/cc/" was not in the output' |
|
| 83 | ); |
|
| 84 | ||
| 85 | $this->assertFalse( |
|
| 86 | strpos($response->getContent(), 'linking to a page form aaa') !== false, |
|
| 87 | '"linking to a page form aaa" should not be in the output' |
|
| 88 | ); |
|
| 89 | ||
| 90 | ||
| 91 | ||
| 92 | $doc = phpQuery::newDocument($response->getContent()); |
|
| 93 | // look for id="plugin__backlinks" |
|
| 94 | $this->assertEquals( |
|
| 95 | 1, |
|
| 96 | pq('#plugin__backlinks', $doc)->length, |
|
| 97 | 'There should be one backlinks element' |
|
| 98 | ); |
|
| 99 | ||
| 100 | $wikilinks = pq('#plugin__backlinks ul li', $doc); |
|
| 101 | dbglog($wikilinks->text(), 'found backlinks'); |
|
| 102 | $this->assertEquals( |
|
| 103 | 5, |
|
| 104 | $wikilinks->contents()->length, |
|
| 105 | 'There should be 5 backlinks' |
|
| 106 | ); |
|
| 107 | ||
| 108 | $lastlink = pq('a:last',$wikilinks); |
|
| 109 | dbglog($lastlink->text(),"last backlink"); |
|
| 110 | $this->assertEquals( |
|
| 111 | $lastlink->text(), |
|
| 112 | 'linking to a namespace', |
|
| 113 | 'The last backlink should be "linking to a namespace"' |
|
| 114 | ); |
|
| 115 | } |
|
| 116 | } |
|
| 117 | ||