Skip to content

Commit

Permalink
add locale length option for i18n behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles SANQUER committed Apr 8, 2013
1 parent 8b6a304 commit 926d70a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion generator/lib/behavior/i18n/I18nBehavior.php
Expand Up @@ -30,6 +30,7 @@ class I18nBehavior extends Behavior
'i18n_columns' => '',
'i18n_pk_name' => null,
'locale_column' => 'locale',
'locale_length' => 5,
'default_locale' => null,
'locale_alias' => '',
);
Expand Down Expand Up @@ -128,7 +129,7 @@ protected function addLocaleColumnToI18n()
$this->i18nTable->addColumn(array(
'name' => $localeColumnName,
'type' => PropelTypes::VARCHAR,
'size' => 5,
'size' => $this->getParameter('locale_length') ? (int) $this->getParameter('locale_length') : 5,
'default' => $this->getDefaultLocale(),
'primaryKey' => 'true',
));
Expand Down
30 changes: 30 additions & 0 deletions test/testsuite/generator/behavior/i18n/I18nBehaviorTest.php
Expand Up @@ -401,7 +401,37 @@ public function testModifyTableUseCustomPkName()
$this->assertContains($expected, $builder->getSQL());
}

public function testModiFyTableUsesCustomI18nLocaleLength()
{
$schema = <<<EOF
<database name="i18n_behavior_test_0">
<table name="i18n_behavior_test_0">
<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
<behavior name="i18n">
<parameter name="locale_length" value="6" />
</behavior>
</table>
</database>
EOF;
$builder = new PropelQuickBuilder();
$builder->setSchema($schema);
$expected = <<<EOF
-----------------------------------------------------------------------
-- i18n_behavior_test_0_i18n
-----------------------------------------------------------------------
DROP TABLE IF EXISTS [i18n_behavior_test_0_i18n];
CREATE TABLE [i18n_behavior_test_0_i18n]
(
[id] INTEGER NOT NULL,
[locale] VARCHAR(6) DEFAULT 'en_US' NOT NULL,
PRIMARY KEY ([id],[locale])
);
EOF;
$this->assertContains($expected, $builder->getSQL());
}

public function testTableWithPrefix()
{
$schema = <<<EOF
Expand Down

0 comments on commit 926d70a

Please sign in to comment.