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

BaseTestCase::getObjectManager()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 4
nc 2
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\Model\Test;
28
29
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
30
use PHPUnit\Framework\TestCase;
31
32
class BaseTestCase extends TestCase
33
{
34
    /**
35
     * Return ObjectManager object based on the current Magento 2 version
36
     *
37
     * @return ObjectManager|PayoneObjectManager
38
     */
39
    public function getObjectManager()
40
    {
41
        // This is a version-switch -> class was added with Magento 2.2.0
42
        // Couldnt find a direct way to obtain the version using only the Unittest-Objectmanager
43
        if (class_exists('\Magento\Framework\Serialize\Serializer\Json') === false) {
44
            return new PayoneObjectManager($this);
0 ignored issues
show
Documentation introduced by
$this is of type this<Payone\Core\Model\Test\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...
45
        }
46
        return new ObjectManager($this);
47
    }
48
}
49