Code Duplication    Length = 19-22 lines in 3 locations

tests/Mapper/ProductMapperTest.php 3 locations

@@ 16-37 (lines=22) @@
13
     *
14
     * @test
15
     */
16
    public function getProduct_AllRequiredFieldsPresent_ValidationPasses_ProductIsReturned()
17
    {
18
        // arrange
19
        $contentMapperMock = $this->createMock(ContentMapper::class);
20
        $contentMapperMock->method("getContent")->willReturn(new Content("Title", "Summary", "..."));
21
22
        /** @var ContentMapper $contentMapperMock */
23
        $productMapper = new ProductMapper($contentMapperMock);
24
25
        $productData = array(
26
            "sku" => "a-product",
27
            "slug" => "A-Product",
28
            "title" => "Super fancy product",
29
            "summary" => "A super fancy product",
30
        );
31
32
        // act
33
        $product = $productMapper->getProduct($productData);
34
35
        // assert
36
        $this->assertNotNull($product, "getProduct() should have returned a product");
37
    }
38
39
    /**
40
     * If given product data is missing one of the mandatory fields and exception should be thrown.
@@ 69-87 (lines=19) @@
66
     * @test
67
     * @expectedException Wambo\Catalog\Error\ProductException
68
     */
69
    public function getProduct_AllRequiredFieldsPresent_SkuValidationFails_ProductIsReturned()
70
    {
71
        // arrange
72
        $contentMapperMock = $this->createMock(ContentMapper::class);
73
        $contentMapperMock->method("getContent")->willReturn(new Content("Title", "Summary", "..."));
74
75
        /** @var ContentMapper $contentMapperMock */
76
        $productMapper = new ProductMapper($contentMapperMock);
77
78
        $productData = array(
79
            "sku" => "a",
80
            "slug" => "A-Product",
81
            "title" => "Super fancy product",
82
            "summary" => "A super fancy product",
83
        );
84
85
        // act
86
        $productMapper->getProduct($productData);
87
    }
88
89
    /**
90
     * If the Slug validation fails and exception should be thrown
@@ 95-113 (lines=19) @@
92
     * @test
93
     * @expectedException Wambo\Catalog\Error\ProductException
94
     */
95
    public function getProduct_AllRequiredFieldsPresent_SlugValidationFails_ProductIsReturned()
96
    {
97
        // arrange
98
        $contentMapperMock = $this->createMock(ContentMapper::class);
99
        $contentMapperMock->method("getContent")->willReturn(new Content("Title", "A super fancy product", "..."));
100
101
        /** @var ContentMapper $contentMapperMock */
102
        $productMapper = new ProductMapper($contentMapperMock);
103
104
        $productData = array(
105
            "sku" => "a-product",
106
            "slug" => "A/Product",
107
            "title" => "Super fancy product",
108
            "summary" => "A super fancy product",
109
        );
110
111
        // act
112
        $productMapper->getProduct($productData);
113
    }
114
115
    /**
116
     * Get product data with one or more missing attributes.