PaymentMethodAssignDataTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 6
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\Observer;
28
29
use Magento\Framework\DataObject;
30
use Payone\Core\Observer\PaymentMethodAssignData as ClassToTest;
31
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
32
use Magento\Framework\Event\Observer;
33
use Payone\Core\Helper\Toolkit;
34
use Magento\Payment\Model\Info;
35
use Payone\Core\Test\Unit\BaseTestCase;
36
use Payone\Core\Model\Test\PayoneObjectManager;
37
38
class PaymentMethodAssignDataTest extends BaseTestCase
39
{
40
    /**
41
     * @var ClassToTest
42
     */
43
    private $classToTest;
44
45
    /**
46
     * @var ObjectManager|PayoneObjectManager
47
     */
48
    private $objectManager;
49
50
    protected function setUp()
51
    {
52
        $this->objectManager = $this->getObjectManager();
53
54
        $toolkitHelper = $this->getMockBuilder(Toolkit::class)->disableOriginalConstructor()->getMock();
55
        $toolkitHelper->method('getAdditionalDataEntry')->willReturn(true);
56
57
        $this->classToTest = $this->objectManager->getObject(ClassToTest::class, [
58
            'toolkitHelper' => $toolkitHelper
59
        ]);
60
    }
61
62
    public function testExecute()
63
    {
64
        $paymentInfo = $this->objectManager->getObject(Info::class);
65
66
        $data = $this->objectManager->getObject(DataObject::class);
67
        $observer = $this->getMockBuilder(Observer::class)
68
            ->disableOriginalConstructor()
69
            ->setMethods(['getPaymentModel', 'getData'])
70
            ->getMock();
71
        $observer->method('getPaymentModel')->willReturn($paymentInfo);
72
        $observer->method('getData')->willReturn($data);
73
74
        $result = $this->classToTest->execute($observer);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as $this->classToTest->execute($observer) (which targets Payone\Core\Observer\Pay...odAssignData::execute()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
75
        $this->assertNull($result);
76
        $this->assertTrue($paymentInfo->getAdditionalInformation('payone_boni_agreement'));
77
    }
78
}
79