Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'upstream/master' into sortable_scope

  • Loading branch information...
commit 7b0e087e606ddf8cb4ed7ce6302bfcafa9745556 2 parents 4f89358 + a6b98bd
@rozwell authored
Showing with 701 additions and 530 deletions.
  1. +1 −1  generator/lib/behavior/concrete_inheritance/ConcreteInheritanceBehavior.php
  2. +1 −1  generator/lib/behavior/i18n/I18nBehavior.php
  3. +36 −8 generator/lib/builder/om/PHP5ObjectBuilder.php
  4. +41 −0 generator/lib/builder/om/QueryInheritanceBuilder.php
  5. +14 −3 generator/lib/model/diff/PropelForeignKeyComparator.php
  6. +1 −1  generator/lib/platform/DefaultPlatform.php
  7. +1 −1  generator/lib/platform/PgsqlPlatform.php
  8. +8 −4 generator/lib/task/PropelSQLTask.php
  9. +8 −0 runtime/lib/om/BaseObject.php
  10. +1 −1  runtime/lib/query/Criteria.php
  11. +10 −0 test/testsuite/generator/behavior/ObjectBehaviorTest.php
  12. +5 −3 test/testsuite/generator/behavior/archivable/ArchivableBehaviorTest.php
  13. +17 −17 test/testsuite/generator/behavior/i18n/I18nBehaviorObjectBuilderModifierTest.php
  14. +1 −1  test/testsuite/generator/behavior/i18n/I18nBehaviorPeerBuilderModifierTest.php
  15. +18 −18 test/testsuite/generator/behavior/i18n/I18nBehaviorQueryBuilderModifierTest.php
  16. +46 −46 test/testsuite/generator/behavior/i18n/I18nBehaviorTest.php
  17. +92 −92 test/testsuite/generator/behavior/versionable/VersionableBehaviorTest.php
  18. +8 −1 test/testsuite/generator/builder/om/GeneratedObjectTest.php
  19. +14 −0 test/testsuite/generator/builder/om/QueryBuilderInheritanceTest.php
  20. +1 −1  test/testsuite/generator/model/ColumnTest.php
  21. +77 −74 test/testsuite/generator/platform/MssqlPlatformTest.php
  22. +65 −65 test/testsuite/generator/platform/PgsqlPlatformMigrationTest.php
  23. +150 −145 test/testsuite/generator/platform/PgsqlPlatformTest.php
  24. +47 −43 test/testsuite/generator/platform/SqlitePlatformTest.php
  25. +4 −4 test/testsuite/generator/util/PropelQuickBuilderTest.php
  26. +23 −0 test/testsuite/runtime/query/ModelCriteriaTest.php
  27. +6 −0 test/tools/helpers/bookstore/behavior/TestAuthor.php
  28. +5 −0 test/tools/helpers/bookstore/behavior/Testallhooksbehavior.php
View
2  generator/lib/behavior/concrete_inheritance/ConcreteInheritanceBehavior.php
@@ -207,7 +207,7 @@ public function getParentOrCreate(\$con = null)
if (null === (\$parent = \$this->get". $parentClass . "(\$con))) {
\$parent = new " . $parentClass . "();
}
- \$parent->set" . $this->getParentTable()->getColumn($this->getParameter('descendant_column'))->getPhpName() . "('" . $this->builder->getStubObjectBuilder()->getClassname() . "');
+ \$parent->set" . $this->getParentTable()->getColumn($this->getParameter('descendant_column'))->getPhpName() . "('" . $this->builder->getStubObjectBuilder()->getFullyQualifiedClassname() . "');
return \$parent;
} else {
View
2  generator/lib/behavior/i18n/I18nBehavior.php
@@ -21,7 +21,7 @@
*/
class I18nBehavior extends Behavior
{
- const DEFAULT_LOCALE = 'en_EN';
+ const DEFAULT_LOCALE = 'en_US';
// default parameters value
protected $parameters = array(
View
44 generator/lib/builder/om/PHP5ObjectBuilder.php
@@ -192,9 +192,16 @@ protected function addClassOpen(&$script)
$table = $this->getTable();
$tableName = $table->getName();
$tableDesc = $table->getDescription();
- $interface = $this->getInterface();
$parentClass = $this->getBehaviorContent('parentClass');
- $parentClass = (null !== $parentClass) ? $parentClass : ClassTools::classname($this->getBaseClass());
+ if (null === $parentClass) {
+ $parentClass = ClassTools::classname($this->getBaseClass());
+
+ if (false === strpos($this->getBaseClass(), '.')) {
+ $this->declareClass($this->getBaseClass());
+ } else {
+ $this->declareClass($parentClass);
+ }
+ }
if ($this->getBuildProperty('addClassLevelComment')) {
$script .= "
@@ -246,8 +253,8 @@ protected function addClassBody(&$script)
$this->declareClassFromBuilder($this->getStubPeerBuilder());
$this->declareClassFromBuilder($this->getStubQueryBuilder());
$this->declareClasses(
- 'Propel', 'PropelException', 'PDO', 'PropelPDO', 'Criteria',
- 'BaseObject', 'Persistent', 'BasePeer', 'PropelCollection',
+ 'Propel', 'PropelException', 'PDO', 'PropelPDO', 'PropelQuery', 'Criteria',
+ 'Persistent', 'BasePeer', 'PropelCollection',
'PropelObjectCollection', 'Exception'
);
@@ -2058,7 +2065,11 @@ protected function addHydrateBody(&$script)
if (\$rehydrate) {
\$this->ensureConsistency();
}
+ \$this->postHydrate(\$row, \$startcol, \$rehydrate);";
+ $this->applyBehaviorModifier('postHydrate', $script, " ");
+
+ $script .= "
return \$startcol + $n; // $n = ".$this->getPeerClassname()."::NUM_HYDRATE_COLUMNS.
} catch (Exception \$e) {
@@ -3533,13 +3544,15 @@ protected function addRefFKClear(&$script, ForeignKey $refFK)
* This does not modify the database; however, it will remove any associated objects, causing
* them to be refetched by subsequent calls to accessor method.
*
- * @return void
+ * @return ".$this->getObjectClassname()." The current object (for fluent API support)
* @see add$relCol()
*/
public function clear$relCol()
{
\$this->$collName = null; // important to set this to null since that means it is uninitialized
\$this->{$collName}Partial = null;
+
+ return \$this;
}
";
} // addRefererClear()
@@ -3799,6 +3812,7 @@ protected function addRefFKSet(&$script, $refFK)
*
* @param PropelCollection \${$inputCollection} A Propel collection.
* @param PropelPDO \$con Optional connection object
+ * @return ".$this->getObjectClassname()." The current object (for fluent API support)
*/
public function set{$relatedName}(PropelCollection \${$inputCollection}, PropelPDO \$con = null)
{
@@ -3815,6 +3829,8 @@ public function set{$relatedName}(PropelCollection \${$inputCollection}, PropelP
\$this->{$collName} = \${$inputCollection};
\$this->{$collName}Partial = false;
+
+ return \$this;
}
";
}
@@ -3870,6 +3886,7 @@ protected function addRefFKRemove(&$script, $refFK)
$script .= "
/**
* @param {$relatedObjectClassName} \${$lowerRelatedObjectClassName} The $lowerRelatedObjectClassName object to remove.
+ * @return ".$this->getObjectClassname()." The current object (for fluent API support)
*/
public function remove{$relatedObjectClassName}(\${$lowerRelatedObjectClassName})
{
@@ -3882,6 +3899,8 @@ public function remove{$relatedObjectClassName}(\${$lowerRelatedObjectClassName}
\$this->{$inputCollection}[]= \${$lowerRelatedObjectClassName};
\${$lowerRelatedObjectClassName}->set{$relCol}(null);
}
+
+ return \$this;
}
";
}
@@ -4108,13 +4127,15 @@ protected function addCrossFKClear(&$script, ForeignKey $crossFK)
* This does not modify the database; however, it will remove any associated objects, causing
* them to be refetched by subsequent calls to accessor method.
*
- * @return void
+ * @return ".$this->getObjectClassname()." The current object (for fluent API support)
* @see add$relCol()
*/
public function clear$relCol()
{
\$this->$collName = null; // important to set this to null since that means it is uninitialized
\$this->{$collName}Partial = null;
+
+ return \$this;
}
";
} // addRefererClear()
@@ -4218,6 +4239,7 @@ protected function addCrossFKSet(&$script, $refFK, $crossFK)
*
* @param PropelCollection \${$inputCollection} A Propel collection.
* @param PropelPDO \$con Optional connection object
+ * @return ".$this->getObjectClassname()." The current object (for fluent API support)
*/
public function set{$relatedNamePlural}(PropelCollection \${$inputCollection}, PropelPDO \$con = null)
{
@@ -4233,6 +4255,8 @@ public function set{$relatedNamePlural}(PropelCollection \${$inputCollection}, P
}
\$this->$collName = \${$inputCollection};
+
+ return \$this;
}
";
}
@@ -4303,7 +4327,7 @@ protected function addCrossFKAdd(&$script, ForeignKey $refFK, ForeignKey $crossF
* through the " . $tblFK->getName() . " cross reference table.
*
* @param " . $crossObjectClassName . " " . $crossObjectName . " The $className object to relate
- * @return void
+ * @return ".$this->getObjectClassname()." The current object (for fluent API support)
*/
public function add{$relatedObjectClassName}($crossObjectClassName $crossObjectName)
{
@@ -4315,6 +4339,8 @@ public function add{$relatedObjectClassName}($crossObjectClassName $crossObjectN
\$this->" . $collName . "[]= " . $crossObjectName . ";
}
+
+ return \$this;
}
";
}
@@ -4382,7 +4408,7 @@ protected function addCrossFKRemove(&$script, ForeignKey $refFK, ForeignKey $cro
* through the {$tblFK->getName()} cross reference table.
*
* @param {$crossObjectClassName} {$crossObjectName} The $className object to relate
- * @return void
+ * @return ".$this->getObjectClassname()." The current object (for fluent API support)
*/
public function remove{$relatedObjectClassName}($crossObjectClassName $crossObjectName)
{
@@ -4394,6 +4420,8 @@ public function remove{$relatedObjectClassName}($crossObjectClassName $crossObje
}
\$this->{$M2MScheduledForDeletion}[]= {$crossObjectName};
}
+
+ return \$this;
}
";
}
View
41 generator/lib/builder/om/QueryInheritanceBuilder.php
@@ -169,6 +169,7 @@ protected function addClassBody(&$script)
$this->addPreUpdate($script);
$this->addPreDelete($script);
$this->addDoDeleteAll($script);
+ $this->addFindOneOrCreate($script);
}
/**
@@ -296,4 +297,44 @@ protected function addClassClose(&$script)
";
}
+ /**
+ * Adds findOneOrCreate function for this object.
+ * @param unknown $script
+ */
+ protected function addFindOneOrCreate(&$script)
+ {
+ $child = $this->getChild();
+ $col = $child->getColumn();
+ $script .= "
+
+ /**
+ * Issue a SELECT ... LIMIT 1 query based on the current ModelCriteria
+ * and format the result with the current formatter
+ * By default, returns a model object
+ *
+ * @param PropelPDO \$con an optional connection object
+ *
+ * @return mixed the result, formatted by the current formatter
+ *
+ * @throws PropelException
+ */
+ public function findOneOrCreate(\$con = null)
+ {
+ if (\$this->joins) {
+ throw new PropelException('findOneOrCreate() cannot be used on a query with a join, because Propel cannot transform a SQL JOIN into a subquery. You should split the query in two queries to avoid joins.');
+ }
+ if (!\$ret = \$this->findOne(\$con)) {
+ \$class = ".$this->getPeerClassname() . "::CLASSNAME_" . strtoupper($child->getKey()) . ";
+ \$obj = new \$class;
+ foreach (\$this->keys() as \$key) {
+ \$obj->setByName(\$key, \$this->getValue(\$key), BasePeer::TYPE_COLNAME);
+ }
+ \$ret = \$this->getFormatter()->formatRecord(\$obj);
+ }
+
+ return \$ret;
+ }
+";
+ }
+
} // MultiExtensionQueryBuilder
View
17 generator/lib/model/diff/PropelForeignKeyComparator.php
@@ -62,11 +62,22 @@ public static function computeDiff(ForeignKey $fromFk, ForeignKey $toFk, $caseIn
return true;
}
- // compare on
- if ($fromFk->normalizeFKey($fromFk->getOnUpdate()) != $toFk->normalizeFKey($toFk->getOnUpdate())) {
+
+ /*
+ * Compare onDelete and onUpdate:
+ *
+ * "RESTRICT" and its synonym "NO ACTION" is default and is not being reported explicitly.
+ */
+ $equalBehavior = array('', 'RESTRICT', 'NO ACTION');
+
+ $fromOnUpdate = strtoupper($fromFk->normalizeFKey($fromFk->getOnUpdate()));
+ $toOnUpdate = strtoupper($toFk->normalizeFKey($toFk->getOnUpdate()));
+ if ((in_array($fromOnUpdate, $equalBehavior) && !in_array($toOnUpdate, $equalBehavior)) || (!in_array($fromOnUpdate, $equalBehavior) && in_array($toOnUpdate, $equalBehavior))) {
return true;
}
- if ($fromFk->normalizeFKey($fromFk->getOnDelete()) != $toFk->normalizeFKey($toFk->getOnDelete())) {
+ $fromOnDelete = strtoupper($fromFk->normalizeFKey($fromFk->getOnDelete()));
+ $toOnDelete = strtoupper($toFk->normalizeFKey($toFk->getOnDelete()));
+ if ((in_array($fromOnDelete, $equalBehavior) && !in_array($toOnDelete, $equalBehavior)) || (!in_array($fromOnDelete, $equalBehavior) && in_array($toOnDelete, $equalBehavior))) {
return true;
}
View
2  generator/lib/platform/DefaultPlatform.php
@@ -39,7 +39,7 @@ class DefaultPlatform implements PropelPlatformInterface
/**
* @var boolean whether the identifier quoting is enabled
*/
- protected $isIdentifierQuotingEnabled = false;
+ protected $isIdentifierQuotingEnabled = true;
/**
* Default constructor.
View
2  generator/lib/platform/PgsqlPlatform.php
@@ -499,7 +499,7 @@ public function getIdentifierPhp($columnValueMutator, $connectionVariableName =
%s = \$row[0];";
$script = sprintf($snippet,
$connectionVariableName,
- $this->quoteIdentifier($sequenceName),
+ $sequenceName,
$columnValueMutator
);
View
12 generator/lib/task/PropelSQLTask.php
@@ -137,27 +137,31 @@ public function main()
$this->createSqlDbMap();
// 2) Now actually create the DDL based on the datamodel(s) from XML schema file.
- $targetDatabase = $this->getTargetDatabase();
-
+ $targetDatabase = $this->getTargetDatabase();
$generatorConfig = $this->getGeneratorConfig();
foreach ($dataModels as $package => $dataModel) {
-
foreach ($dataModel->getDatabases() as $database) {
-
$platform = $database->getPlatform();
+
if (!$this->packageObjectModel) {
$name = $dataModel->getName();
} else {
$name = ($package ? $package . '.' : '') . 'schema.xml';
}
+
$outFile = $this->getMappedFile($name);
$absPath = $outFile->getAbsolutePath();
+
if ($this->getGeneratorConfig()->getBuildProperty('disableIdentifierQuoting')) {
$platform->setIdentifierQuoting(false);
+ } else {
+ $platform->setIdentifierQuoting(true);
}
+
$this->log('Using ' . get_class($platform), Project::MSG_VERBOSE);
$ddl = $platform->getAddTablesDDL($database);
+
if (file_exists($absPath) && $ddl == file_get_contents($absPath)) {
$this->log('[Unchanged] ' . $outFile->getName());
} else {
View
8 runtime/lib/om/BaseObject.php
@@ -208,6 +208,14 @@ public function postDelete(PropelPDO $con = null)
}
/**
+ * Code to be run after deleting the object in database
+ * @param PropelPDO $con
+ */
+ public function postHydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ }
+
+ /**
* Sets the modified state for the object to be false.
* @param string $col If supplied, only the specified column is reset.
* @return void
View
2  runtime/lib/query/Criteria.php
@@ -822,7 +822,7 @@ public function combine($criterions = array(), $operator = self::LOGICAL_AND, $n
$firstCriterion->$operatorMethod($criterion);
}
if ($name === null) {
- $this->add($firstCriterion, null, null);
+ $this->addAnd($firstCriterion, null, null);
} else {
$this->addCond($name, $firstCriterion, null, null);
}
View
10 test/testsuite/generator/behavior/ObjectBehaviorTest.php
@@ -129,6 +129,16 @@ public function testPostDelete()
$this->assertEquals($t->postDeleteBuilder, 'PHP5ObjectBuilder', 'postDelete hook is called with the object builder as parameter');
$this->assertFalse($t->postDeleteIsBeforeDelete, 'postDelete hook is called before deletion');
}
+
+ public function testPostHydrate()
+ {
+ $t = new Table3();
+ $t->postHydrate = 0;
+ $t->hydrate(array(1, 'Title', 'Test'));
+ $this->assertEquals($t->postHydrate, 1, 'postHydrate hook is called on object hydration');
+ $this->assertEquals($t->postHydrateBuilder, 'PHP5ObjectBuilder', 'postHydrate hook is called with the object builder as parameter');
+ $this->assertTrue($t->postHydrateIsAfterHydrate, 'postHydrate hook is called after hydrate');
+ }
public function testObjectMethods()
{
View
8 test/testsuite/generator/behavior/archivable/ArchivableBehaviorTest.php
@@ -136,7 +136,7 @@ public function testCopiesColumnsToArchiveTable()
{
$table = ArchivableTest1ArchivePeer::getTableMap();
$this->assertTrue($table->hasColumn('id'));
- $this->assertContains('id INTEGER NOT NULL,', self::$generatedSQL, 'copied columns are not autoincremented');
+ $this->assertContains('[id] INTEGER NOT NULL,', self::$generatedSQL, 'copied columns are not autoincremented');
$this->assertTrue($table->hasColumn('title'));
$this->assertTrue($table->hasColumn('age'));
$this->assertTrue($table->hasColumn('foo_id'));
@@ -151,14 +151,16 @@ public function testDoesNotCopyForeignKeys()
public function testCopiesIndices()
{
$table = ArchivableTest1ArchivePeer::getTableMap();
- $expected = "CREATE INDEX archivable_test_1_archive_I_1 ON archivable_test_1_archive (title,age);";
+
+ $expected = "CREATE INDEX [archivable_test_1_archive_I_1] ON [archivable_test_1_archive] ([title],[age]);";
$this->assertContains($expected, self::$generatedSQL);
}
public function testCopiesUniquesToIndices()
{
$table = ArchivableTest2ArchivePeer::getTableMap();
- $expected = "CREATE INDEX my_old_archivable_test_3_I_1 ON my_old_archivable_test_3 (title);";
+
+ $expected = "CREATE INDEX [my_old_archivable_test_3_I_1] ON [my_old_archivable_test_3] ([title]);";
$this->assertContains($expected, self::$generatedSQL);
}
View
34 test/testsuite/generator/behavior/i18n/I18nBehaviorObjectBuilderModifierTest.php
@@ -92,7 +92,7 @@ public function testPostDeleteEmulatesOnDeleteCascade()
I18nBehaviorTest1I18nQuery::create()->deleteAll();
$o = new I18nBehaviorTest1();
$o->setFoo(123);
- $o->setLocale('en_EN');
+ $o->setLocale('en_US');
$o->setBar('hello');
$o->setLocale('fr_FR');
$o->setBar('bonjour');
@@ -139,13 +139,13 @@ public function testGetTranslationAcceptsALocaleParameter()
{
$o = new I18nBehaviorTest1();
$translation1 = new I18nBehaviorTest1I18n();
- $translation1->setLocale('en_EN');
+ $translation1->setLocale('en_US');
$o->addI18nBehaviorTest1I18n($translation1);
$translation2 = new I18nBehaviorTest1I18n();
$translation2->setLocale('fr_FR');
$o->addI18nBehaviorTest1I18n($translation2);
$o->save();
- $this->assertEquals($translation1, $o->getTranslation('en_EN'));
+ $this->assertEquals($translation1, $o->getTranslation('en_US'));
$this->assertEquals($translation2, $o->getTranslation('fr_FR'));
}
@@ -154,7 +154,7 @@ public function testGetTranslationSetsTheLocaleOnTheTranslation()
$o = new I18nBehaviorTest1();
$o->save();
$translation = $o->getTranslation();
- $this->assertEquals('en_EN', $translation->getLocale());
+ $this->assertEquals('en_US', $translation->getLocale());
$o = new I18nBehaviorTest2();
$o->save();
$translation = $o->getTranslation();
@@ -165,12 +165,12 @@ public function testGetTranslationUsesInternalCollectionIfAvailable()
{
$o = new I18nBehaviorTest1();
$translation1 = new I18nBehaviorTest1I18n();
- $translation1->setLocale('en_EN');
+ $translation1->setLocale('en_US');
$o->addI18nBehaviorTest1I18n($translation1);
$translation2 = new I18nBehaviorTest1I18n();
$translation2->setLocale('fr_FR');
$o->addI18nBehaviorTest1I18n($translation2);
- $translation = $o->getTranslation('en_EN');
+ $translation = $o->getTranslation('en_US');
$this->assertEquals($translation1, $translation);
}
@@ -178,7 +178,7 @@ public function testRemoveTranslation()
{
$o = new I18nBehaviorTest1();
$translation1 = new I18nBehaviorTest1I18n();
- $translation1->setLocale('en_EN');
+ $translation1->setLocale('en_US');
$o->addI18nBehaviorTest1I18n($translation1);
$translation2 = new I18nBehaviorTest1I18n();
$translation2->setLocale('fr_FR');
@@ -201,7 +201,7 @@ public function testLocaleSetterAndGetterExist()
public function testGetLocaleReturnsDefaultLocale()
{
$o = new I18nBehaviorTest1();
- $this->assertEquals('en_EN', $o->getLocale());
+ $this->assertEquals('en_US', $o->getLocale());
$o = new I18nBehaviorTest2();
$this->assertEquals('fr_FR', $o->getLocale());
}
@@ -218,7 +218,7 @@ public function testSetLocaleUsesDefaultLocale()
$o = new I18nBehaviorTest1();
$o->setLocale('fr_FR');
$o->setLocale();
- $this->assertEquals('en_EN', $o->getLocale());
+ $this->assertEquals('en_US', $o->getLocale());
}
public function testLocaleSetterAndGetterAliasesExist()
@@ -236,15 +236,15 @@ public function testGetLocaleAliasReturnsDefaultLocale()
public function testSetLocaleAlias()
{
$o = new I18nBehaviorTest2();
- $o->setCulture('en_EN');
- $this->assertEquals('en_EN', $o->getCulture());
+ $o->setCulture('en_US');
+ $this->assertEquals('en_US', $o->getCulture());
}
public function testGetCurrentTranslationUsesDefaultLocale()
{
$o = new I18nBehaviorTest1();
$t = $o->getCurrentTranslation();
- $this->assertEquals('en_EN', $t->getLocale());
+ $this->assertEquals('en_US', $t->getLocale());
$o = new I18nBehaviorTest2();
$t = $o->getCurrentTranslation();
$this->assertEquals('fr_FR', $t->getLocale());
@@ -268,7 +268,7 @@ public function testI18nColumnGetterUsesCurrentTranslation()
$t2 = $o->getCurrentTranslation();
$t2->setBar('bonjour');
//$o->save();
- $o->setLocale('en_EN');
+ $o->setLocale('en_US');
$this->assertEquals('hello', $o->getBar());
$o->setLocale('fr_FR');
$this->assertEquals('bonjour', $o->getBar());
@@ -280,7 +280,7 @@ public function testI18nColumnSetterUsesCurrentTranslation()
$o->setBar('hello');
$o->setLocale('fr_FR');
$o->setBar('bonjour');
- $o->setLocale('en_EN');
+ $o->setLocale('en_US');
$this->assertEquals('hello', $o->getBar());
$o->setLocale('fr_FR');
$this->assertEquals('bonjour', $o->getBar());
@@ -312,7 +312,7 @@ public function testClearRemovesExistingTranlsations()
$translation1->setLocale('fr_FR');
$o->addI18nBehaviorTest1I18n($translation1);
$o->clear();
- $this->assertEquals('en_EN', $o->getLocale());
+ $this->assertEquals('en_US', $o->getLocale());
$t1 = $o->getTranslation('fr_FR');
$this->assertEquals('', $t1->getBar());
}
@@ -398,13 +398,13 @@ public function testUseLocalColumnParameter()
{
$o = new I18nBehaviorTestLocalColumn();
$translation1 = new I18nBehaviorTestLocalColumnI18n();
- $translation1->setMyLang('en_EN');
+ $translation1->setMyLang('en_US');
$o->addI18nBehaviorTestLocalColumnI18n($translation1);
$translation2 = new I18nBehaviorTestLocalColumnI18n();
$translation2->setMyLang('fr_FR');
$o->addI18nBehaviorTestLocalColumnI18n($translation2);
$o->save();
- $this->assertEquals($translation1, $o->getTranslation('en_EN'));
+ $this->assertEquals($translation1, $o->getTranslation('en_US'));
$this->assertEquals($translation2, $o->getTranslation('fr_FR'));
}
}
View
2  test/testsuite/generator/behavior/i18n/I18nBehaviorPeerBuilderModifierTest.php
@@ -39,7 +39,7 @@ public function testDefaultLocaleConstant()
</database>
EOF;
PropelQuickBuilder::buildSchema($schema);
- $this->assertEquals('en_EN', I18nBehaviorTest01Peer::DEFAULT_LOCALE);
+ $this->assertEquals('en_US', I18nBehaviorTest01Peer::DEFAULT_LOCALE);
$this->assertEquals('fr_FR', I18nBehaviorTest02Peer::DEFAULT_LOCALE);
}
View
36 test/testsuite/generator/behavior/i18n/I18nBehaviorQueryBuilderModifierTest.php
@@ -63,7 +63,7 @@ public function testJoinI18nUsesDefaultLocaleInJoinCondition()
$sql = BasePeer::createSelectSQL($q, $params);
$expectedSQL = 'SELECT FROM i18n_behavior_test_11 LEFT JOIN i18n_behavior_test_11_i18n ON (i18n_behavior_test_11.ID=i18n_behavior_test_11_i18n.ID AND i18n_behavior_test_11_i18n.LOCALE = :p1)';
$this->assertEquals($expectedSQL, $sql);
- $this->assertEquals('en_EN', $params[0]['value']);
+ $this->assertEquals('en_US', $params[0]['value']);
}
public function testJoinI18nUsesLocaleInJoinCondition()
@@ -80,23 +80,23 @@ public function testJoinI18nUsesLocaleInJoinCondition()
public function testJoinI18nAcceptsARelationAlias()
{
$q = I18nBehaviorTest11Query::create()
- ->joinI18n('en_EN', 'I18n');
+ ->joinI18n('en_US', 'I18n');
$params = array();
$sql = BasePeer::createSelectSQL($q, $params);
$expectedSQL = 'SELECT FROM i18n_behavior_test_11 LEFT JOIN i18n_behavior_test_11_i18n I18n ON (i18n_behavior_test_11.ID=I18n.ID AND I18n.LOCALE = :p1)';
$this->assertEquals($expectedSQL, $sql);
- $this->assertEquals('en_EN', $params[0]['value']);
+ $this->assertEquals('en_US', $params[0]['value']);
}
public function testJoinI18nAcceptsAJoinType()
{
$q = I18nBehaviorTest11Query::create()
- ->joinI18n('en_EN', null, Criteria::INNER_JOIN);
+ ->joinI18n('en_US', null, Criteria::INNER_JOIN);
$params = array();
$sql = BasePeer::createSelectSQL($q, $params);
$expectedSQL = 'SELECT FROM i18n_behavior_test_11 INNER JOIN i18n_behavior_test_11_i18n ON (i18n_behavior_test_11.ID=i18n_behavior_test_11_i18n.ID AND i18n_behavior_test_11_i18n.LOCALE = :p1)';
$this->assertEquals($expectedSQL, $sql);
- $this->assertEquals('en_EN', $params[0]['value']);
+ $this->assertEquals('en_US', $params[0]['value']);
}
public function testJoinI18nCreatesACorrectQuery()
@@ -161,7 +161,7 @@ public function testJoinWithI18nAddsTheI18nColumns()
$sql = BasePeer::createSelectSQL($q, $params);
$expectedSQL = 'SELECT i18n_behavior_test_11.ID, i18n_behavior_test_11.FOO, i18n_behavior_test_11_i18n.ID, i18n_behavior_test_11_i18n.LOCALE, i18n_behavior_test_11_i18n.BAR FROM i18n_behavior_test_11 LEFT JOIN i18n_behavior_test_11_i18n ON (i18n_behavior_test_11.ID=i18n_behavior_test_11_i18n.ID AND i18n_behavior_test_11_i18n.LOCALE = :p1)';
$this->assertEquals($expectedSQL, $sql);
- $this->assertEquals('en_EN', $params[0]['value']);
+ $this->assertEquals('en_US', $params[0]['value']);
}
public function testJoinWithI18nDoesNotPruneResultsWithoutTranslation()
@@ -172,7 +172,7 @@ public function testJoinWithI18nDoesNotPruneResultsWithoutTranslation()
$o->setFoo(123);
$o->save();
$res = I18nBehaviorTest11Query::create()
- ->joinWithI18n('en_EN')
+ ->joinWithI18n('en_US')
->findOne();
$this->assertEquals($o, $res);
}
@@ -185,7 +185,7 @@ public function testJoinWithI18nPrunesResultsWithoutTranslationWhenUsingInnerJoi
$o->setFoo(123);
$o->save();
$res = I18nBehaviorTest11Query::create()
- ->joinWithI18n('en_EN', Criteria::INNER_JOIN)
+ ->joinWithI18n('en_US', Criteria::INNER_JOIN)
->findOne();
$this->assertNull($res);
}
@@ -198,7 +198,7 @@ public function testJoinWithI18nHydratesRelatedObject()
I18nBehaviorTest11I18nQuery::create()->deleteAll();
$o = new I18nBehaviorTest11();
$o->setFoo(123);
- $o->setLocale('en_EN');
+ $o->setLocale('en_US');
$o->setBar('hello');
$o->setLocale('fr_FR');
$o->setBar('bonjour');
@@ -206,10 +206,10 @@ public function testJoinWithI18nHydratesRelatedObject()
I18nBehaviorTest11Peer::clearInstancePool();
I18nBehaviorTest11I18nPeer::clearInstancePool();
$o = I18nBehaviorTest11Query::create()
- ->joinWithI18n('en_EN')
+ ->joinWithI18n('en_US')
->findOne($con);
$count = $con->getQueryCount();
- $translation = $o->getTranslation('en_EN', $con);
+ $translation = $o->getTranslation('en_US', $con);
$this->assertEquals($count, $con->getQueryCount());
$this->assertEquals('hello', $translation->getBar());
}
@@ -220,15 +220,15 @@ public function testJoinWithI18nSetsTheLocaleOnResults()
I18nBehaviorTest11I18nQuery::create()->deleteAll();
$o = new I18nBehaviorTest11();
$o->setFoo(123);
- $o->setLocale('en_EN');
+ $o->setLocale('en_US');
$o->setBar('hello');
$o->setLocale('fr_FR');
$o->setBar('bonjour');
$o->save();
$o1 = I18nBehaviorTest11Query::create()
- ->joinWithI18n('en_EN')
+ ->joinWithI18n('en_US')
->findOne();
- $this->assertEquals('en_EN', $o1->getLocale());
+ $this->assertEquals('en_US', $o1->getLocale());
$o2 = I18nBehaviorTest11Query::create()
->joinWithI18n('fr_FR')
->findOne();
@@ -238,7 +238,7 @@ public function testJoinWithI18nSetsTheLocaleOnResults()
public function testJoinWithI18nAndLimitDoesNotThrowException()
{
$res = I18nBehaviorTest11Query::create()
- ->joinWithI18n('en_EN')
+ ->joinWithI18n('en_US')
->limit(2)
->find();
$this->assertInstanceOf('PropelObjectCollection', $res);
@@ -250,7 +250,7 @@ public function testJoinWithI18nAndLimitDoesNotThrowException()
// use case:
// $o = new Object();
// $t1 = new Translation();
- // $o->setTranslation($t2, 'en_EN'); // this is what happens during joined hydration
+ // $o->setTranslation($t2, 'en_US'); // this is what happens during joined hydration
// now the translation collection exists
// $t2 = $o->getTranslation('fr_FR'); // we MUST issue a query here
public function testJoinWithI18nDoesNotExecuteAdditionalQueryWhenNoTranslationIsFound()
@@ -263,10 +263,10 @@ public function testJoinWithI18nDoesNotExecuteAdditionalQueryWhenNoTranslationIs
$o = new I18nBehaviorTest11();
$o->save();
$o = I18nBehaviorTest11Query::create()
- ->joinWithI18n('en_EN')
+ ->joinWithI18n('en_US')
->findOne($con);
$count = $con->getQueryCount();
- $translation = $o->getTranslation('en_EN', $con);
+ $translation = $o->getTranslation('en_US', $con);
$this->assertEquals($count, $con->getQueryCount());
}
View
92 test/testsuite/generator/behavior/i18n/I18nBehaviorTest.php
@@ -42,13 +42,13 @@ public function testModifyDatabaseOverridesDefaultLocale()
-- i18n_behavior_test_0_i18n
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS i18n_behavior_test_0_i18n;
+DROP TABLE IF EXISTS [i18n_behavior_test_0_i18n];
-CREATE TABLE i18n_behavior_test_0_i18n
+CREATE TABLE [i18n_behavior_test_0_i18n]
(
- id INTEGER NOT NULL,
- locale VARCHAR(5) DEFAULT 'fr_FR' NOT NULL,
- PRIMARY KEY (id,locale)
+ [id] INTEGER NOT NULL,
+ [locale] VARCHAR(5) DEFAULT 'fr_FR' NOT NULL,
+ PRIMARY KEY ([id],[locale])
);
EOF;
$this->assertContains($expected, $builder->getSQL());
@@ -76,13 +76,13 @@ public function testModifyDatabaseDoesNotOverrideTableLocale()
-- i18n_behavior_test_0_i18n
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS i18n_behavior_test_0_i18n;
+DROP TABLE IF EXISTS [i18n_behavior_test_0_i18n];
-CREATE TABLE i18n_behavior_test_0_i18n
+CREATE TABLE [i18n_behavior_test_0_i18n]
(
- id INTEGER NOT NULL,
- locale VARCHAR(5) DEFAULT 'pt_PT' NOT NULL,
- PRIMARY KEY (id,locale)
+ [id] INTEGER NOT NULL,
+ [locale] VARCHAR(5) DEFAULT 'pt_PT' NOT NULL,
+ PRIMARY KEY ([id],[locale])
);
EOF;
$this->assertContains($expected, $builder->getSQL());
@@ -111,7 +111,7 @@ public function schemaDataProvider()
</table>
<table name="i18n_behavior_test_0_i18n">
<column name="id" primaryKey="true" type="INTEGER" />
- <column name="locale" primaryKey="true" type="VARCHAR" size="5" default="en_EN" />
+ <column name="locale" primaryKey="true" type="VARCHAR" size="5" default="en_US" />
<column name="bar" type="VARCHAR" size="100" />
<foreign-key foreignTable="i18n_behavior_test_0">
<reference local="id" foreign="id" />
@@ -135,9 +135,9 @@ public function testModifyTableAddsI18nTable($schema)
-- i18n_behavior_test_0_i18n
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS i18n_behavior_test_0_i18n;
+DROP TABLE IF EXISTS [i18n_behavior_test_0_i18n];
-CREATE TABLE i18n_behavior_test_0_i18n
+CREATE TABLE [i18n_behavior_test_0_i18n]
EOF;
$this->assertContains($expected, $builder->getSQL());
}
@@ -150,7 +150,7 @@ public function testModifyTableRelatesI18nTableToMainTable($schema)
$builder = new PropelQuickBuilder();
$builder->setSchema($schema);
$expected = <<<EOF
--- FOREIGN KEY (id) REFERENCES i18n_behavior_test_0 (id)
+-- FOREIGN KEY ([id]) REFERENCES i18n_behavior_test_0 ([id])
EOF;
$this->assertContains($expected, $builder->getSQL());
}
@@ -163,10 +163,10 @@ public function testModifyTableAddsLocaleColumnToI18n($schema)
$builder = new PropelQuickBuilder();
$builder->setSchema($schema);
$expected = <<<EOF
-CREATE TABLE i18n_behavior_test_0_i18n
+CREATE TABLE [i18n_behavior_test_0_i18n]
(
- id INTEGER NOT NULL,
- locale VARCHAR(5) DEFAULT 'en_EN' NOT NULL,
+ [id] INTEGER NOT NULL,
+ [locale] VARCHAR(5) DEFAULT 'en_US' NOT NULL,
EOF;
$this->assertContains($expected, $builder->getSQL());
}
@@ -179,12 +179,12 @@ public function testModifyTableMovesI18nColumns($schema)
$builder = new PropelQuickBuilder();
$builder->setSchema($schema);
$expected = <<<EOF
-CREATE TABLE i18n_behavior_test_0_i18n
+CREATE TABLE [i18n_behavior_test_0_i18n]
(
- id INTEGER NOT NULL,
- locale VARCHAR(5) DEFAULT 'en_EN' NOT NULL,
- bar VARCHAR(100),
- PRIMARY KEY (id,locale)
+ [id] INTEGER NOT NULL,
+ [locale] VARCHAR(5) DEFAULT 'en_US' NOT NULL,
+ [bar] VARCHAR(100),
+ PRIMARY KEY ([id],[locale])
);
EOF;
$this->assertContains($expected, $builder->getSQL());
@@ -198,10 +198,10 @@ public function testModifyTableDoesNotMoveNonI18nColumns($schema)
$builder = new PropelQuickBuilder();
$builder->setSchema($schema);
$expected = <<<EOF
-CREATE TABLE i18n_behavior_test_0
+CREATE TABLE [i18n_behavior_test_0]
(
- id INTEGER NOT NULL PRIMARY KEY,
- foo INTEGER
+ [id] INTEGER NOT NULL PRIMARY KEY,
+ [foo] INTEGER
);
EOF;
$this->assertContains($expected, $builder->getSQL());
@@ -276,13 +276,13 @@ public function testModiFyTableUsesCustomI18nTableName()
-- foo_table
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS foo_table;
+DROP TABLE IF EXISTS [foo_table];
-CREATE TABLE foo_table
+CREATE TABLE [foo_table]
(
- id INTEGER NOT NULL,
- locale VARCHAR(5) DEFAULT 'en_EN' NOT NULL,
- PRIMARY KEY (id,locale)
+ [id] INTEGER NOT NULL,
+ [locale] VARCHAR(5) DEFAULT 'en_US' NOT NULL,
+ PRIMARY KEY ([id],[locale])
);
EOF;
$this->assertContains($expected, $builder->getSQL());
@@ -307,13 +307,13 @@ public function testModiFyTableUsesCustomLocaleColumnName()
-- i18n_behavior_test_0_i18n
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS i18n_behavior_test_0_i18n;
+DROP TABLE IF EXISTS [i18n_behavior_test_0_i18n];
-CREATE TABLE i18n_behavior_test_0_i18n
+CREATE TABLE [i18n_behavior_test_0_i18n]
(
- id INTEGER NOT NULL,
- culture VARCHAR(5) DEFAULT 'en_EN' NOT NULL,
- PRIMARY KEY (id,culture)
+ [id] INTEGER NOT NULL,
+ [culture] VARCHAR(5) DEFAULT 'en_US' NOT NULL,
+ PRIMARY KEY ([id],[culture])
);
EOF;
$this->assertContains($expected, $builder->getSQL());
@@ -338,13 +338,13 @@ public function testModiFyTableUsesCustomLocaleDefault()
-- i18n_behavior_test_0_i18n
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS i18n_behavior_test_0_i18n;
+DROP TABLE IF EXISTS [i18n_behavior_test_0_i18n];
-CREATE TABLE i18n_behavior_test_0_i18n
+CREATE TABLE [i18n_behavior_test_0_i18n]
(
- id INTEGER NOT NULL,
- locale VARCHAR(5) DEFAULT 'fr_FR' NOT NULL,
- PRIMARY KEY (id,locale)
+ [id] INTEGER NOT NULL,
+ [locale] VARCHAR(5) DEFAULT 'fr_FR' NOT NULL,
+ PRIMARY KEY ([id],[locale])
);
EOF;
$this->assertContains($expected, $builder->getSQL());
@@ -382,20 +382,20 @@ public function testModifyTableUseCustomPkName()
$this->assertEquals(count($fkList), 1);
$fk = array_pop($fkList);
$this->assertEquals($fk->getForeignTableName(), 'i18n_behavior_test_0');
- $this->assertEquals($fk->getForeignColumnNames(), 'id');
+ $this->assertEquals($fk->getForeignColumnNames(), '[id]');
$expected = <<<EOF
-----------------------------------------------------------------------
-- i18n_behavior_test_0_i18n
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS i18n_behavior_test_0_i18n;
+DROP TABLE IF EXISTS [i18n_behavior_test_0_i18n];
-CREATE TABLE i18n_behavior_test_0_i18n
+CREATE TABLE [i18n_behavior_test_0_i18n]
(
- custom_id INTEGER NOT NULL,
- locale VARCHAR(5) DEFAULT 'fr_FR' NOT NULL,
- PRIMARY KEY (custom_id,locale)
+ [custom_id] INTEGER NOT NULL,
+ [locale] VARCHAR(5) DEFAULT 'fr_FR' NOT NULL,
+ PRIMARY KEY ([custom_id],[locale])
);
EOF;
$this->assertContains($expected, $builder->getSQL());
View
184 test/testsuite/generator/behavior/versionable/VersionableBehaviorTest.php
@@ -49,13 +49,13 @@ public function testModifyTableAddsVersionColumn($schema)
-- versionable_behavior_test_0
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS versionable_behavior_test_0;
+DROP TABLE IF EXISTS [versionable_behavior_test_0];
-CREATE TABLE versionable_behavior_test_0
+CREATE TABLE [versionable_behavior_test_0]
(
- id INTEGER NOT NULL PRIMARY KEY,
- bar INTEGER,
- version INTEGER DEFAULT 0
+ [id] INTEGER NOT NULL PRIMARY KEY,
+ [bar] INTEGER,
+ [version] INTEGER DEFAULT 0
);
EOF;
$this->assertContains($expected, $builder->getSQL());
@@ -81,13 +81,13 @@ public function testModifyTableAddsVersionColumnCustomName()
-- versionable_behavior_test_0
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS versionable_behavior_test_0;
+DROP TABLE IF EXISTS [versionable_behavior_test_0];
-CREATE TABLE versionable_behavior_test_0
+CREATE TABLE [versionable_behavior_test_0]
(
- id INTEGER NOT NULL PRIMARY KEY,
- bar INTEGER,
- foo_ver INTEGER DEFAULT 0
+ [id] INTEGER NOT NULL PRIMARY KEY,
+ [bar] INTEGER,
+ [foo_ver] INTEGER DEFAULT 0
);
EOF;
$this->assertContains($expected, $builder->getSQL());
@@ -112,13 +112,13 @@ public function testModifyTableDoesNotAddVersionColumnIfExists()
-- versionable_behavior_test_0
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS versionable_behavior_test_0;
+DROP TABLE IF EXISTS [versionable_behavior_test_0];
-CREATE TABLE versionable_behavior_test_0
+CREATE TABLE [versionable_behavior_test_0]
(
- id INTEGER NOT NULL PRIMARY KEY,
- bar INTEGER,
- version BIGINT
+ [id] INTEGER NOT NULL PRIMARY KEY,
+ [bar] INTEGER,
+ [version] BIGINT
);
EOF;
$this->assertContains($expected, $builder->getSQL());
@@ -160,14 +160,14 @@ public function testModifyTableAddsVersionColumnForForeignKeysIfForeignTableIsVe
-- versionable_behavior_test_0
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS versionable_behavior_test_0;
+DROP TABLE IF EXISTS [versionable_behavior_test_0];
-CREATE TABLE versionable_behavior_test_0
+CREATE TABLE [versionable_behavior_test_0]
(
- id INTEGER NOT NULL PRIMARY KEY,
- bar INTEGER,
- foreign_id INTEGER,
- version INTEGER DEFAULT 0
+ [id] INTEGER NOT NULL PRIMARY KEY,
+ [bar] INTEGER,
+ [foreign_id] INTEGER,
+ [version] INTEGER DEFAULT 0
);
EOF;
$this->assertContains($expected, $builder->getSQL());
@@ -177,20 +177,20 @@ public function testModifyTableAddsVersionColumnForForeignKeysIfForeignTableIsVe
-- versionable_behavior_test_0_version
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS versionable_behavior_test_0_version;
+DROP TABLE IF EXISTS [versionable_behavior_test_0_version];
-CREATE TABLE versionable_behavior_test_0_version
+CREATE TABLE [versionable_behavior_test_0_version]
(
- id INTEGER NOT NULL,
- bar INTEGER,
- foreign_id INTEGER,
- version INTEGER DEFAULT 0 NOT NULL,
- foreign_id_version INTEGER DEFAULT 0,
- PRIMARY KEY (id,version)
+ [id] INTEGER NOT NULL,
+ [bar] INTEGER,
+ [foreign_id] INTEGER,
+ [version] INTEGER DEFAULT 0 NOT NULL,
+ [foreign_id_version] INTEGER DEFAULT 0,
+ PRIMARY KEY ([id],[version])
);
-- SQLite does not support foreign keys; this is just for reference
--- FOREIGN KEY (id) REFERENCES versionable_behavior_test_0 (id)
+-- FOREIGN KEY ([id]) REFERENCES versionable_behavior_test_0 ([id])
EOF;
$this->assertContains($expected, $builder->getSQL());
}
@@ -207,13 +207,13 @@ public function testModifyTableAddsVersionColumnForReferrersIfForeignTableIsVers
-- versionable_behavior_test_1
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS versionable_behavior_test_1;
+DROP TABLE IF EXISTS [versionable_behavior_test_1];
-CREATE TABLE versionable_behavior_test_1
+CREATE TABLE [versionable_behavior_test_1]
(
- id INTEGER NOT NULL PRIMARY KEY,
- bar INTEGER,
- version INTEGER DEFAULT 0
+ [id] INTEGER NOT NULL PRIMARY KEY,
+ [bar] INTEGER,
+ [version] INTEGER DEFAULT 0
);
EOF;
$this->assertContains($expected, $builder->getSQL());
@@ -223,20 +223,20 @@ public function testModifyTableAddsVersionColumnForReferrersIfForeignTableIsVers
-- versionable_behavior_test_1_version
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS versionable_behavior_test_1_version;
+DROP TABLE IF EXISTS [versionable_behavior_test_1_version];
-CREATE TABLE versionable_behavior_test_1_version
+CREATE TABLE [versionable_behavior_test_1_version]
(
- id INTEGER NOT NULL,
- bar INTEGER,
- version INTEGER DEFAULT 0 NOT NULL,
- versionable_behavior_test_0_ids MEDIUMTEXT,
- versionable_behavior_test_0_versions MEDIUMTEXT,
- PRIMARY KEY (id,version)
+ [id] INTEGER NOT NULL,
+ [bar] INTEGER,
+ [version] INTEGER DEFAULT 0 NOT NULL,
+ [versionable_behavior_test_0_ids] MEDIUMTEXT,
+ [versionable_behavior_test_0_versions] MEDIUMTEXT,
+ PRIMARY KEY ([id],[version])
);
-- SQLite does not support foreign keys; this is just for reference
--- FOREIGN KEY (id) REFERENCES versionable_behavior_test_1 (id)
+-- FOREIGN KEY ([id]) REFERENCES versionable_behavior_test_1 ([id])
EOF;
$this->assertContains($expected, $builder->getSQL());
}
@@ -253,18 +253,18 @@ public function testModifyTableAddsVersionTable($schema)
-- versionable_behavior_test_0_version
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS versionable_behavior_test_0_version;
+DROP TABLE IF EXISTS [versionable_behavior_test_0_version];
-CREATE TABLE versionable_behavior_test_0_version
+CREATE TABLE [versionable_behavior_test_0_version]
(
- id INTEGER NOT NULL,
- bar INTEGER,
- version INTEGER DEFAULT 0 NOT NULL,
- PRIMARY KEY (id,version)
+ [id] INTEGER NOT NULL,
+ [bar] INTEGER,
+ [version] INTEGER DEFAULT 0 NOT NULL,
+ PRIMARY KEY ([id],[version])
);
-- SQLite does not support foreign keys; this is just for reference
--- FOREIGN KEY (id) REFERENCES versionable_behavior_test_0 (id)
+-- FOREIGN KEY ([id]) REFERENCES versionable_behavior_test_0 ([id])
EOF;
$this->assertContains($expected, $builder->getSQL());
}
@@ -289,18 +289,18 @@ public function testModifyTableAddsVersionTableCustomName()
-- foo_ver
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS foo_ver;
+DROP TABLE IF EXISTS [foo_ver];
-CREATE TABLE foo_ver
+CREATE TABLE [foo_ver]
(
- id INTEGER NOT NULL,
- bar INTEGER,
- version INTEGER DEFAULT 0 NOT NULL,
- PRIMARY KEY (id,version)
+ [id] INTEGER NOT NULL,
+ [bar] INTEGER,
+ [version] INTEGER DEFAULT 0 NOT NULL,
+ PRIMARY KEY ([id],[version])
);
-- SQLite does not support foreign keys; this is just for reference
--- FOREIGN KEY (id) REFERENCES versionable_behavior_test_0 (id)
+-- FOREIGN KEY ([id]) REFERENCES versionable_behavior_test_0 ([id])
EOF;
$this->assertContains($expected, $builder->getSQL());
}
@@ -328,25 +328,25 @@ public function testModifyTableDoesNotAddVersionTableIfExists()
-- versionable_behavior_test_0
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS versionable_behavior_test_0;
+DROP TABLE IF EXISTS [versionable_behavior_test_0];
-CREATE TABLE versionable_behavior_test_0
+CREATE TABLE [versionable_behavior_test_0]
(
- id INTEGER NOT NULL PRIMARY KEY,
- bar INTEGER,
- version INTEGER DEFAULT 0
+ [id] INTEGER NOT NULL PRIMARY KEY,
+ [bar] INTEGER,
+ [version] INTEGER DEFAULT 0
);
-----------------------------------------------------------------------
-- versionable_behavior_test_0_version
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS versionable_behavior_test_0_version;
+DROP TABLE IF EXISTS [versionable_behavior_test_0_version];
-CREATE TABLE versionable_behavior_test_0_version
+CREATE TABLE [versionable_behavior_test_0_version]
(
- id INTEGER NOT NULL PRIMARY KEY,
- baz INTEGER
+ [id] INTEGER NOT NULL PRIMARY KEY,
+ [baz] INTEGER
);
EOF;
@@ -384,16 +384,16 @@ public function testModifyTableAddsLogColumns($schema)
-- versionable_behavior_test_0
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS versionable_behavior_test_0;
+DROP TABLE IF EXISTS [versionable_behavior_test_0];
-CREATE TABLE versionable_behavior_test_0
+CREATE TABLE [versionable_behavior_test_0]
(
- id INTEGER NOT NULL PRIMARY KEY,
- bar INTEGER,
- version INTEGER DEFAULT 0,
- version_created_at TIMESTAMP,
- version_created_by VARCHAR(100),
- version_comment VARCHAR(255)
+ [id] INTEGER NOT NULL PRIMARY KEY,
+ [bar] INTEGER,
+ [version] INTEGER DEFAULT 0,
+ [version_created_at] TIMESTAMP,
+ [version_created_by] VARCHAR(100),
+ [version_comment] VARCHAR(255)
);
EOF;
$this->assertContains($expected, $builder->getSQL());
@@ -411,21 +411,21 @@ public function testModifyTableAddsVersionTableLogColumns($schema)
-- versionable_behavior_test_0_version
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS versionable_behavior_test_0_version;
+DROP TABLE IF EXISTS [versionable_behavior_test_0_version];
-CREATE TABLE versionable_behavior_test_0_version
+CREATE TABLE [versionable_behavior_test_0_version]
(
- id INTEGER NOT NULL,
- bar INTEGER,
- version INTEGER DEFAULT 0 NOT NULL,
- version_created_at TIMESTAMP,
- version_created_by VARCHAR(100),
- version_comment VARCHAR(255),
- PRIMARY KEY (id,version)
+ [id] INTEGER NOT NULL,
+ [bar] INTEGER,
+ [version] INTEGER DEFAULT 0 NOT NULL,
+ [version_created_at] TIMESTAMP,
+ [version_created_by] VARCHAR(100),
+ [version_comment] VARCHAR(255),
+ PRIMARY KEY ([id],[version])
);
-- SQLite does not support foreign keys; this is just for reference
--- FOREIGN KEY (id) REFERENCES versionable_behavior_test_0 (id)
+-- FOREIGN KEY ([id]) REFERENCES versionable_behavior_test_0 ([id])
EOF;
$this->assertContains($expected, $builder->getSQL());
}
@@ -448,18 +448,18 @@ public function testDatabaseLevelBehavior()
-- versionable_behavior_test_0_version
-----------------------------------------------------------------------
-DROP TABLE IF EXISTS versionable_behavior_test_0_version;
+DROP TABLE IF EXISTS [versionable_behavior_test_0_version];
-CREATE TABLE versionable_behavior_test_0_version
+CREATE TABLE [versionable_behavior_test_0_version]
(
- id INTEGER NOT NULL,
- bar INTEGER,
- version INTEGER DEFAULT 0 NOT NULL,
- PRIMARY KEY (id,version)
+ [id] INTEGER NOT NULL,
+ [bar] INTEGER,
+ [version] INTEGER DEFAULT 0 NOT NULL,
+ PRIMARY KEY ([id],[version])
);
-- SQLite does not support foreign keys; this is just for reference
--- FOREIGN KEY (id) REFERENCES versionable_behavior_test_0 (id)
+-- FOREIGN KEY ([id]) REFERENCES versionable_behavior_test_0 ([id])
EOF;
$this->assertContains($expected, $builder->getSQL());
}
View
9 test/testsuite/generator/builder/om/GeneratedObjectTest.php
@@ -1047,7 +1047,14 @@ public function testPostDelete()
$author->delete();
$this->assertEquals("Post-Deleted", $author->getLastName());
}
-
+
+ public function testPostHydrate()
+ {
+ $author = new TestAuthor();
+ $author->hydrate(array(1, 'bogus', 'Lastname', 'bogus@mail.com', 21));
+ $this->assertEquals("Post-Hydrated", $author->getLastName());
+ }
+
public function testMagicVirtualColumnGetter()
{
$book = new Book();
View
14 test/testsuite/generator/builder/om/QueryBuilderInheritanceTest.php
@@ -159,5 +159,19 @@ public function testFindPkSimpleWithAbstractSingleTableInheritanceReturnCorrect
Propel::enableInstancePooling();
}
+
+ public function testFindOneOrCreateFunction()
+ {
+ $cashier1 = new BookstoreCashier();
+ $cashier1->save($this->con);
+
+ $cashier2 = BookstoreCashierQuery::create()->findOneOrCreate($this->con);
+ $this->assertInstanceOf('BookstoreCashier', $cashier2, 'findOneOrCreate return right object when find one : BookstoreCashier');
+
+ BookstoreCashierQuery::create()->deleteAll($this->con);
+
+ $cashier3 = BookstoreCashierQuery::create()->findOneOrCreate($this->con);
+ $this->assertInstanceOf('BookstoreCashier', $cashier3, 'findOneOrCreate return right object when create one : BookstoreCashier');
+ }
}
View
2  test/testsuite/generator/model/ColumnTest.php
@@ -29,7 +29,7 @@ class ColumnTest extends PHPUnit_Framework_TestCase
*/
public function testMakeList()
{
- $expected = 'Column0, Column1, Column2, Column3, Column4';
+ $expected = '"Column0", "Column1", "Column2", "Column3", "Column4"';
$objArray = array();
for ($i=0; $i<5; $i++) {
$c = new Column();
View
151 test/testsuite/generator/platform/MssqlPlatformTest.php
@@ -62,7 +62,7 @@ public function testGetAddTablesDDL($schema)
-----------------------------------------------------------------------
IF EXISTS (SELECT 1 FROM sysobjects WHERE type ='RI' AND name='book_FK_1')
- ALTER TABLE book DROP CONSTRAINT book_FK_1;
+ ALTER TABLE [book] DROP CONSTRAINT [book_FK_1];
IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'book')
BEGIN
@@ -86,21 +86,21 @@ public function testGetAddTablesDDL($schema)
END
CLOSE refcursor
DEALLOCATE refcursor
- DROP TABLE book
+ DROP TABLE [book]
END
-CREATE TABLE book
+CREATE TABLE [book]
(
- id INT NOT NULL IDENTITY,
- title VARCHAR(255) NOT NULL,
- author_id INT NULL,
- CONSTRAINT book_PK PRIMARY KEY (id)
+ [id] INT NOT NULL IDENTITY,
+ [title] VARCHAR(255) NOT NULL,
+ [author_id] INT NULL,
+ CONSTRAINT [book_PK] PRIMARY KEY ([id])
);
-CREATE INDEX book_I_1 ON book (title);
+CREATE INDEX [book_I_1] ON [book] ([title]);
BEGIN
-ALTER TABLE book ADD CONSTRAINT book_FK_1 FOREIGN KEY (author_id) REFERENCES author (id)
+ALTER TABLE [book] ADD CONSTRAINT [book_FK_1] FOREIGN KEY ([author_id]) REFERENCES [author] ([id])
END
;
@@ -130,15 +130,15 @@ public function testGetAddTablesDDL($schema)
END
CLOSE refcursor
DEALLOCATE refcursor
- DROP TABLE author
+ DROP TABLE [author]
END
-CREATE TABLE author
+CREATE TABLE [author]
(
- id INT NOT NULL IDENTITY,
- first_name VARCHAR(100) NULL,
- last_name VARCHAR(100) NULL,
- CONSTRAINT author_PK PRIMARY KEY (id)
+ [id] INT NOT NULL IDENTITY,
+ [first_name] VARCHAR(100) NULL,
+ [last_name] VARCHAR(100) NULL,
+ CONSTRAINT [author_PK] PRIMARY KEY ([id])
);
EOF;
@@ -158,7 +158,7 @@ public function testGetAddTablesDDLSchemas($schema)
-----------------------------------------------------------------------
IF EXISTS (SELECT 1 FROM sysobjects WHERE type ='RI' AND name='book_FK_1')
- ALTER TABLE x.book DROP CONSTRAINT book_FK_1;
+ ALTER TABLE [x].[book] DROP CONSTRAINT [book_FK_1];
IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'x.book')
BEGIN
@@ -182,21 +182,21 @@ public function testGetAddTablesDDLSchemas($schema)
END
CLOSE refcursor
DEALLOCATE refcursor
- DROP TABLE x.book
+ DROP TABLE [x].[book]
END
-CREATE TABLE x.book
+CREATE TABLE [x].[book]
(
- id INT NOT NULL IDENTITY,
- title VARCHAR(255) NOT NULL,
- author_id INT NULL,
- CONSTRAINT book_PK PRIMARY KEY (id)
+ [id] INT NOT NULL IDENTITY,
+ [title] VARCHAR(255) NOT NULL,
+ [author_id] INT NULL,
+ CONSTRAINT [book_PK] PRIMARY KEY ([id])
);
-CREATE INDEX book_I_1 ON x.book (title);
+CREATE INDEX [book_I_1] ON [x].[book] ([title]);
BEGIN
-ALTER TABLE x.book ADD CONSTRAINT book_FK_1 FOREIGN KEY (author_id) REFERENCES y.author (id)
+ALTER TABLE [x].[book] ADD CONSTRAINT [book_FK_1] FOREIGN KEY ([author_id]) REFERENCES [y].[author] ([id])
END
;
@@ -226,15 +226,15 @@ public function testGetAddTablesDDLSchemas($schema)
END
CLOSE refcursor
DEALLOCATE refcursor
- DROP TABLE y.author
+ DROP TABLE [y].[author]
END
-CREATE TABLE y.author
+CREATE TABLE [y].[author]
(
- id INT NOT NULL IDENTITY,
- first_name VARCHAR(100) NULL,
- last_name VARCHAR(100) NULL,
- CONSTRAINT author_PK PRIMARY KEY (id)
+ [id] INT NOT NULL IDENTITY,
+ [first_name] VARCHAR(100) NULL,
+ [last_name] VARCHAR(100) NULL,
+ CONSTRAINT [author_PK] PRIMARY KEY ([id])
);
-----------------------------------------------------------------------
@@ -242,7 +242,7 @@ public function testGetAddTablesDDLSchemas($schema)
-----------------------------------------------------------------------
IF EXISTS (SELECT 1 FROM sysobjects WHERE type ='RI' AND name='book_summary_FK_1')
- ALTER TABLE x.book_summary DROP CONSTRAINT book_summary_FK_1;
+ ALTER TABLE [x].[book_summary] DROP CONSTRAINT [book_summary_FK_1];
IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'x.book_summary')
BEGIN
@@ -266,19 +266,19 @@ public function testGetAddTablesDDLSchemas($schema)
END
CLOSE refcursor
DEALLOCATE refcursor
- DROP TABLE x.book_summary
+ DROP TABLE [x].[book_summary]
END
-CREATE TABLE x.book_summary
+CREATE TABLE [x].[book_summary]
(
- id INT NOT NULL IDENTITY,
- book_id INT NOT NULL,
- summary VARCHAR(MAX) NOT NULL,
- CONSTRAINT book_summary_PK PRIMARY KEY (id)
+ [id] INT NOT NULL IDENTITY,
+ [book_id] INT NOT NULL,
+ [summary] VARCHAR(MAX) NOT NULL,
+ CONSTRAINT [book_summary_PK] PRIMARY KEY ([id])
);
BEGIN
-ALTER TABLE x.book_summary ADD CONSTRAINT book_summary_FK_1 FOREIGN KEY (book_id) REFERENCES x.book (id) ON DELETE CASCADE
+ALTER TABLE [x].[book_summary] ADD CONSTRAINT [book_summary_FK_1] FOREIGN KEY ([book_id]) REFERENCES [x].[book] ([id]) ON DELETE CASCADE
END
;
@@ -304,11 +304,11 @@ public function testGetAddTableDDLSimplePK($schema)
$table = $this->getTableFromSchema($schema);
$expected = "
-- This is foo table
-CREATE TABLE foo
+CREATE TABLE [foo]
(
- id INT NOT NULL IDENTITY,
- bar VARCHAR(255) NOT NULL,
- CONSTRAINT foo_PK PRIMARY KEY (id)
+ [id] INT NOT NULL IDENTITY,
+ [bar] VARCHAR(255) NOT NULL,
+ CONSTRAINT [foo_PK] PRIMARY KEY ([id])
);
";
$this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table));
@@ -321,12 +321,12 @@ public function testGetAddTableDDLCompositePK($schema)
{
$table = $this->getTableFromSchema($schema);
$expected = "
-CREATE TABLE foo
+CREATE TABLE [foo]
(
- foo INT NOT NULL,
- bar INT NOT NULL,
- baz VARCHAR(255) NOT NULL,
- CONSTRAINT foo_PK PRIMARY KEY (foo,bar)
+ [foo] INT NOT NULL,
+ [bar] INT NOT NULL,
+ [baz] VARCHAR(255) NOT NULL,
+ CONSTRAINT [foo_PK] PRIMARY KEY ([foo],[bar])
);
";
$this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table));
@@ -339,12 +339,12 @@ public function testGetAddTableDDLUniqueIndex($schema)
{
$table = $this->getTableFromSchema($schema);
$expected = "
-CREATE TABLE foo
+CREATE TABLE [foo]
(
- id INT NOT NULL IDENTITY,
- bar INT NULL,
- CONSTRAINT foo_PK PRIMARY KEY (id),
- UNIQUE (bar)
+ [id] INT NOT NULL IDENTITY,
+ [bar] INT NULL,
+ CONSTRAINT [foo_PK] PRIMARY KEY ([id]),
+ UNIQUE ([bar])
);
";
$this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table));
@@ -357,11 +357,11 @@ public function testGetAddTableDDLSchema($schema)
{
$table = $this->getTableFromSchema($schema, 'Woopah.foo');
$expected = "
-CREATE TABLE Woopah.foo
+CREATE TABLE [Woopah].[foo]
(
- id INT NOT NULL IDENTITY,
- bar INT NULL,
- CONSTRAINT foo_PK PRIMARY KEY (id)
+ [id] INT NOT NULL IDENTITY,
+ [bar] INT NULL,
+ CONSTRAINT [foo_PK] PRIMARY KEY ([id])
);
";
$this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table));
@@ -393,7 +393,7 @@ public function testGetDropTableDDL()
END
CLOSE refcursor
DEALLOCATE refcursor
- DROP TABLE foo
+ DROP TABLE [foo]
END
";
$this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table));
@@ -428,7 +428,7 @@ public function testGetDropTableDDLSchema($schema)
END
CLOSE refcursor
DEALLOCATE refcursor
- DROP TABLE Woopah.foo
+ DROP TABLE [Woopah].[foo]
END
";
$this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table));
@@ -443,7 +443,8 @@ public function testGetColumnDDLCustomSqlType()
$column->setNotNull(true);
$column->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE));
$column->getDomain()->replaceSqlType('DECIMAL(5,6)');
- $expected = 'foo DECIMAL(5,6) DEFAULT 123 NOT NULL';
+
+ $expected = '[foo] DECIMAL(5,6) DEFAULT 123 NOT NULL';
$this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column));
}
@@ -453,7 +454,8 @@ public function testGetPrimaryKeyDDLSimpleKey()
$column = new Column('bar');
$column->setPrimaryKey(true);
$table->addColumn($column);
- $expected = 'CONSTRAINT foo_PK PRIMARY KEY (bar)';
+
+ $expected = 'CONSTRAINT [foo_PK] PRIMARY KEY ([bar])';
$this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table));
}
@@ -466,7 +468,8 @@ public function testGetPrimaryKeyDDLCompositeKey()
$column2 = new Column('bar2');
$column2->setPrimaryKey(true);
$table->addColumn($column2);
- $expected = 'CONSTRAINT foo_PK PRIMARY KEY (bar1,bar2)';
+
+ $expected = 'CONSTRAINT [foo_PK] PRIMARY KEY ([bar1],[bar2])';
$this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table));
}
@@ -476,7 +479,7 @@ public function testGetPrimaryKeyDDLCompositeKey()
public function testGetDropPrimaryKeyDDL($table)
{
$expected = "
-ALTER TABLE foo DROP CONSTRAINT foo_PK;
+ALTER TABLE [foo] DROP CONSTRAINT [foo_PK];
";
$this->assertEquals($expected, $this->getPlatform()->getDropPrimaryKeyDDL($table));
}
@@ -487,7 +490,7 @@ public function testGetDropPrimaryKeyDDL($table)
public function testGetAddPrimaryKeyDDL($table)
{
$expected = "
-ALTER TABLE foo ADD CONSTRAINT foo_PK PRIMARY KEY (bar);
+ALTER TABLE [foo] ADD CONSTRAINT [foo_PK] PRIMARY KEY ([bar]);
";
$this->assertEquals($expected, $this->getPlatform()->getAddPrimaryKeyDDL($table));
}
@@ -498,9 +501,9 @@ public function testGetAddPrimaryKeyDDL($table)
public function testAddIndicesDDL($table)
{
$expected = "
-CREATE INDEX babar ON foo (bar1,bar2);
+CREATE INDEX [babar] ON [foo] ([bar1],[bar2]);
-CREATE INDEX foo_index ON foo (bar1);
+CREATE INDEX [foo_index] ON [foo] ([bar1]);
";
$this->assertEquals($expected, $this->getPLatform()->getAddIndicesDDL($table));
}
@@ -511,7 +514,7 @@ public function testAddIndicesDDL($table)
public function testAddIndexDDL($index)
{
$expected = "
-CREATE INDEX babar ON foo (bar1,bar2);
+CREATE INDEX [babar] ON [foo] ([bar1],[bar2]);
";
$this->assertEquals($expected, $this->getPLatform()->getAddIndexDDL($index));
}
@@ -522,7 +525,7 @@ public function testAddIndexDDL($index)
public function testDropIndexDDL($index)
{
$expected = "
-DROP INDEX babar;
+DROP INDEX [babar];
";
$this->assertEquals($expected, $this->getPLatform()->getDropIndexDDL($index));
}
@@ -532,7 +535,7 @@ public function testDropIndexDDL($index)
*/
public function testGetIndexDDL($index)
{
- $expected = 'INDEX babar (bar1,bar2)';
+ $expected = 'INDEX [babar] ([bar1],[bar2])';
$this->assertEquals($expected, $this->getPLatform()->getIndexDDL($index));
}
@@ -541,7 +544,7 @@ public function testGetIndexDDL($index)
*/
public function testGetUniqueDDL($index)
{
- $expected = 'UNIQUE (bar1,bar2)';
+ $expected = 'UNIQUE ([bar1],[bar2])';
$this->assertEquals($expected, $this->getPLatform()->getUniqueDDL($index));
}
@@ -552,12 +555,12 @@ public function testGetAddForeignKeysDDL($table)
{
$expected = "
BEGIN
-ALTER TABLE foo ADD CONSTRAINT foo_bar_FK FOREIGN KEY (bar_id) REFERENCES bar (id) ON DELETE CASCADE
+ALTER TABLE [foo] ADD CONSTRAINT [foo_bar_FK] FOREIGN KEY ([bar_id]) REFERENCES [bar] ([id]) ON DELETE CASCADE
END
;
BEGIN
-ALTER TABLE foo ADD CONSTRAINT foo_baz_FK FOREIGN KEY (baz_id) REFERENCES baz (id)
+ALTER TABLE [foo] ADD CONSTRAINT [foo_baz_FK] FOREIGN KEY ([baz_id]) REFERENCES [baz] ([id])
END
;
";
@@ -571,7 +574,7 @@ public function testGetAddForeignKeyDDL($fk)
{
$expected = "
BEGIN
-ALTER TABLE foo ADD CONSTRAINT foo_bar_FK FOREIGN KEY (bar_id) REFERENCES bar (id) ON DELETE CASCADE
+ALTER TABLE [foo] ADD CONSTRAINT [foo_bar_FK] FOREIGN KEY ([bar_id]) REFERENCES [bar] ([id]) ON DELETE CASCADE
END
;
";
@@ -593,7 +596,7 @@ public function testGetAddForeignKeySkipSqlDDL($fk)
public function testGetDropForeignKeyDDL($fk)
{
$expected = "
-ALTER TABLE foo DROP CONSTRAINT foo_bar_FK;
+ALTER TABLE [foo] DROP CONSTRAINT [foo_bar_FK];
";
$this->assertEquals($expected, $this->getPLatform()->getDropForeignKeyDDL($fk));
}
@@ -612,7 +615,7 @@ public function testGetDropForeignKeySkipSqlDDL($fk)
*/
public function testGetForeignKeyDDL($fk)
{
- $expected = 'CONSTRAINT foo_bar_FK FOREIGN KEY (bar_id) REFERENCES bar (id) ON DELETE CASCADE';
+ $expected = 'CONSTRAINT [foo_bar_FK] FOREIGN KEY ([bar_id]) REFERENCES [bar] ([id]) ON DELETE CASCADE';
$this->assertEquals($expected, $this->getPLatform()->getForeignKeyDDL($fk));
}
View
130 test/testsuite/generator/platform/PgsqlPlatformMigrationTest.php
@@ -37,23 +37,23 @@ public function testGetModifyDatabaseDDL($databaseDiff)
{
$expected = <<<END
-DROP TABLE IF EXISTS foo1 CASCADE;
+DROP TABLE IF EXISTS "foo1" CASCADE;
-ALTER TABLE foo3 RENAME TO foo4;
+ALTER TABLE "foo3" RENAME TO "foo4";
-CREATE TABLE foo5
+CREATE TABLE "foo5"
(
- id serial NOT NULL,
- lkdjfsh INTEGER,
- dfgdsgf TEXT,
- PRIMARY KEY (id)
+ "id" serial NOT NULL,
+ "lkdjfsh" INTEGER,
+ "dfgdsgf" TEXT,
+ PRIMARY KEY ("id")
);
-ALTER TABLE foo2 RENAME COLUMN bar TO bar1;
+ALTER TABLE "foo2" RENAME COLUMN "bar" TO "bar1";
-ALTER TABLE foo2 ALTER COLUMN baz DROP NOT NULL;
+ALTER TABLE "foo2" ALTER COLUMN "baz" DROP NOT NULL;
-ALTER TABLE foo2 ADD baz3 TEXT;
+ALTER TABLE "foo2" ADD "baz3" TEXT;
END;
$this->assertEquals($expected, $this->getPlatform()->getModifyDatabaseDDL($databaseDiff));
@@ -64,9 +64,9 @@ public function testGetModifyDatabaseDDL($databaseDiff)
*/
public function testGetRenameTableDDL($fromName, $toName)
{
- $expected = "
-ALTER TABLE foo1 RENAME TO foo2;
-";
+ $expected = '
+ALTER TABLE "foo1" RENAME TO "foo2";
+';
$this->assertEquals($expected, $this->getPlatform()->getRenameTableDDL($fromName, $toName));
}
@@ -77,27 +77,27 @@ public function testGetModifyTableDDL($tableDiff)
{
$expected = <<<END
-ALTER TABLE foo DROP CONSTRAINT foo1_FK_2;
+ALTER TABLE "foo" DROP CONSTRAINT "foo1_FK_2";
-ALTER TABLE foo DROP CONSTRAINT foo1_FK_1;
+ALTER TABLE "foo" DROP CONSTRAINT "foo1_FK_1";
-DROP INDEX bar_baz_FK;
+DROP INDEX "bar_baz_FK";
-DROP INDEX bar_FK;
+DROP INDEX "bar_FK";
-ALTER TABLE foo RENAME COLUMN bar TO bar1;
+ALTER TABLE "foo" RENAME COLUMN "bar" TO "bar1";
-ALTER TABLE foo ALTER COLUMN baz DROP NOT NULL;
+ALTER TABLE "foo" ALTER COLUMN "baz" DROP NOT NULL;
-ALTER TABLE foo ADD baz3 TEXT;
+ALTER TABLE "foo" ADD "baz3" TEXT;
-CREATE INDEX bar_FK ON foo (bar1);
+CREATE INDEX "bar_FK" ON "foo" ("bar1");
-CREATE INDEX baz_FK ON foo (baz3);
+CREATE INDEX "baz_FK" ON "foo" ("baz3");
-ALTER TABLE foo ADD CONSTRAINT foo1_FK_1
- FOREIGN KEY (bar1)
- REFERENCES foo2 (bar);
+ALTER TABLE "foo" ADD CONSTRAINT "foo1_FK_1"
+ FOREIGN KEY ("bar1")
+ REFERENCES "foo2" ("bar");
END;
$this->assertEquals($expected, $this->getPlatform()->getModifyTableDDL($tableDiff));
@@ -110,11 +110,11 @@ public function testGetModifyTableColumnsDDL($tableDiff)
{
$expected = <<<END
-ALTER TABLE foo RENAME COLUMN bar TO bar1;
+ALTER TABLE "foo" RENAME COLUMN "bar" TO "bar1";
-ALTER TABLE foo ALTER COLUMN baz DROP NOT NULL;
+ALTER TABLE "foo" ALTER COLUMN "baz" DROP NOT NULL;
-ALTER TABLE foo ADD baz3 TEXT;
+ALTER TABLE "foo" ADD "baz3" TEXT;
END;
$this->assertEquals($expected, $this->getPlatform()->getModifyTableColumnsDDL($tableDiff));
@@ -127,9 +127,9 @@ public function testGetModifyTablePrimaryKeysDDL($tableDiff)
{
$expected = <<<END
-ALTER TABLE foo DROP CONSTRAINT foo_pkey;
+ALTER TABLE "foo" DROP CONSTRAINT "foo_pkey";
-ALTER TABLE foo ADD PRIMARY KEY (id,bar);
+ALTER TABLE "foo" ADD PRIMARY KEY ("id","bar");
END;
$this->assertEquals($expected, $this->getPlatform()->getModifyTablePrimaryKeyDDL($tableDiff));
@@ -142,13 +142,13 @@ public function testGetModifyTableIndicesDDL($tableDiff)
{
$expected = <<<END
-DROP INDEX bar_FK;
+DROP INDEX "bar_FK";
-CREATE INDEX baz_FK ON foo (baz);
+CREATE INDEX "baz_FK" ON "foo" ("baz");
-DROP INDEX bar_baz_FK;
+DROP INDEX "bar_baz_FK";
-CREATE INDEX bar_baz_FK ON foo (id,bar,baz);
+CREATE INDEX "bar_baz_FK" ON "foo" ("id","bar","baz");
END;
$this->assertEquals($expected, $this->getPlatform()->getModifyTableIndicesDDL($tableDiff));
@@ -161,17 +161,17 @@ public function testGetModifyTableForeignKeysDDL($tableDiff)
{
$expected = <<<END
-ALTER TABLE foo1 DROP CONSTRAINT foo1_FK_1;
+ALTER TABLE "foo1" DROP CONSTRAINT "foo1_FK_1";