-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2.0] Testing all dbal types and making sure they are fully implemented
- Loading branch information
jwage
committed
Jun 20, 2009
1 parent
ab2b399
commit 78d4309
Showing
22 changed files
with
295 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Doctrine\DBAL\Types; | ||
|
||
/** | ||
* Type that maps a PHP object to a clob SQL type. | ||
* | ||
* @since 2.0 | ||
*/ | ||
class ObjectType extends Type | ||
{ | ||
public function getSqlDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) | ||
{ | ||
return $platform->getClobDeclarationSql($fieldDeclaration); | ||
} | ||
|
||
public function convertToDatabaseValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) | ||
{ | ||
return serialize($value); | ||
} | ||
|
||
public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatform $platform) | ||
{ | ||
return unserialize($value); | ||
} | ||
|
||
public function getName() | ||
{ | ||
return 'Object'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\DBAL\Types; | ||
|
||
use Doctrine\DBAL\Types\Type; | ||
use Doctrine\Tests\DBAL\Mocks; | ||
|
||
require_once __DIR__ . '/../../TestInit.php'; | ||
|
||
class ArrayTest extends \Doctrine\Tests\DbalTestCase | ||
{ | ||
protected | ||
$_platform, | ||
$_type; | ||
|
||
protected function setUp() | ||
{ | ||
$this->_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); | ||
$this->_type = Type::getType('array'); | ||
} | ||
|
||
public function testArrayConvertsToDatabaseValue() | ||
{ | ||
$this->assertTrue( | ||
is_string($this->_type->convertToDatabaseValue(array(), $this->_platform)) | ||
); | ||
} | ||
|
||
public function testArrayConvertsToPHPValue() | ||
{ | ||
$this->assertTrue( | ||
is_array($this->_type->convertToPHPValue(serialize(array()), $this->_platform)) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\DBAL\Types; | ||
|
||
use Doctrine\DBAL\Types\Type; | ||
use Doctrine\Tests\DBAL\Mocks; | ||
|
||
require_once __DIR__ . '/../../TestInit.php'; | ||
|
||
class BooleanTest extends \Doctrine\Tests\DbalTestCase | ||
{ | ||
protected | ||
$_platform, | ||
$_type; | ||
|
||
protected function setUp() | ||
{ | ||
$this->_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); | ||
$this->_type = Type::getType('boolean'); | ||
} | ||
|
||
public function testBooleanConvertsToDatabaseValue() | ||
{ | ||
$this->assertTrue( | ||
is_integer($this->_type->convertToDatabaseValue(1, $this->_platform)) | ||
); | ||
} | ||
|
||
public function testBooleanConvertsToPHPValue() | ||
{ | ||
$this->assertTrue( | ||
is_bool($this->_type->convertToPHPValue(0, $this->_platform)) | ||
); | ||
} | ||
} |
Oops, something went wrong.