CompanySchemaTest.php 2.0 KB

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