StringToObjectConverterTest::testConvert()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
3
namespace Ddeboer\DataImport\ValueConverter;
4
5
use Ddeboer\DataImport\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->getMock(
15
            'Doctrine\\Common\\Persistence\\ObjectRepository',
16
            array('find', 'findAll', 'findBy', 'findOneBy', 'getClassName', 'findOneByName')
17
        );
18
19
        $converter = new StringToObjectConverter($repository, 'name');
20
21
        $class = new \stdClass();
22
23
        $repository->expects($this->once())
24
            ->method('findOneByName')
25
            ->with('bar')
26
            ->will($this->returnValue($class));
27
28
        $this->assertEquals($class, call_user_func($converter, 'bar'));
29
    }
30
}
31