|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * |
| 4 | + * @filesource ListTest.php |
| 5 | + * @created 04.03.2016 |
| 6 | + * @package chillerlan\BBCodeTest\normal\Modules\HTML5 |
| 7 | + * @author Smiley <smiley@chillerlan.net> |
| 8 | + * @copyright 2015 Smiley |
| 9 | + * @license MIT |
| 10 | + */ |
| 11 | + |
| 12 | +namespace chillerlan\BBCodeTest\normal\Modules\HTML5; |
| 13 | + |
| 14 | +/** |
| 15 | + * Class ListTest |
| 16 | + */ |
| 17 | +class ListTest extends HTML5TestBase{ |
| 18 | + |
| 19 | + const INNER_BB = '[*]blah[*]blubb[*]foo[*]bar'; |
| 20 | + const INNER_HTML = '<li>blah</li><li>blubb</li><li>foo</li><li>bar</li>'; |
| 21 | + |
| 22 | + public function orderedListDataProvider(){ |
| 23 | + return [ |
| 24 | + ['0', 'decimal-leading-zero'], |
| 25 | + ['1', 'decimal'], |
| 26 | + ['a', 'lower-alpha'], |
| 27 | + ['A', 'upper-alpha'], |
| 28 | + ['i', 'lower-roman'], |
| 29 | + ['I', 'upper-roman'], |
| 30 | + ]; |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * @dataProvider orderedListDataProvider |
| 35 | + */ |
| 36 | + public function testListModuleOrdered($type, $css){ |
| 37 | + |
| 38 | + $testdata = [ |
| 39 | + // type only |
| 40 | + '[list type='.$type.']'.self::INNER_BB.'[/list]' |
| 41 | + => '<ol class="bb-list '.$css.'">'.self::INNER_HTML.'</ol>', |
| 42 | + // reversed |
| 43 | + '[list type='.$type.' reversed=1]'.self::INNER_BB.'[/list]' |
| 44 | + => '<ol reversed="true" class="bb-list '.$css.'">'.self::INNER_HTML.'</ol>', |
| 45 | + // start |
| 46 | + '[list=42 type='.$type.']'.self::INNER_BB.'[/list]' |
| 47 | + => '<ol start="42" class="bb-list '.$css.'">'.self::INNER_HTML.'</ol>', |
| 48 | + // all |
| 49 | + '[list=42 type='.$type.' reversed=1 class=foobar title=WAT]'.self::INNER_BB.'[/list]' |
| 50 | + => '<ol start="42" reversed="true" title="WAT" class="foobar bb-list '.$css.'">'.self::INNER_HTML.'</ol>', |
| 51 | + ]; |
| 52 | + |
| 53 | + foreach($testdata as $bbcode => $expected){ |
| 54 | + $this->assertEquals($expected, $this->parser->parse($bbcode)); |
| 55 | + } |
| 56 | + |
| 57 | + } |
| 58 | + |
| 59 | + public function unorderedListDataProvider(){ |
| 60 | + return [ |
| 61 | + ['c', 'circle'], |
| 62 | + ['d', 'disc'], |
| 63 | + ['s', 'square'], |
| 64 | + ]; |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * @dataProvider unorderedListDataProvider |
| 69 | + */ |
| 70 | + public function testListModuleUnordered($type, $css){ |
| 71 | + |
| 72 | + $testdata = [ |
| 73 | + // type only |
| 74 | + '[list type='.$type.']'.self::INNER_BB.'[/list]', |
| 75 | + // should not happen... |
| 76 | + '[list=42 reversed=1 type='.$type.']'.self::INNER_BB.'[/list]', |
| 77 | + ]; |
| 78 | + |
| 79 | + foreach($testdata as $bbcode){ |
| 80 | + $this->assertEquals('<ul class="bb-list '.$css.'">'.self::INNER_HTML.'</ul>', $this->parser->parse($bbcode)); |
| 81 | + } |
| 82 | + |
| 83 | + } |
| 84 | + |
| 85 | +} |
0 commit comments