Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / dbal / tests / Doctrine / Tests / DBAL / Types / ArrayTest.php
1 <?php
2
3 namespace Doctrine\Tests\DBAL\Types;
4
5 use Doctrine\DBAL\Types\Type;
6 use Doctrine\Tests\DBAL\Mocks;
7
8 require_once __DIR__ . '/../../TestInit.php';
9
10 class ArrayTest extends \Doctrine\Tests\DbalTestCase
11 {
12     protected
13         $_platform,
14         $_type;
15
16     protected function setUp()
17     {
18         $this->_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform();
19         $this->_type = Type::getType('array');
20     }
21
22     public function tearDown()
23     {
24         error_reporting(-1); // reactive all error levels
25     }
26
27
28     public function testArrayConvertsToDatabaseValue()
29     {
30         $this->assertTrue(
31             is_string($this->_type->convertToDatabaseValue(array(), $this->_platform))
32         );
33     }
34
35     public function testArrayConvertsToPHPValue()
36     {
37         $this->assertTrue(
38             is_array($this->_type->convertToPHPValue(serialize(array()), $this->_platform))
39         );
40     }
41
42     public function testConversionFailure()
43     {
44         error_reporting( (E_ALL | E_STRICT) - \E_NOTICE );
45         $this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
46         $this->_type->convertToPHPValue('abcdefg', $this->_platform);
47     }
48
49     public function testNullConversion()
50     {
51         $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform));
52     }
53
54     /**
55      * @group DBAL-73
56      */
57     public function testFalseConversion()
58     {
59         $this->assertFalse($this->_type->convertToPHPValue(serialize(false), $this->_platform));
60     }
61 }