Test Setup Failed
Pull Request — develop (#1)
by Andreas
04:24
created

ContentTests   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 84
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getContent_ValidSummaryAndDescriptionGiven_ContentWithSummaryAndDescriptionIsReturned() 0 12 1
A getContent_InvalidSummary_ContentExceptionIsThrown() 0 5 1
A getValidContentData() 0 14 1
A getContentWithInvalidSummary() 0 16 1
1
<?php
2
use Wambo\Catalog\Mapper\ContentMapper;
3
use Wambo\Catalog\Model\Content;
4
5
/**
6
 * Class ContentTests tests the Wambo\Catalog\Model\Content class.
7
 */
8
class ContentTests extends PHPUnit_Framework_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...
9
{
10
    /**
11
     * If the given summary and description is valid a Content model with the given summary and description should be
12
     * returned
13
     *
14
     * @test
15
     * @dataProvider getValidContentData
16
     *
17
     * @param string $summary
18
     * @param string $description
19
     */
20
    public function getContent_ValidSummaryAndDescriptionGiven_ContentWithSummaryAndDescriptionIsReturned(
21
        $summary,
22
        $description
23
    ) {
24
        // act
25
        $content = new Content($summary, $description);
26
27
        // assert
28
        $this->assertNotEmpty($content->getSummaryText(), "The summary of the content model should not be empty");
29
        $this->assertNotEmpty($content->getProductDescription(),
30
            "The description of the content model should not be empty");
31
    }
32
33
    /**
34
     * If the given summary is invalid a ContentException should be thrown
35
     *
36
     * @test
37
     * @dataProvider                   getContentWithInvalidSummary
38
     * @expectedException Wambo\Catalog\Error\ContentException
39
     * @expectedExceptionMessageRegExp /The summary text should not be (shorter|longer) than \d+ characters/
40
     *
41
     * @param string $summary
42
     * @param string $description
43
     */
44
    public function getContent_InvalidSummary_ContentExceptionIsThrown($summary, $description)
45
    {
46
        // act
47
        new Content($summary, $description);
48
    }
49
50
    /**
51
     * Get a list of valid content data for testing
52
     *
53
     * @return array
54
     */
55
    public static function getValidContentData()
56
    {
57
        return array(
58
            [
59
                "A product summary",
60
                "A detailed product description"
61
            ],
62
63
            [
64
                "ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.",
65
                "A detailed product description ..."
66
            ]
67
        );
68
    }
69
70
    /**
71
     * Get a list of valid content data for testing
72
     *
73
     * @return array
74
     */
75
    public static function getContentWithInvalidSummary()
76
    {
77
        return array(
78
            // empty
79
            ["", ""],
80
81
            // too short
82
            ["A", ""],
83
84
            // too long
85
            [
86
                "ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.ABCdefghijklmnopqrstuvwxyzöüä.",
87
                ""
88
            ]
89
        );
90
    }
91
}
92