|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * TranslateBehaviorTest file |
4 |
| - * |
5 |
| - * PHP 5 |
6 |
| - * |
7 | 3 | * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
|
8 | 4 | * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
9 | 5 | *
|
|
12 | 8 | *
|
13 | 9 | * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
14 | 10 | * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
|
15 |
| - * @package Cake.Test.Case.Model.Behavior |
16 | 11 | * @since CakePHP(tm) v 1.2.0.5669
|
17 | 12 | * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
18 | 13 | */
|
@@ -1058,4 +1053,36 @@ public function testUnbindTranslation() {
|
1058 | 1053 | $this->assertNotContains('slug', $result);
|
1059 | 1054 | }
|
1060 | 1055 |
|
| 1056 | +/** |
| 1057 | + * Test that additional records are not inserted for associated translations. |
| 1058 | + * |
| 1059 | + * @return void |
| 1060 | + */ |
| 1061 | + public function testNoExtraRowsForAssociatedTranslations() { |
| 1062 | + $this->loadFixtures('Translate', 'TranslatedItem'); |
| 1063 | + $TestModel = new TranslatedItem(); |
| 1064 | + $TestModel->locale = 'spa'; |
| 1065 | + $TestModel->unbindTranslation(); |
| 1066 | + $TestModel->bindTranslation(array('name' => 'nameTranslate')); |
| 1067 | + |
| 1068 | + $data = array( |
| 1069 | + 'TranslatedItem' => array( |
| 1070 | + 'slug' => 'spanish-name', |
| 1071 | + 'name' => 'Spanish name', |
| 1072 | + ), |
| 1073 | + ); |
| 1074 | + $TestModel->create($data); |
| 1075 | + $TestModel->save(); |
| 1076 | + |
| 1077 | + $Translate = $TestModel->translateModel(); |
| 1078 | + $results = $Translate->find('all', array( |
| 1079 | + 'conditions' => array( |
| 1080 | + 'locale' => $TestModel->locale, |
| 1081 | + 'foreign_key' => $TestModel->id |
| 1082 | + ) |
| 1083 | + )); |
| 1084 | + $this->assertCount(1, $results, 'Only one field should be saved'); |
| 1085 | + $this->assertEquals('name', $results[0]['TranslateTestModel']['field']); |
| 1086 | + } |
| 1087 | + |
1061 | 1088 | }
|
0 commit comments