1
0
Fork 0
mirror of synced 2025-04-03 13:23:37 +03:00

Fixing DatabaseDriverTest fails for mysql.

This commit is contained in:
Jonathan H. Wage 2010-05-25 13:35:12 -04:00
parent e8386eca37
commit 2db8ad30a9

View file

@ -4,7 +4,8 @@ namespace Doctrine\Tests\ORM\Functional;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\Common\Util\Inflector;
class DatabaseDriverTest extends \Doctrine\Tests\OrmFunctionalTestCase class DatabaseDriverTest extends \Doctrine\Tests\OrmFunctionalTestCase
{ {
@ -29,7 +30,7 @@ class DatabaseDriverTest extends \Doctrine\Tests\OrmFunctionalTestCase
$table = new \Doctrine\DBAL\Schema\Table("dbdriver_foo"); $table = new \Doctrine\DBAL\Schema\Table("dbdriver_foo");
$table->addColumn('id', 'integer'); $table->addColumn('id', 'integer');
$table->setPrimaryKey(array('id')); $table->setPrimaryKey(array('id'));
$table->addColumn('bar', 'string', array('length' => 200)); $table->addColumn('bar', 'string', array('notnull' => false, 'length' => 200));
$this->_sm->dropAndCreateTable($table); $this->_sm->dropAndCreateTable($table);
@ -39,14 +40,13 @@ class DatabaseDriverTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals('id', $metadata->fieldMappings['id']['fieldName']); $this->assertEquals('id', $metadata->fieldMappings['id']['fieldName']);
$this->assertEquals('id', strtolower($metadata->fieldMappings['id']['columnName'])); $this->assertEquals('id', strtolower($metadata->fieldMappings['id']['columnName']));
$this->assertEquals('integer', (string)$metadata->fieldMappings['id']['type']); $this->assertEquals('integer', (string)$metadata->fieldMappings['id']['type']);
$this->assertTrue($metadata->fieldMappings['id']['notnull']);
$this->assertArrayHasKey('bar', $metadata->fieldMappings); $this->assertArrayHasKey('bar', $metadata->fieldMappings);
$this->assertEquals('bar', $metadata->fieldMappings['bar']['fieldName']); $this->assertEquals('bar', $metadata->fieldMappings['bar']['fieldName']);
$this->assertEquals('bar', strtolower($metadata->fieldMappings['bar']['columnName'])); $this->assertEquals('bar', strtolower($metadata->fieldMappings['bar']['columnName']));
$this->assertEquals('string', (string)$metadata->fieldMappings['bar']['type']); $this->assertEquals('string', (string)$metadata->fieldMappings['bar']['type']);
$this->assertEquals(200, $metadata->fieldMappings['bar']['length']); $this->assertEquals(200, $metadata->fieldMappings['bar']['length']);
$this->assertTrue($metadata->fieldMappings['bar']['notnull']); $this->assertTrue($metadata->fieldMappings['bar']['nullable']);
} }
public function testCreateYamlWithForeignKeyFromDatabase() public function testCreateYamlWithForeignKeyFromDatabase()
@ -88,12 +88,13 @@ class DatabaseDriverTest extends \Doctrine\Tests\OrmFunctionalTestCase
protected function extractClassMetadata($className) protected function extractClassMetadata($className)
{ {
$driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($this->_sm); $driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($this->_sm);
foreach ($driver->getAllClassNames() as $dbClassName) { foreach ($driver->getAllClassNames() as $dbTableName) {
$class = new ClassMetadataInfo($dbClassName); if (strtolower(Inflector::classify($dbTableName)) != strtolower($className)) {
$driver->loadMetadataForClass($dbClassName, $class); continue;
if (strtolower($class->name) == strtolower($className)) {
return $class;
} }
$class = new ClassMetadataInfo($dbTableName);
$driver->loadMetadataForClass($dbTableName, $class);
return $class;
} }
$this->fail("No class matching the name '".$className."' was found!"); $this->fail("No class matching the name '".$className."' was found!");