Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a failing test to testSavePartialFields

Added a failing test to the testSavePartialFields method where the title data for two locales creates only one empty content entry instead of two.
  • Loading branch information...
commit de1450763b9a9c270650ab235a4d2d82528f3409 1 parent e620433
@cdvrooman cdvrooman authored markstory committed
Showing with 63 additions and 0 deletions.
  1. +63 −0 lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php
View
63 lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php
@@ -552,6 +552,69 @@ public function testSavePartialFields() {
) + $data
);
$this->assertEquals($expected, $result);
+
+ $TestModel->locale = 'eng';
+ $data = array(
+ 'slug' => 'fifth_translated',
+ 'title' => array('eng' => 'Title #5', 'spa' => 'Leyenda #5'),
+ );
+ $TestModel->create($data);
+ $TestModel->save();
+ $TestModel->unbindTranslation();
+ $translations = array('title' => 'Title', 'content' => 'Content');
+ $TestModel->bindTranslation($translations, false);
+ $result = $TestModel->read(null, $TestModel->id);
+ $expected = array(
+ 'TranslatedItem' => array(
+ 'id' => '5',
+ 'translated_article_id' => null,
+ 'slug' => 'fifth_translated',
+ 'locale' => 'eng',
+ 'title' => '',
+ 'content' => ''
+ ),
+ 0 => array(
+ 'TranslatedItem__i18n_Title' => 'Title #5',
+ 'TranslatedItem__i18n_Content' => ''
+ ),
+ 'Title' => array(
+ 0 => array(
+ 'id' => '21',
+ 'locale' => 'eng',
+ 'model' => 'TranslatedItem',
+ 'foreign_key' => '5',
+ 'field' => 'title',
+ 'content' => 'Title #5'
+ ),
+ 1 => array(
+ 'id' => '22',
+ 'locale' => 'spa',
+ 'model' => 'TranslatedItem',
+ 'foreign_key' => '5',
+ 'field' => 'title',
+ 'content' => 'Leyenda #5'
+ )
+ ),
+ 'Content' => array(
+ 0 => array(
+ 'id' => '23',
+ 'locale' => 'eng',
+ 'model' => 'TranslatedItem',
+ 'foreign_key' => '5',
+ 'field' => 'content',
+ 'content' => ''
+ ),
+ 1 => array(
+ 'id' => '24',
+ 'locale' => 'spa',
+ 'model' => 'TranslatedItem',
+ 'foreign_key' => '5',
+ 'field' => 'content',
+ 'content' => ''
+ )
+ )
+ );
+ $this->assertEquals($expected, $result);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.