Completed
Pull Request — master (#298)
by
unknown
03:49
created

StringToObjectConverterTest::testConvert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
rs 9.4285
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