[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/_test/tests/inc/parser/ -> parser_quotes.test.php (source)

   1  <?php
   2  
   3  use dokuwiki\Parsing\ParserMode\Quotes;
   4  
   5  require_once  'parser.inc.php';
   6  
   7  class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
   8  
   9      function setUp() {
  10          parent::setUp();
  11          global $conf;
  12          $conf['typography'] = 2;
  13      }
  14  
  15      function testSingleQuoteOpening() {
  16          $raw = "Foo 'hello Bar";
  17          $this->P->addMode('quotes',new Quotes());
  18          $this->P->parse($raw);
  19  
  20          $calls = array (
  21              array('document_start',array()),
  22              array('p_open',array()),
  23              array('cdata',array("\n".'Foo ')),
  24              array('singlequoteopening',array()),
  25              array('cdata',array('hello Bar')),
  26              array('p_close',array()),
  27              array('document_end',array()),
  28          );
  29  
  30          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
  31      }
  32  
  33      function testSingleQuoteOpeningSpecial() {
  34          $raw = "Foo said:'hello Bar";
  35          $this->P->addMode('quotes',new Quotes());
  36          $this->P->parse($raw);
  37  
  38          $calls = array (
  39              array('document_start',array()),
  40              array('p_open',array()),
  41              array('cdata',array("\n".'Foo said:')),
  42              array('singlequoteopening',array()),
  43              array('cdata',array('hello Bar')),
  44              array('p_close',array()),
  45              array('document_end',array()),
  46          );
  47  
  48          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
  49      }
  50  
  51      function testSingleQuoteClosing() {
  52          $raw = "Foo hello' Bar";
  53          $this->P->addMode('quotes',new Quotes());
  54          $this->P->parse($raw);
  55  
  56          $calls = array (
  57              array('document_start',array()),
  58              array('p_open',array()),
  59              array('cdata',array("\n".'Foo hello')),
  60              array('singlequoteclosing',array()),
  61              array('cdata',array(' Bar')),
  62              array('p_close',array()),
  63              array('document_end',array()),
  64          );
  65  
  66          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
  67      }
  68  
  69      function testSingleQuoteClosingSpecial() {
  70          $raw = "Foo hello') Bar";
  71          $this->P->addMode('quotes',new Quotes());
  72          $this->P->parse($raw);
  73  
  74          $calls = array (
  75              array('document_start',array()),
  76              array('p_open',array()),
  77              array('cdata',array("\n".'Foo hello')),
  78              array('singlequoteclosing',array()),
  79              array('cdata',array(') Bar')),
  80              array('p_close',array()),
  81              array('document_end',array()),
  82          );
  83  
  84          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
  85      }
  86  
  87      function testSingleQuotes() {
  88          $raw = "Foo 'hello' Bar";
  89          $this->P->addMode('quotes',new Quotes());
  90          $this->P->parse($raw);
  91  
  92          $calls = array (
  93              array('document_start',array()),
  94              array('p_open',array()),
  95              array('cdata',array("\n".'Foo ')),
  96              array('singlequoteopening',array()),
  97              array('cdata',array('hello')),
  98              array('singlequoteclosing',array()),
  99              array('cdata',array(' Bar')),
 100              array('p_close',array()),
 101              array('document_end',array()),
 102          );
 103  
 104          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
 105      }
 106  
 107      function testApostrophe() {
 108          $raw = "hey it's fine weather today";
 109          $this->P->addMode('quotes',new Quotes());
 110          $this->P->parse($raw);
 111  
 112          $calls = array (
 113              array('document_start',array()),
 114              array('p_open',array()),
 115              array('cdata',array("\n".'hey it')),
 116              array('apostrophe',array()),
 117              array('cdata',array('s fine weather today')),
 118              array('p_close',array()),
 119              array('document_end',array()),
 120          );
 121  
 122          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
 123      }
 124  
 125  
 126      function testSingleQuotesSpecial() {
 127          $raw = "Foo ('hello') Bar";
 128          $this->P->addMode('quotes',new Quotes());
 129          $this->P->parse($raw);
 130  
 131          $calls = array (
 132              array('document_start',array()),
 133              array('p_open',array()),
 134              array('cdata',array("\n".'Foo (')),
 135              array('singlequoteopening',array()),
 136              array('cdata',array('hello')),
 137              array('singlequoteclosing',array()),
 138              array('cdata',array(') Bar')),
 139              array('p_close',array()),
 140              array('document_end',array()),
 141          );
 142  
 143          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
 144      }
 145  
 146      function testDoubleQuoteOpening() {
 147          $raw = 'Foo "hello Bar';
 148          $this->P->addMode('quotes',new Quotes());
 149          $this->P->parse($raw);
 150  
 151          $calls = array (
 152              array('document_start',array()),
 153              array('p_open',array()),
 154              array('cdata',array("\n".'Foo ')),
 155              array('doublequoteopening',array()),
 156              array('cdata',array('hello Bar')),
 157              array('p_close',array()),
 158              array('document_end',array()),
 159          );
 160  
 161          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
 162      }
 163  
 164      function testDoubleQuoteOpeningSpecial() {
 165          $raw = 'Foo said:"hello Bar';
 166          $this->P->addMode('quotes',new Quotes());
 167          $this->P->parse($raw);
 168  
 169          $calls = array (
 170              array('document_start',array()),
 171              array('p_open',array()),
 172              array('cdata',array("\n".'Foo said:')),
 173              array('doublequoteopening',array()),
 174              array('cdata',array('hello Bar')),
 175              array('p_close',array()),
 176              array('document_end',array()),
 177          );
 178  
 179          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
 180      }
 181  
 182      function testDoubleQuoteClosing() {
 183          $raw = 'Foo hello" Bar';
 184          $this->P->addMode('quotes',new Quotes());
 185  
 186          /** @noinspection PhpUnhandledExceptionInspection */
 187          $status = $this->getInaccessibleProperty($this->H, 'status');
 188          $status['doublequote'] = 1;
 189          /** @noinspection PhpUnhandledExceptionInspection */
 190          $this->setInaccessibleProperty($this->H, 'status', $status);
 191          $this->P->parse($raw);
 192  
 193          $calls = array (
 194              array('document_start',array()),
 195              array('p_open',array()),
 196              array('cdata',array("\n".'Foo hello')),
 197              array('doublequoteclosing',array()),
 198              array('cdata',array(' Bar')),
 199              array('p_close',array()),
 200              array('document_end',array()),
 201          );
 202  
 203          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
 204      }
 205  
 206      function testDoubleQuoteClosingSpecial() {
 207          $raw = 'Foo hello") Bar';
 208          $this->P->addMode('quotes',new Quotes());
 209          /** @noinspection PhpUnhandledExceptionInspection */
 210          $status = $this->getInaccessibleProperty($this->H, 'status');
 211          $status['doublequote'] = 1;
 212          /** @noinspection PhpUnhandledExceptionInspection */
 213          $this->setInaccessibleProperty($this->H, 'status', $status);
 214  
 215          $this->P->parse($raw);
 216  
 217          $calls = array (
 218              array('document_start',array()),
 219              array('p_open',array()),
 220              array('cdata',array("\n".'Foo hello')),
 221              array('doublequoteclosing',array()),
 222              array('cdata',array(') Bar')),
 223              array('p_close',array()),
 224              array('document_end',array()),
 225          );
 226  
 227          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
 228      }
 229      function testDoubleQuoteClosingSpecial2() {
 230          $raw = 'Foo hello") Bar';
 231          $this->P->addMode('quotes',new Quotes());
 232          /** @noinspection PhpUnhandledExceptionInspection */
 233          $status = $this->getInaccessibleProperty($this->H, 'status');
 234          $status['doublequote'] = 0;
 235          /** @noinspection PhpUnhandledExceptionInspection */
 236          $this->setInaccessibleProperty($this->H, 'status', $status);
 237  
 238          $this->P->parse($raw);
 239  
 240          $calls = array (
 241              array('document_start',array()),
 242              array('p_open',array()),
 243              array('cdata',array("\n".'Foo hello')),
 244              array('doublequoteopening',array()),
 245              array('cdata',array(') Bar')),
 246              array('p_close',array()),
 247              array('document_end',array()),
 248          );
 249  
 250          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
 251      }
 252  
 253      function testDoubleQuotes() {
 254          $raw = 'Foo "hello" Bar';
 255          $this->P->addMode('quotes',new Quotes());
 256          $this->P->parse($raw);
 257  
 258          $calls = array (
 259              array('document_start',array()),
 260              array('p_open',array()),
 261              array('cdata',array("\n".'Foo ')),
 262              array('doublequoteopening',array()),
 263              array('cdata',array('hello')),
 264              array('doublequoteclosing',array()),
 265              array('cdata',array(' Bar')),
 266              array('p_close',array()),
 267              array('document_end',array()),
 268          );
 269  
 270          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
 271      }
 272  
 273      function testDoubleQuotesSpecial() {
 274          $raw = 'Foo ("hello") Bar';
 275          $this->P->addMode('quotes',new Quotes());
 276          $this->P->parse($raw);
 277  
 278          $calls = array (
 279              array('document_start',array()),
 280              array('p_open',array()),
 281              array('cdata',array("\n".'Foo (')),
 282              array('doublequoteopening',array()),
 283              array('cdata',array('hello')),
 284              array('doublequoteclosing',array()),
 285              array('cdata',array(') Bar')),
 286              array('p_close',array()),
 287              array('document_end',array()),
 288          );
 289  
 290          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw);
 291      }
 292  
 293      function testDoubleQuotesEnclosingBrackets() {
 294          $raw = 'Foo "{hello}" Bar';
 295          $this->P->addMode('quotes',new Quotes());
 296          $this->P->parse($raw);
 297  
 298          $calls = array (
 299              array('document_start',array()),
 300              array('p_open',array()),
 301              array('cdata',array("\n".'Foo ')),
 302              array('doublequoteopening',array()),
 303              array('cdata',array('{hello}')),
 304              array('doublequoteclosing',array()),
 305              array('cdata',array(' Bar')),
 306              array('p_close',array()),
 307              array('document_end',array()),
 308          );
 309  
 310          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls,'wikitext - '.$raw);
 311      }
 312  
 313      function testDoubleQuotesEnclosingLink() {
 314          $raw = 'Foo "[[www.domain.com]]" Bar';
 315          $this->P->addMode('quotes',new Quotes());
 316          $this->P->parse($raw);
 317  
 318          $calls = array (
 319              array('document_start',array()),
 320              array('p_open',array()),
 321              array('cdata',array("\n".'Foo ')),
 322              array('doublequoteopening',array()),
 323              array('cdata',array('[[www.domain.com]]')),
 324              array('doublequoteclosing',array()),
 325              array('cdata',array(' Bar')),
 326              array('p_close',array()),
 327              array('document_end',array()),
 328          );
 329  
 330          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls,'wikitext => '.$raw);
 331      }
 332  
 333  
 334      function testAllQuotes() {
 335          $raw = 'There was written "He thought \'It\'s a man\'s world\'".';
 336          $this->P->addMode('quotes',new Quotes());
 337          $this->P->parse($raw);
 338  
 339          $calls = array (
 340              array('document_start',array()),
 341              array('p_open',array()),
 342              array('cdata',array("\n".'There was written ')),
 343              array('doublequoteopening',array()),
 344              array('cdata',array('He thought ')),
 345              array('singlequoteopening',array()),
 346              array('cdata',array('It')),
 347              array('apostrophe',array()),
 348              array('cdata',array('s a man')),
 349              array('apostrophe',array()),
 350              array('cdata',array('s world')),
 351              array('singlequoteclosing',array()),
 352              array('doublequoteclosing',array()),
 353              array('cdata',array(".")),
 354              array('p_close',array()),
 355              array('document_end',array()),
 356          );
 357  
 358          $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls,'wikitext => '.$raw);
 359      }
 360  
 361  }
 362