Actualización

This commit is contained in:
Xes
2025-04-10 12:24:57 +02:00
parent 8969cc929d
commit 45420b6f0d
39760 changed files with 4303286 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
<?php
namespace Ddeboer\DataImport\Tests\ValueConverter;
use Ddeboer\DataImport\ValueConverter\ObjectConverter;
/**
* @author Markus Bachmann <markus.bachmann@bachi.biz
*/
class ObjectConverterTest extends \PHPUnit_Framework_TestCase
{
public function testGetAndSetPropertyPath()
{
$converter = new ObjectConverter();
$this->assertNull($converter->getPropertyPath());
$converter->setPropertyPath('foo.bar');
$this->assertEquals('foo.bar', $converter->getPropertyPath());
}
public function testConvertWithToString()
{
$converter = new ObjectConverter();
$object = new ToStringDummy();
$this->assertEquals('foo', call_user_func($converter, $object));
}
public function testConvertWithPropertyPath()
{
$converter = new ObjectConverter('foo');
$object = new Dummy();
$this->assertEquals('bar', call_user_func($converter, $object));
}
/**
* @expectedException RuntimeException
*/
public function testConvertAObjectWithoutToString()
{
$converter = new ObjectConverter;
call_user_func($converter, new Dummy());
}
/**
* @expectedException Ddeboer\DataImport\Exception\UnexpectedTypeException
*/
public function testConvetANonObject()
{
$converter = new ObjectConverter();
call_user_func($converter, 'foo');
}
}
class Dummy
{
public $foo = 'bar';
}
class ToStringDummy
{
public function __toString()
{
return 'foo';
}
}