Skip to content

Instantly share code, notes, and snippets.

@marcj
Created April 10, 2013 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcj/5350549 to your computer and use it in GitHub Desktop.
Save marcj/5350549 to your computer and use it in GitHub Desktop.
<?php
class Issue651Test extends PHPUnit_Framework_TestCase
{
public function testIndex()
{
$updatedSchema = '
<database>
<table name="notification_type">
<column name="module_unique_name" primaryKey="true" required="true" size="255" type="VARCHAR" />
<column name="unique_name" primaryKey="true" required="true" size="255" type="VARCHAR" />
<column name="is_correction" defaultValue="0" required="true" type="BOOLEAN" />
<column name="disabled_engine" size="255" type="VARCHAR" />
<foreign-key foreignTable="module" name="FK_TYPENOTIFICATION_MODULE0" onDelete="CASCADE" onUpdate="CASCADE">
<reference foreign="unique_name" local="module_unique_name" />
</foreign-key>
<index name="FK_TYPENOTIFICATION_MODULE">
<index-column name="module_unique_name" />
</index>
</table>
<table name="module">
<column name="unique_name" primaryKey="true" size="255" type="VARCHAR" />
</table>
</database>
';
$platform = new MysqlPlatform();
$platform->setDefaultTableEngine('InnoDb');
$updatedBuilder = new PropelQuickBuilder();
$updatedBuilder->setPlatform($platform);
$updatedBuilder->setSchema($updatedSchema);
$sql = $updatedBuilder->getSQL();
var_dump($sql);
}
}
$ phpunit test/testsuite/misc/Issue651Test.php
PHPUnit 3.7.13 by Sebastian Bergmann.
Configuration read from /Users/marc/Propel/phpunit.xml.dist
.string(1288) "
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------------------------------------------------
-- notification_type
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `notification_type`;
CREATE TABLE `notification_type`
(
`module_unique_name` VARCHAR(255) NOT NULL,
`unique_name` VARCHAR(255) NOT NULL,
`is_correction` TINYINT(1) DEFAULT 0 NOT NULL,
`disabled_engine` VARCHAR(255),
PRIMARY KEY (`module_unique_name`,`unique_name`),
INDEX `FK_TYPENOTIFICATION_MODULE` (`module_unique_name`),
CONSTRAINT `FK_TYPENOTIFICATION_MODULE0`
FOREIGN KEY (`module_unique_name`)
REFERENCES `module` (`unique_name`)
ON UPDATE CASCADE
ON DELETE CASCADE
) ENGINE=InnoDb;
-- ---------------------------------------------------------------------
-- module
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `module`;
CREATE TABLE `module`
(
`unique_name` VARCHAR(255) NOT NULL,
PRIMARY KEY (`unique_name`)
) ENGINE=InnoDb;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;
"
Time: 0 seconds, Memory: 6.50Mb
OK (1 test, 0 assertions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment