1<?php 2/** 3 * @group plugin_datepicker 4 * @group plugins 5 */ 6class plugin_datepicker_syntax_test extends DokuWikiTest { 7 8 protected $plugin; 9 public function setup() { 10 $this->pluginsEnabled[] = 'datepicker'; 11 $this->pluginsEnabled[] = 'ajaxedit'; 12 parent::setup(); 13 $this->plugin = plugin_load('action', 'datepicker'); 14 } 15 16 17 public function test_basic_datepicker_empty_syntax() { 18 global $INFO; 19 $id = 'test:plugin_datepicker:syntax'; 20 $INFO['id'] = $id; 21 saveWikiText($id, 22 '<datepicker>'.DOKU_LF. 23 '<datepicker#>'.DOKU_LF. 24 '<datepicker\\>'.DOKU_LF 25 ,'test'); 26 27 $xhtml = p_wiki_xhtml($id); 28 $doc = phpQuery::newDocument($xhtml); 29 30 $mselector = pq("span.datepicker",$doc); 31 $this->assertTrue($mselector->length === 0); 32 $mselector = pq("p",$doc); 33 $this->assertTrue($mselector->length === 1); 34 $this->assertEquals( 35 $this->plugin->getConf('emptyStringDate').DOKU_LF. 36 $this->plugin->getConf('emptyStringDate').DOKU_LF. 37 $this->plugin->getConf('emptyStringDate'),trim($mselector->eq(0)->text())); 38 39 40 $INFO['perm'] = AUTH_EDIT; 41 $xhtml = p_wiki_xhtml($id); 42 $doc = phpQuery::newDocument($xhtml); 43 44 $mselector = pq("span.datepicker",$doc); 45 $this->assertTrue($mselector->length === 3); 46 $this->assertEquals($this->plugin->getConf('emptyStringDate'), trim($mselector->eq(0)->text())); 47 $this->assertEquals($this->plugin->getConf('emptyStringDate'), trim($mselector->eq(1)->text())); 48 $this->assertEquals($this->plugin->getConf('emptyStringDate'), trim($mselector->eq(2)->text())); 49 } 50 51 public function test_basic_weekpicker_empty_syntax() { 52 global $INFO; 53 $id = 'test:plugin_datepicker:syntax2'; 54 $INFO['id'] = $id; 55 saveWikiText($id, 56 '<weekpicker>'.DOKU_LF. 57 '<weekpicker#>'.DOKU_LF. 58 '<weekpicker\\>'.DOKU_LF 59 ,'test'); 60 61 $xhtml = p_wiki_xhtml($id); 62 $doc = phpQuery::newDocument($xhtml); 63 64 $mselector = pq("span.weekpicker",$doc); 65 $this->assertTrue($mselector->length === 0); 66 $mselector = pq("p",$doc); 67 $this->assertTrue($mselector->length === 1); 68 $this->assertEquals( 69 $this->plugin->getConf('emptyStringWeek').DOKU_LF. 70 $this->plugin->getConf('emptyStringWeek').DOKU_LF. 71 $this->plugin->getConf('emptyStringWeek'),trim($mselector->eq(0)->text())); 72 73 $INFO['perm'] = AUTH_EDIT; 74 $xhtml = p_wiki_xhtml($id); 75 $doc = phpQuery::newDocument($xhtml); 76 77 $mselector = pq("span.weekpicker",$doc); 78 $this->assertTrue($mselector->length === 3); 79 $this->assertEquals($this->plugin->getConf('emptyStringWeek'), trim($mselector->eq(0)->text())); 80 $this->assertEquals($this->plugin->getConf('emptyStringWeek'), trim($mselector->eq(1)->text())); 81 $this->assertEquals($this->plugin->getConf('emptyStringWeek'), trim($mselector->eq(2)->text())); 82 } 83 public function test_basic_datepicker_syntax() { 84 global $INFO; 85 $INFO['perm'] = AUTH_EDIT; 86 $id = 'test:plugin_datepicker:syntax3'; 87 $INFO['id'] = $id; 88 saveWikiText($id, 89 '<datepicker 2014-02-01>'.DOKU_LF. 90 '<datepicker# 2014-02-01>'.DOKU_LF. 91 '<datepicker\\ 2014-02-01>'.DOKU_LF 92 ,'test'); 93 94 $xhtml = p_wiki_xhtml($id); 95 $doc = phpQuery::newDocument($xhtml); 96 97 $mselector = pq("span.datepicker",$doc); 98 $this->assertTrue($mselector->length === 3); 99 $this->assertEquals('2014-02-01',trim($mselector->eq(0)->text())); 100 $this->assertEquals('2014-02-01',trim($mselector->eq(1)->text())); 101 $this->assertEquals('2014-02-01',trim($mselector->eq(2)->text())); 102 } 103 104 public function test_basic_weekpicker_syntax() { 105 global $INFO; 106 $INFO['perm'] = AUTH_EDIT; 107 $id = 'test:plugin_datepicker:syntax4'; 108 $INFO['id'] = $id; 109 saveWikiText($id, 110 '<weekpicker 14/02>'.DOKU_LF. 111 '<weekpicker# 14/02>'.DOKU_LF. 112 '<weekpicker\\ 14/02>'.DOKU_LF 113 ,'test'); 114 115 $xhtml = p_wiki_xhtml($id); 116 $doc = phpQuery::newDocument($xhtml); 117 118 $mselector = pq("span.weekpicker",$doc); 119 $this->assertTrue($mselector->length === 3); 120 $this->assertEquals('14/02',trim($mselector->eq(0)->text())); 121 $this->assertEquals('14/02',trim($mselector->eq(1)->text())); 122 $this->assertEquals('14/02',trim($mselector->eq(2)->text())); 123 } 124 125} 126