Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Functional / SchemaTool / CompanySchemaTest.php
1 <?php
2
3 namespace Doctrine\Tests\ORM\Functional\SchemaTool;
4
5 use Doctrine\DBAL\Schema\Schema;
6
7 require_once __DIR__ . '/../../../TestInit.php';
8
9 /**
10  * Functional tests for the Class Table Inheritance mapping strategy.
11  *
12  * @author robo
13  */
14 class CompanySchemaTest extends \Doctrine\Tests\OrmFunctionalTestCase
15 {
16     protected function setUp()
17     {
18         $this->useModelSet('company');
19         parent::setUp();
20     }
21
22     /**
23      * @group DDC-966
24      * @return Schema
25      */
26     public function testGeneratedSchema()
27     {
28         $schema = $this->_em->getConnection()->getSchemaManager()->createSchema();
29
30         $this->assertTrue($schema->hasTable('company_contracts'));
31
32         return $schema;
33     }
34
35     /**
36      * @group DDC-966
37      * @depends testGeneratedSchema
38      */
39     public function testSingleTableInheritance(Schema $schema)
40     {
41         $table = $schema->getTable('company_contracts');
42
43         // Check nullability constraints
44         $this->assertTrue($table->getColumn('id')->getNotnull());
45         $this->assertTrue($table->getColumn('completed')->getNotnull());
46         $this->assertFalse($table->getColumn('salesPerson_id')->getNotnull());
47         $this->assertTrue($table->getColumn('discr')->getNotnull());
48         $this->assertFalse($table->getColumn('fixPrice')->getNotnull());
49         $this->assertFalse($table->getColumn('hoursWorked')->getNotnull());
50         $this->assertFalse($table->getColumn('pricePerHour')->getNotnull());
51         $this->assertFalse($table->getColumn('maxPrice')->getNotnull());
52     }
53
54     /**
55      * @group DBAL-115
56      */
57     public function testDropPartSchemaWithForeignKeys()
58     {
59         if (!$this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) {
60             $this->markTestSkipped("Foreign Key test");
61         }
62
63         $sql = $this->_schemaTool->getDropSchemaSQL(array(
64             $this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyManager'),
65         ));
66         $this->assertEquals(4, count($sql));
67     }
68 }