1<?php 2 3/** 4 * General tests for the ifauthex plugin 5 * 6 * @group plugin_ifauthex 7 * @group plugins 8 */ 9class instructions_plugin_ifauthex_test extends DokuWikiTest 10{ 11 12 protected $pluginsEnabled = array('ifauthex'); 13 14 15 public function test_instructions() 16 { 17 18 $calls = p_get_instructions(file_get_contents(__DIR__.'/test_page.txt')); 19 20 $calls = array_map([self::class, 'stripByteIndex'], $calls); 21 22 $this->assertJsonStringEqualsJsonFile(__DIR__.'/test_page.json', json_encode($calls)); 23 24 //print_r(json_encode($calls)); 25 } 26 27 public function test_nested_instructions() 28 { 29 30 $calls = p_get_instructions(file_get_contents(__DIR__.'/test_nested.txt')); 31 32 $calls = array_map([self::class, 'stripByteIndex'], $calls); 33 34 $this->assertJsonStringEqualsJsonFile(__DIR__.'/test_nested.json', json_encode($calls)); 35 36 // print_r(json_encode($calls)); 37 } 38 39 public function test_header() 40 { 41 42 $info = array(); 43 $calls = p_get_instructions(file_get_contents(__DIR__.'/test_hidden_first_header.txt')); 44 $xhtml = p_render('xhtml', $calls, $info); 45 46 $doc = new DOMDocument(); 47 $this->assertTrue($doc->loadHTML($xhtml)); 48 49 $calls = p_get_instructions(file_get_contents(__DIR__.'/test_visible_first_header.txt')); 50 $xhtml = p_render('xhtml', $calls, $info); 51 52 $doc = new DOMDocument(); 53 $this->assertTrue($doc->loadHTML($xhtml)); 54 } 55 56 /** 57 * copied from the core test suite, removes the byte positions 58 * 59 * @param $call 60 * @return mixed 61 */ 62 public static function stripByteIndex($call) { 63 unset($call[2]); 64 if ($call[0] == "nest") { 65 $call[1][0] = array_map('stripByteIndex',$call[1][0]); 66 } 67 return $call; 68 } 69} 70