Completed
Pull Request — master (#6487)
by Andreas
09:22
created

DDC3460Test   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 8
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B testDetectMyISAM() 0 24 2
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
     * @group DDC-3460
11
     */
12
    public function testDetectMyISAM()
13
    {
14
        $conn = $this->_em->getConnection();
15
16
        if (strpos($conn->getDriver()->getName(), "mysql") === false) {
17
            $this->markTestSkipped('this test is only relevant for MySQL');
18
        }
19
20
        $conn->exec('CREATE TABLE `tweet_user` (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) ENGINE = MyISAM');
21
        $conn->exec('CREATE TABLE `tweet_tweet` (id INT NOT NULL AUTO_INCREMENT, content VARCHAR(255) NOT NULL, author_id INT, PRIMARY KEY(id)) ENGINE = MyISAM');
22
23
        $fromSchema = $conn->getSchemaManager()->createSchema();
24
25
        $classMetadata = [
26
            $this->_em->getClassMetadata('Doctrine\Tests\Models\Tweet\Tweet'),
27
            $this->_em->getClassMetadata('Doctrine\Tests\Models\Tweet\User')
28
        ];
29
        $schemaTool = new Tools\SchemaTool($this->_em);
30
        $toSchema = $schemaTool->getSchemaFromMetadata($classMetadata);
31
32
        $comparator = new \Doctrine\DBAL\Schema\Comparator();
33
        $schemaDiff = $comparator->compare($fromSchema, $toSchema);
34
        $this->assertEquals([], $schemaDiff->toSql($conn->getDatabasePlatform()));
35
    }
36
}
37