1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Doctrine\Tests\ORM\Functional\SchemaTool; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Tools; |
6
|
|
|
|
7
|
|
|
class DDC3460Test extends \Doctrine\Tests\OrmFunctionalTestCase |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @var \Doctrine\DBAL\Connection |
11
|
|
|
*/ |
12
|
|
|
private $connection; |
13
|
|
|
|
14
|
|
|
public function setUp() |
15
|
|
|
{ |
16
|
|
|
parent::setUp(); |
17
|
|
|
$this->connection = $this->_em->getConnection(); |
18
|
|
|
|
19
|
|
|
if (strpos($this->connection->getDriver()->getName(), "mysql") === false) { |
20
|
|
|
$this->markTestSkipped('this test is only relevant for MySQL'); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
$this->connection->exec('DROP TABLE IF EXISTS `tweet_user`'); |
24
|
|
|
$this->connection->exec('DROP TABLE IF EXISTS `tweet_tweet`'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @group DDC-3460 |
29
|
|
|
*/ |
30
|
|
|
public function testDetectMyISAM() |
31
|
|
|
{ |
32
|
|
|
|
33
|
|
|
$this->connection->exec('CREATE TABLE `tweet_user` (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) ENGINE = MyISAM'); |
34
|
|
|
$this->connection->exec('CREATE TABLE `tweet_tweet` (id INT NOT NULL AUTO_INCREMENT, content VARCHAR(255) NOT NULL, author_id INT, PRIMARY KEY(id)) ENGINE = MyISAM'); |
35
|
|
|
|
36
|
|
|
$fromSchema = $this->connection->getSchemaManager()->createSchema(); |
37
|
|
|
$options = $fromSchema->getTable('tweet_user')->getOptions(); |
38
|
|
|
$this->assertArrayHasKey('engine', $options); |
39
|
|
|
$this->assertSame('MyISAM', $options['engine']); |
40
|
|
|
|
41
|
|
|
$classMetadata = [ |
42
|
|
|
$this->_em->getClassMetadata(Doctrine\Tests\Models\Tweet\Tweet::class), |
43
|
|
|
$this->_em->getClassMetadata(Doctrine\Tests\Models\Tweet\User::class) |
44
|
|
|
]; |
45
|
|
|
$schemaTool = new Tools\SchemaTool($this->_em); |
46
|
|
|
$toSchema = $schemaTool->getSchemaFromMetadata($classMetadata); |
47
|
|
|
|
48
|
|
|
$comparator = new \Doctrine\DBAL\Schema\Comparator(); |
49
|
|
|
$schemaDiff = $comparator->compare($fromSchema, $toSchema); |
50
|
|
|
$this->assertEquals([], $schemaDiff->toSql($this->connection->getDatabasePlatform()), 'Schema diff should be empty'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function tearDown() |
54
|
|
|
{ |
55
|
|
|
$this->connection->exec('DROP TABLE IF EXISTS `tweet_user`'); |
56
|
|
|
$this->connection->exec('DROP TABLE IF EXISTS `tweet_tweet`'); |
57
|
|
|
parent::tearDown(); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|