MarkdownTest::testParseMarkdown()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
/**
3
 * Tests for the markdowntextareafield module: parser, form field, etc
4
 *
5
 * @category silverstripe
6
 * @package  markdowntextareafield
7
 * @author   Robbie Averill <[email protected]>
8
 */
9
class MarkdownTest extends SapphireTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
10
{
11
    /**
12
     * Integration-esque tests ensuring that markdown is correctly parsed to HTML
13
     *
14
     * @dataProvider markdownProvider
15
     *
16
     * @param string $markdown
17
     * @param string $expected
18
     */
19
    public function testParseMarkdown($markdown, $expected)
20
    {
21
        $parser = new MarkdownParser($markdown);
22
        $result = $parser->parse($parser);
0 ignored issues
show
Unused Code introduced by
The call to MarkdownParser::parse() has too many arguments starting with $parser.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
23
        $this->assertSame($expected, $result);
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<MarkdownTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
24
    }
25
26
    /**
27
     * @return array
28
     */
29
    public function markdownProvider()
30
    {
31
        $first = array(
32
            'This is *italic* text',
33
            '<p>This is <em>italic</em> text</p>' . PHP_EOL
34
        );
35
36
        $second = array();
37
        $second[] = <<<MARKDOWN
38
# A heading
39
40
---
41
42
* Bullet 1
43
* Bullet 2
44
* Bullet 3
45
MARKDOWN;
46
47
        $second[] = <<<EXPECTED
48
<h1>A heading</h1>
49
50
<hr />
51
52
<ul>
53
<li>Bullet 1</li>
54
<li>Bullet 2</li>
55
<li>Bullet 3</li>
56
</ul>
57
58
EXPECTED;
59
60
        return array($first, $second);
61
    }
62
}
63