Completed
Push — master ( fe4d16...77dac1 )
by Florian
26:03
created

ViewTest::setUp()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 21

Duplication

Lines 31
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 31
loc 31
rs 8.8571
cc 1
eloc 21
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\Block\Adminhtml\Protocol\Transactionstatus;
28
29
use Payone\Core\Block\Adminhtml\Protocol\Transactionstatus\View as ClassToTest;
30
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
31
use Payone\Core\Model\Entities\TransactionStatusFactory;
32
use Payone\Core\Model\Entities\TransactionStatus;
33
use Magento\Framework\App\RequestInterface;
34
use Magento\Backend\Block\Widget\Context;
35
use Magento\Backend\Block\Widget\Button\ButtonList;
36
use Magento\Framework\UrlInterface;
37
38 View Code Duplication
class ViewTest extends \PHPUnit_Framework_TestCase
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...
39
{
40
    /**
41
     * @var ClassToTest
42
     */
43
    private $classToTest;
44
45
    /**
46
     * @var ObjectManager
47
     */
48
    private $objectManager;
49
50
    protected function setUp()
51
    {
52
        $this->objectManager = new ObjectManager($this);
53
54
        $status = $this->getMockBuilder(TransactionStatus::class)->disableOriginalConstructor()->getMock();
55
        $status->method('load')->willReturn($status);
56
57
        $statusFactory = $this->getMockBuilder(TransactionStatusFactory::class)
58
            ->disableOriginalConstructor()
59
            ->setMethods(['create'])
60
            ->getMock();
61
        $statusFactory->method('create')->willReturn($status);
62
63
        $request = $this->getMockBuilder(RequestInterface::class)->disableOriginalConstructor()->getMock();
64
        $request->method('getParam')->willReturn('5');
65
66
        $buttonList = $this->getMockBuilder(ButtonList::class)->disableOriginalConstructor()->getMock();
67
68
        $urlBuilder = $this->getMockBuilder(UrlInterface::class)->disableOriginalConstructor()->getMock();
69
        $urlBuilder->method('getUrl')->willReturn('http://testdomain.com');
70
71
        $context = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
72
        $context->method('getRequest')->willReturn($request);
73
        $context->method('getButtonList')->willReturn($buttonList);
74
        $context->method('getUrlBuilder')->willReturn($urlBuilder);
75
76
        $this->classToTest = $this->objectManager->getObject(ClassToTest::class, [
77
            'context' => $context,
78
            'statusFactory' => $statusFactory
79
        ]);
80
    }
81
82
    public function testGetApiLogEntry()
83
    {
84
        $result = $this->classToTest->getTransactionStatusEntry();
85
        $this->assertInstanceOf(TransactionStatus::class, $result);
86
    }
87
}
88