1<?php
2
3require_once(__DIR__ . '/../webcomponent.php');
4/**
5 * Test the component plugin
6 *
7 * @group plugin_webcomponent
8 * @group plugins
9 */
10class plugin_webcomponent_teaser_test extends DokuWikiTest
11{
12
13    protected $pluginsEnabled = [webcomponent::PLUGIN_NAME];
14
15
16    public function test_component_name() {
17
18        $componentName = syntax_plugin_webcomponent_card::getTag();
19
20        $this->assertEquals('card', $componentName);
21
22    }
23
24    public function test_base() {
25
26        $componentName = syntax_plugin_webcomponent_card::getTag();
27        $doku_text = '<'. $componentName .' style="width: 18rem;">'.DOKU_LF.
28            '{{:allowclipboardhelper.jpg?30|}}'.DOKU_LF.
29            '=== Teaser Title ==='.DOKU_LF.
30            'A example taken from [[https://getbootstrap.com/docs/4.3/components/card/#example|the bootstrap quick example]] on how to build a card title in order to make up the bulk of the teaser content.'.DOKU_LF.
31            '</'.$componentName.'>';
32
33        $info = array();
34
35        $instructions = p_get_instructions($doku_text);
36        $xhtml = p_render('xhtml', $instructions, $info);
37
38        $expected = '<div class="card" style="width: 18rem;">'.DOKU_LF.
39                    DOKU_TAB.'<img class="card-img-top" src="/./lib/exe/fetch.php?w=30&amp;tok=029902&amp;media=allowclipboardhelper.jpg" alt="" width="30">'.DOKU_LF.
40                    DOKU_TAB.'<div class="card-body">'.DOKU_LF.
41                    DOKU_TAB.DOKU_TAB.'<h4 class="card-title">Teaser Title</h4>'.DOKU_LF.
42                    DOKU_TAB.DOKU_TAB.'<p class="card-text">A example taken from <a href="https://getbootstrap.com/docs/4.3/components/card/#example" class="urlextern" title="https://getbootstrap.com/docs/4.3/components/card/#example" rel="nofollow">the bootstrap quick example</a> on how to build a card title in order to make up the bulk of the teaser content.</p>'.DOKU_LF.
43                    DOKU_TAB.'</div>'.DOKU_LF.
44                    '</div>'.DOKU_LF;
45
46
47        $this->assertEquals($expected, $xhtml);
48
49    }
50
51    public function test_two_teaser() {
52
53        $componentName = syntax_plugin_webcomponent_card::getTag();
54        $doku_text = '<'. $componentName .' style="width: 18rem;">'.DOKU_LF.
55            '{{:allowclipboardhelper.jpg?30|}}'.DOKU_LF.
56            '=== Teaser Title ==='.DOKU_LF.
57            'A example taken from [[https://getbootstrap.com/docs/4.3/components/card/#example|the bootstrap quick example]] on how to build a card title in order to make up the bulk of the teaser content.'.DOKU_LF.
58            '</'.$componentName.'>'.DOKU_LF;
59
60
61
62        $expected = '<div class="card" style="width: 18rem;">'.DOKU_LF.
63            DOKU_TAB.'<img class="card-img-top" src="/./lib/exe/fetch.php?w=30&amp;tok=029902&amp;media=allowclipboardhelper.jpg" alt="" width="30">'.DOKU_LF.
64            DOKU_TAB.'<div class="card-body">'.DOKU_LF.
65            DOKU_TAB.DOKU_TAB.'<h4 class="card-title">Teaser Title</h4>'.DOKU_LF.
66            DOKU_TAB.DOKU_TAB.'<p class="card-text">A example taken from <a href="https://getbootstrap.com/docs/4.3/components/card/#example" class="urlextern" title="https://getbootstrap.com/docs/4.3/components/card/#example" rel="nofollow">the bootstrap quick example</a> on how to build a card title in order to make up the bulk of the teaser content.</p>'.DOKU_LF.
67            DOKU_TAB.'</div>'.DOKU_LF.
68            '</div>'.DOKU_LF;
69
70        $instructions = p_get_instructions($doku_text.$doku_text);
71        $xhtml = p_render('xhtml', $instructions, $info);
72        $this->assertEquals($expected.$expected, $xhtml);
73
74    }
75
76
77
78
79
80}
81