Completed
Pull Request — master (#114)
by Florian
03:49
created

BaseTestCase   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getObjectManager() 0 9 2
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;
28
29
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
30
use Payone\Core\Model\Test\PayoneObjectManager;
31
use PHPUnit\Framework\TestCase;
32
33
class BaseTestCase extends TestCase
34
{
35
    /**
36
     * Return ObjectManager object based on the current Magento 2 version
37
     *
38
     * @return ObjectManager|PayoneObjectManager
39
     */
40
    public function getObjectManager()
41
    {
42
        // This is a version-switch -> class was added with Magento 2.2.0
43
        // Couldnt find a direct way to obtain the version using only the Unittest-Objectmanager
44
        if (class_exists('\Magento\Framework\Serialize\Serializer\Json') === false) {
45
            return new PayoneObjectManager($this);
0 ignored issues
show
Documentation introduced by
$this is of type this<Payone\Core\Test\Unit\BaseTestCase>, but the function expects a object<PHPUnit_Framework_TestCase>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
46
        }
47
        return new ObjectManager($this);
48
    }
49
}
50