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

ContentTests::getValidContentData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
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