3 namespace Doctrine\Tests\DBAL\Types;
5 use Doctrine\DBAL\Types\Type;
6 use Doctrine\Tests\DBAL\Mocks;
8 require_once __DIR__ . '/../../TestInit.php';
10 class ObjectTest extends \Doctrine\Tests\DbalTestCase
16 protected function setUp()
18 $this->_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform();
19 $this->_type = Type::getType('object');
22 public function tearDown()
24 error_reporting(-1); // reactive all error levels
27 public function testObjectConvertsToDatabaseValue()
29 $this->assertInternalType('string', $this->_type->convertToDatabaseValue(new \stdClass(), $this->_platform));
32 public function testObjectConvertsToPHPValue()
34 $this->assertInternalType('object', $this->_type->convertToPHPValue(serialize(new \stdClass), $this->_platform));
37 public function testConversionFailure()
39 error_reporting( (E_ALL | E_STRICT) - \E_NOTICE );
40 $this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
41 $this->_type->convertToPHPValue('abcdefg', $this->_platform);
44 public function testNullConversion()
46 $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform));
52 public function testFalseConversion()
54 $this->assertFalse($this->_type->convertToPHPValue(serialize(false), $this->_platform));