Completed
Push — tolerant_search_service ( 1edbf9...0c5f4c )
by André
11:19
created

PHPUnit5CompatTrait::getMock()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 10
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
/**
3
 * File containing PHPUnit 5 Forward Compatibility trait.
4
 *
5
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
6
 * @license For full copyright and license information view LICENSE file distributed with this source code.
7
 */
8
namespace eZ\Publish\Core\Base\Tests;
9
10
/**
11
 * Trait for PHPUnit 5 Forward Compatibility, for PHPUnit 4.8 use and up.
12
 */
13
trait PHPUnit5CompatTrait
14
{
15
    /**
16
     * @deprecated Since PHPUnit 5.4, marked as deprecated here to make it clear when working on 6.7/5.4 branches
17
     * @inheritdoc
18
     */
19
    public function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true, $cloneArguments = false, $callOriginalMethods = false, $proxyTarget = null)
20
    {
21
        return $this->getMock(
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\Base\Tes...5CompatTrait::getMock() has been deprecated with message: Since PHPUnit 5.4, marked as deprecated here to make it clear when working on 6.7/5.4 branches

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
22
            $originalClassName,
23
            $methods,
24
            $arguments,
25
            $mockClassName,
26
            $callOriginalConstructor,
27
            $callOriginalClone,
28
            $callAutoload,
29
            $cloneArguments,
30
            $callOriginalMethods,
31
            $proxyTarget
32
        );
33
    }
34
35
    /**
36
     * Returns a test double for the specified class.
37
     *
38
     * @internal Forward compatibility with PHPUnit 5/6, so unit tests written on 6.7 & backported to 5.4 can use this.
39
     *
40
     * @param string $originalClassName
41
     *
42
     * @return \PHPUnit_Framework_MockObject_MockObject
43
     */
44
    protected function createMock($originalClassName)
45
    {
46
        return $this->getMockBuilder($originalClassName)
0 ignored issues
show
Bug introduced by
The method getMockBuilder() does not exist on eZ\Publish\Core\Base\Tests\PHPUnit5CompatTrait. Did you maybe mean getMock()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
47
            ->disableOriginalConstructor()
48
            ->disableOriginalClone()
49
            ->disableArgumentCloning()
50
            //->disallowMockingUnknownTypes() Not defined in PHPunit 4.8
51
            ->getMock();
52
    }
53
}
54