Completed
Push — master ( 974531...773161 )
by Asif
02:14
created

ShortcodeRegistrationTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 34
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testInstance() 0 4 1
A testRegistrationAndCompileShortcode() 0 10 1
1
<?php namespace Webwizo\Shortcodes;
2
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
36
}