Completed
Push — develop ( bbf1d7...d89cb9 )
by Tom
05:51
created

MagentoHelperTest::detectMagentoInModmanInfrastructure()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 28
rs 8.8571
cc 1
eloc 14
nc 1
nop 0
1
<?php
2
3
namespace N98\Util\Console\Helper;
4
5
use N98\Magento\Command\PHPUnit\TestCase;
6
use org\bovigo\vfs\vfsStream;
7
8
class MagentoHelper extends TestCase
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type N98\Util\Console\Helper\MagentoHelper has been defined more than once; this definition is ignored, only the first definition in src/N98/Util/Console/Helper/MagentoHelper.php (L22-428) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
9
{
10
    /**
11
     * @return MagentoHelper
12
     */
13
    protected function getHelper()
14
    {
15
        $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
0 ignored issues
show
Bug introduced by
The method getMock() does not seem to exist on object<N98\Util\Console\Helper\MagentoHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
16
        $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
0 ignored issues
show
Bug introduced by
The method getMock() does not seem to exist on object<N98\Util\Console\Helper\MagentoHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
17
18
        return new MagentoHelper($inputMock, $outputMock);
19
    }
20
21
    /**
22
     * @test
23
     */
24
    public function testHelperInstance()
25
    {
26
        $this->assertInstanceOf('\N98\Util\Console\Helper\MagentoHelper', $this->getHelper());
0 ignored issues
show
Bug introduced by
The method getHelper() does not exist on N98\Util\Console\Helper\MagentoHelper. Did you maybe mean getHelperSet()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<N98\Util\Console\Helper\MagentoHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
    }
28
29
    /**
30
     * @test
31
     */
32
    public function detectMagentoInStandardFolder()
33
    {
34
        vfsStream::setup('root');
35
        vfsStream::create(
36
            array(
37
                'app' => array(
38
                    'Mage.php' => '',
39
                ),
40
            )
41
        );
42
43
        $helper = $this->getHelper();
0 ignored issues
show
Bug introduced by
The method getHelper() does not exist on N98\Util\Console\Helper\MagentoHelper. Did you maybe mean getHelperSet()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
44
        $helper->detect(vfsStream::url('root'), array());
45
46
        $this->assertEquals(vfsStream::url('root'), $helper->getRootFolder());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<N98\Util\Console\Helper\MagentoHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
        $this->assertEquals(\N98\Magento\Application::MAGENTO_MAJOR_VERSION_1, $helper->getMajorVersion());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<N98\Util\Console\Helper\MagentoHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
    }
49
50
    /**
51
     * @test
52
     */
53 View Code Duplication
    public function detectMagentoInHtdocsSubfolder()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
    {
55
        vfsStream::setup('root');
56
        vfsStream::create(
57
            array(
58
                'htdocs' => array(
59
                    'app' => array(
60
                        'Mage.php' => '',
61
                    ),
62
                ),
63
            )
64
        );
65
66
        $helper = $this->getHelper();
0 ignored issues
show
Bug introduced by
The method getHelper() does not exist on N98\Util\Console\Helper\MagentoHelper. Did you maybe mean getHelperSet()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
67
68
        // vfs cannot resolve relative path so we do 'root/htdocs' etc.
69
        $helper->detect(
70
            vfsStream::url('root'),
71
            array(
72
                vfsStream::url('root/www'),
73
                vfsStream::url('root/public'),
74
                vfsStream::url('root/htdocs'),
75
            )
76
        );
77
78
        $this->assertEquals(vfsStream::url('root/htdocs'), $helper->getRootFolder());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<N98\Util\Console\Helper\MagentoHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
79
        $this->assertEquals(\N98\Magento\Application::MAGENTO_MAJOR_VERSION_1, $helper->getMajorVersion());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<N98\Util\Console\Helper\MagentoHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
80
    }
81
82
    /**
83
     * @test
84
     */
85
    public function detectMagentoFailed()
86
    {
87
        vfsStream::setup('root');
88
        vfsStream::create(
89
            array(
90
                'htdocs' => array(),
91
            )
92
        );
93
94
        $helper = $this->getHelper();
0 ignored issues
show
Bug introduced by
The method getHelper() does not exist on N98\Util\Console\Helper\MagentoHelper. Did you maybe mean getHelperSet()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
95
96
        // vfs cannot resolve relative path so we do 'root/htdocs' etc.
97
        $helper->detect(
98
            vfsStream::url('root')
99
        );
100
101
        $this->assertNull($helper->getRootFolder());
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<N98\Util\Console\Helper\MagentoHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
102
    }
103
104
    /**
105
     * @test
106
     */
107
    public function detectMagentoInModmanInfrastructure()
108
    {
109
        vfsStream::setup('root');
110
        vfsStream::create(
111
            array(
112
                '.basedir' => 'root/htdocs/magento_root',
113
                'htdocs'   => array(
114
                    'magento_root' => array(
115
                        'app' => array(
116
                            'Mage.php' => '',
117
                        ),
118
                    ),
119
                ),
120
            )
121
        );
122
123
        $helper = $this->getHelper();
0 ignored issues
show
Bug introduced by
The method getHelper() does not exist on N98\Util\Console\Helper\MagentoHelper. Did you maybe mean getHelperSet()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
124
125
        // vfs cannot resolve relative path so we do 'root/htdocs' etc.
126
        $helper->detect(
127
            vfsStream::url('root')
128
        );
129
130
        // Verify if this could be checked with more elegance
131
        $this->assertEquals(vfsStream::url('root/../root/htdocs/magento_root'), $helper->getRootFolder());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<N98\Util\Console\Helper\MagentoHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
132
133
        $this->assertEquals(\N98\Magento\Application::MAGENTO_MAJOR_VERSION_1, $helper->getMajorVersion());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<N98\Util\Console\Helper\MagentoHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
134
    }
135
136
    /**
137
     * @test
138
     */
139 View Code Duplication
    public function detectMagento2InHtdocsSubfolder()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
140
    {
141
        vfsStream::setup('root');
142
        vfsStream::create(
143
            array(
144
                'htdocs' => array(
145
                    'app' => array(
146
                        'autoload.php'  => '',
147
                        'bootstrap.php' => '',
148
                    ),
149
                ),
150
            )
151
        );
152
153
        $helper = $this->getHelper();
0 ignored issues
show
Bug introduced by
The method getHelper() does not exist on N98\Util\Console\Helper\MagentoHelper. Did you maybe mean getHelperSet()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
154
155
        // vfs cannot resolve relative path so we do 'root/htdocs' etc.
156
        $helper->detect(
157
            vfsStream::url('root'),
158
            array(
159
                vfsStream::url('root/www'),
160
                vfsStream::url('root/public'),
161
                vfsStream::url('root/htdocs'),
162
            )
163
        );
164
165
        $this->assertEquals(vfsStream::url('root/htdocs'), $helper->getRootFolder());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<N98\Util\Console\Helper\MagentoHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
166
        $this->assertEquals(\N98\Magento\Application::MAGENTO_MAJOR_VERSION_2, $helper->getMajorVersion());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<N98\Util\Console\Helper\MagentoHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
167
    }
168
}
169