IndexTest::testExecute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 5
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/**
4
 * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
16
 *
17
 * PHP version 5
18
 *
19
 * @category  Payone
20
 * @package   Payone_Magento2_Plugin
21
 * @author    FATCHIP GmbH <[email protected]>
22
 * @copyright 2003 - 2017 Payone GmbH
23
 * @license   <http://www.gnu.org/licenses/> GNU Lesser General Public License
24
 * @link      http://www.payone.de
25
 */
26
27
namespace Payone\Core\Test\Unit\Controller\Adminhtml\Orders;
28
29
use Payone\Core\Controller\Adminhtml\Orders\Index as ClassToTest;
30
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
31
use Magento\Backend\App\Action\Context;
32
use Magento\Framework\View\Result\PageFactory;
33
use Magento\Framework\View\Result\Page;
34
use Magento\Framework\View\Page\Config;
35
use Magento\Framework\View\Page\Title;
36
use Magento\Framework\AuthorizationInterface;
37
use Payone\Core\Test\Unit\BaseTestCase;
38
use Payone\Core\Model\Test\PayoneObjectManager;
39
40 View Code Duplication
class IndexTest extends BaseTestCase
0 ignored issues
show
Duplication introduced by
This class 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...
41
{
42
    /**
43
     * @var ClassToTest
44
     */
45
    private $classToTest;
46
47
    /**
48
     * @var ObjectManager|PayoneObjectManager
49
     */
50
    private $objectManager;
51
52
    protected function setUp()
53
    {
54
        $this->objectManager = $this->getObjectManager();
55
56
        $authorization = $this->getMockBuilder(AuthorizationInterface::class)->disableOriginalConstructor()->getMock();
57
        $authorization->method('isAllowed')->willReturn(true);
58
59
        $context = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
60
        $context->method('getAuthorization')->willReturn($authorization);
61
62
        $title = $this->getMockBuilder(Title::class)->disableOriginalConstructor()->getMock();
63
64
        $config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
65
        $config->method('getTitle')->willReturn($title);
66
67
        $page = $this->getMockBuilder(Page::class)
68
            ->disableOriginalConstructor()
69
            ->setMethods(['setActiveMenu', 'getConfig'])
70
            ->getMock();
71
        $page->method('getConfig')->willReturn($config);
72
73
        $resultPageFactory = $this->getMockBuilder(PageFactory::class)->disableOriginalConstructor()->getMock();
74
        $resultPageFactory->method('create')->willReturn($page);
75
76
        $this->classToTest = $this->objectManager->getObject(ClassToTest::class, [
77
            'context' => $context,
78
            'resultPageFactory' => $resultPageFactory
79
        ]);
80
    }
81
82
    public function testExecute()
83
    {
84
        $result = $this->classToTest->execute();
85
        $this->assertInstanceOf(Page::class, $result);
86
    }
87
}
88