StringToObjectConverterTest.php 842 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace Ddeboer\DataImport\ValueConverter;
  3. use Ddeboer\DataImport\ValueConverter\StringToObjectConverter;
  4. /**
  5. * @author Markus Bachmann <markus.bachmann@bachi.biz>
  6. */
  7. class StringToObjectConverterTest extends \PHPUnit_Framework_TestCase
  8. {
  9. public function testConvert()
  10. {
  11. $repository = $this->getMock(
  12. 'Doctrine\\Common\\Persistence\\ObjectRepository',
  13. array('find', 'findAll', 'findBy', 'findOneBy', 'getClassName', 'findOneByName')
  14. );
  15. $converter = new StringToObjectConverter($repository, 'name');
  16. $class = new \stdClass();
  17. $repository->expects($this->once())
  18. ->method('findOneByName')
  19. ->with('bar')
  20. ->will($this->returnValue($class));
  21. $this->assertEquals($class, call_user_func($converter, 'bar'));
  22. }
  23. }