1 | <?php namespace Webwizo\Shortcodes; |
||
3 | class ShortcodeRegistrationTest extends TestCase |
||
4 | { |
||
5 | |||
6 | protected $string = '[b class="bold"]Bold Text[/b]'; |
||
7 | |||
8 | protected $compiled = '<strong class="bold">Bold Text</strong>'; |
||
9 | |||
10 | /** |
||
11 | * Setup the test environment. |
||
12 | */ |
||
13 | public function setUp() |
||
14 | { |
||
15 | parent::setUp(); |
||
16 | $this->shortcode = app()->make('shortcode'); |
||
17 | } |
||
18 | |||
19 | public function testInstance() |
||
20 | { |
||
21 | $this->assertInstanceOf(\Webwizo\Shortcodes\Shortcode::class, $this->shortcode); |
||
22 | } |
||
23 | |||
24 | public function testRegistrationAndCompileShortcode() |
||
25 | { |
||
26 | $this->shortcode->register('b', function ($shortcode, $content) { |
||
27 | return sprintf('<strong class="%s">%s</strong>', $shortcode->class, $content); |
||
28 | }); |
||
29 | |||
30 | $compiled = $this->shortcode->compile($this->string); |
||
31 | |||
32 | $this->assertEquals($this->compiled, $compiled); |
||
33 | } |
||
34 | } |
||
35 |