ParserTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 57
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testParserMetadataException() 0 4 1
A testParser() 0 19 1
A testMetadata() 0 5 1
A testMetadataByIndex() 0 5 1
A testContent() 0 5 1
1
<?php
2
3
use Flaviozantut\Parser;
4
5
class ParserTest extends TestCase
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...
6
{
7
    /**
8
     * @expectedException Exception
9
     */
10
    public function testParserMetadataException()
11
    {
12
        $parser = new Parser('hello');
13
    }
14
15
    public function testParser()
16
    {
17
        $delimiter = Config::get('skorry.metadata_delimiter');
18
19
        $content = "$delimiter
20
type: article
21
title: \"Hello from skorry\"
22
date: 2011-07-03 5:59
23
comments: true
24
external_url:
25
tags:
26
permalink:
27
$delimiter
28
Hello";
29
        $parser = new Parser($content);
30
        $this->assertInstanceOf('Flaviozantut\Parser', $parser);
31
32
        return $parser;
33
    }
34
35
    /**
36
     * @depends testParser
37
     */
38
    public function testMetadata($parser)
39
    {
40
        $metadata = $parser->metadata();
41
        $this->assertArrayHasKey('type', $metadata);
42
    }
43
44
    /**
45
     * @depends testParser
46
     */
47
    public function testMetadataByIndex($parser)
48
    {
49
        $metadata = $parser->metadata('type');
50
        $this->assertEquals('article', $parser->metadata('type'));
51
    }
52
53
    /**
54
     * @depends testParser
55
     */
56
    public function testContent($parser)
57
    {
58
        $content = $parser->content();
59
        $this->assertEquals('<p>Hello</p>', $content);
60
    }
61
}
62