Completed
Push — master ( 660080...9a4df6 )
by David de
09:19
created

StringToObjectConverterTest::testConvert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 20
rs 9.4285
cc 1
eloc 13
nc 1
nop 0
1
<?php
2
3
namespace Port\Tests\ValueConverter;
4
5
use Port\ValueConverter\StringToObjectConverter;
6
7
/**
8
 * @author Markus Bachmann <[email protected]>
9
 */
10
class StringToObjectConverterTest extends \PHPUnit_Framework_TestCase
11
{
12
    public function testConvert()
13
    {
14
        $repository = $this->getMockBuilder(
15
            'Doctrine\\Common\\Persistence\\ObjectRepository',
16
            ['find', 'findAll', 'findBy', 'findOneBy', 'getClassName', 'findOneByName']
0 ignored issues
show
Unused Code introduced by
The call to StringToObjectConverterTest::getMockBuilder() has too many arguments starting with array('find', 'findAll',...Name', 'findOneByName').

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
17
        )
18
            ->setMethods(['findOneByName'])
19
            ->getMock();
20
21
        $converter = new StringToObjectConverter($repository, 'name');
22
23
        $class = new \stdClass();
24
25
        $repository->expects($this->once())
26
            ->method('findOneByName')
27
            ->with('bar')
28
            ->will($this->returnValue($class));
29
30
        $this->assertEquals($class, call_user_func($converter, 'bar'));
31
    }
32
}
33