. */ namespace Doctrine\Tests\ORM\Tools; use Doctrine\ORM\Tools\Export\ClassMetadataExporter, Doctrine\ORM\Tools\ConvertDoctrine1Schema; require_once __DIR__ . '/../../TestInit.php'; /** * Test case for converting a Doctrine 1 style schema to Doctrine 2 mapping files * * @author Jonathan H. Wage * @author Roman Borschel getExporter('yml', __DIR__ . '/convert'); $exporter->setMetadatas($converter->getMetadatasFromSchema()); $exporter->export(); $this->assertTrue(file_exists(__DIR__ . '/convert/User.dcm.yml')); $this->assertTrue(file_exists(__DIR__ . '/convert/Profile.dcm.yml')); $cme->addMappingSource(__DIR__ . '/convert', 'yml'); $metadatas = $cme->getMetadatasForMappingSources(); $this->assertEquals(2, count($metadatas)); $this->assertEquals('Profile', $metadatas['Profile']->name); $this->assertEquals('User', $metadatas['User']->name); $this->assertEquals(4, count($metadatas['Profile']->fieldMappings)); $this->assertEquals(5, count($metadatas['User']->fieldMappings)); $this->assertEquals('text', $metadatas['User']->fieldMappings['clob']['type']); $this->assertEquals('test_alias', $metadatas['User']->fieldMappings['theAlias']['columnName']); $this->assertEquals('theAlias', $metadatas['User']->fieldMappings['theAlias']['fieldName']); $this->assertEquals('Profile', $metadatas['Profile']->associationMappings['User']->sourceEntityName); $this->assertEquals('User', $metadatas['Profile']->associationMappings['User']->targetEntityName); $this->assertEquals('username', $metadatas['User']->primaryTable['uniqueConstraints']['username']['columns'][0]); unlink(__DIR__ . '/convert/User.dcm.yml'); unlink(__DIR__ . '/convert/Profile.dcm.yml'); rmdir(__DIR__ . '/convert'); } }