Completed
Push — master ( 686e7c...e851ab )
by Tim
9s
created

EeBunchSubjectTest::setUp()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 37
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 22
nc 1
nop 0
1
<?php
2
3
/**
4
 * TechDivision\Import\Category\Ee\Subjects\BunchSubjectTest
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-category-ee
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Category\Ee\Subjects;
22
23
/**
24
 * Test class for the product action implementation.
25
 *
26
 * @author    Tim Wagner <[email protected]>
27
 * @copyright 2016 TechDivision GmbH <[email protected]>
28
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
 * @link      https://github.com/techdivision/import-category-ee
30
 * @link      http://www.techdivision.com
31
 */
32
class EeBunchSubjectTest extends \PHPUnit_Framework_TestCase
33
{
34
35
    /**
36
     * The subject we want to test.
37
     *
38
     * @var \TechDivision\Import\Category\Ee\Subjects\BunchSubject
39
     */
40
    protected $subject;
41
42
    /**
43
     * Sets up the fixture, for example, open a network connection.
44
     * This method is called before a test is executed.
45
     *
46
     * @return void
47
     * @see \PHPUnit_Framework_TestCase::setUp()
48
     */
49
    protected function setUp()
50
    {
51
52
        // create a mock logger
53
        $mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')
54
                           ->setMethods(get_class_methods('Psr\Log\LoggerInterface'))
55
                           ->getMock();
56
57
        // create a mock subject configuration
58
        $mockSubjectConfiguration = $this->getMockBuilder('TechDivision\Import\Configuration\SubjectConfigurationInterface')
59
                                         ->setMethods(get_class_methods('TechDivision\Import\Configuration\SubjectConfigurationInterface'))
60
                                         ->getMock();
61
62
        // create a mock registry processor
63
        $mockRegistryProcessor = $this->getMockBuilder('TechDivision\Import\Services\RegistryProcessorInterface')
64
                                      ->setMethods(get_class_methods('TechDivision\Import\Services\RegistryProcessorInterface'))
65
                                      ->getMock();
66
67
        // create a mock category processor
68
        $mockCategoryProcessor = $this->getMockBuilder('TechDivision\Import\Category\Ee\Services\EeCategoryBunchProcessorInterface')
69
                                      ->setMethods(get_class_methods('TechDivision\Import\Category\Ee\Services\EeCategoryBunchProcessorInterface'))
70
                                      ->getMock();
71
72
        // create a generator
73
        $mockGenerator = $this->getMockBuilder('TechDivision\Import\Utils\Generators\GeneratorInterface')
74
                              ->setMethods(get_class_methods('TechDivision\Import\Utils\Generators\GeneratorInterface'))
75
                              ->getMock();
76
77
        // create the subject to be tested
78
        $this->subject = new EeBunchSubject(
0 ignored issues
show
Documentation Bug introduced by
It seems like new \TechDivision\Import...$mockCategoryProcessor) of type object<TechDivision\Impo...ubjects\EeBunchSubject> is incompatible with the declared type object<TechDivision\Impo...\Subjects\BunchSubject> of property $subject.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
79
            $mockLogger,
80
            $mockSubjectConfiguration,
81
            $mockRegistryProcessor,
82
            $mockGenerator,
83
            $mockCategoryProcessor
84
        );
85
    }
86
87
    /**
88
     * Test's the persistCategory() method successfull.
89
     *
90
     * @return void
91
     */
92
    public function testPersistCategorySuccessufull()
93
    {
94
95
        // create a mock category processor
96
        $mockProcessor = $this->getMockBuilder('TechDivision\Import\Category\Ee\Services\EeCategoryBunchProcessorInterface')
97
                              ->setMethods(get_class_methods('TechDivision\Import\Category\Ee\Services\EeCategoryBunchProcessorInterface'))
98
                              ->getMock();
99
        $mockProcessor->expects($this->once())
100
                      ->method('persistCategory')
101
                      ->with($category = array('path' => '2/3/4'))
102
                      ->willReturn(null);
103
104
        // inject the processor
105
        $this->subject->setCategoryProcessor($mockProcessor);
106
107
        // make sure that the category will be persisted
108
        $this->assertNull($this->subject->persistCategory($category));
109
    }
110
}
111