Skip to content
This repository
Browse code

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
Christopher Vrooman authored July 25, 2012 markstory committed August 03, 2012
63  lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php
@@ -552,6 +552,69 @@ public function testSavePartialFields() {
552 552
 			) + $data
553 553
 		);
554 554
 		$this->assertEquals($expected, $result);
  555
+		
  556
+		$TestModel->locale = 'eng';
  557
+		$data = array(
  558
+			'slug' => 'fifth_translated',
  559
+			'title' => array('eng' => 'Title #5', 'spa' => 'Leyenda #5'),
  560
+		);
  561
+		$TestModel->create($data);
  562
+		$TestModel->save();
  563
+		$TestModel->unbindTranslation();
  564
+		$translations = array('title' => 'Title', 'content' => 'Content');
  565
+		$TestModel->bindTranslation($translations, false);
  566
+		$result = $TestModel->read(null, $TestModel->id);
  567
+		$expected = array(
  568
+			'TranslatedItem' => array(
  569
+				'id' => '5',
  570
+				'translated_article_id' => null,
  571
+				'slug' => 'fifth_translated',
  572
+				'locale' => 'eng',
  573
+				'title' => '',
  574
+				'content' => ''
  575
+			),
  576
+			0 => array(
  577
+				'TranslatedItem__i18n_Title' => 'Title #5',
  578
+				'TranslatedItem__i18n_Content' => ''
  579
+			),
  580
+			'Title' => array(
  581
+				0 => array(
  582
+					'id' => '21',
  583
+					'locale' => 'eng',
  584
+					'model' => 'TranslatedItem',
  585
+					'foreign_key' => '5',
  586
+					'field' => 'title',
  587
+					'content' => 'Title #5'
  588
+				),
  589
+				1 => array(
  590
+					'id' => '22',
  591
+					'locale' => 'spa',
  592
+					'model' => 'TranslatedItem',
  593
+					'foreign_key' => '5',
  594
+					'field' => 'title',
  595
+					'content' => 'Leyenda #5'
  596
+				)
  597
+			),
  598
+			'Content' => array(
  599
+				0 => array(
  600
+					'id' => '23',
  601
+					'locale' => 'eng',
  602
+					'model' => 'TranslatedItem',
  603
+					'foreign_key' => '5',
  604
+					'field' => 'content',
  605
+					'content' => ''
  606
+				),
  607
+				1 => array(
  608
+					'id' => '24',
  609
+					'locale' => 'spa',
  610
+					'model' => 'TranslatedItem',
  611
+					'foreign_key' => '5',
  612
+					'field' => 'content',
  613
+					'content' => ''
  614
+				)
  615
+			)
  616
+		);
  617
+		$this->assertEquals($expected, $result);		
555 618
 	}
556 619
 
557 620
 /**

0 notes on commit de14507

Please sign in to comment.
Something went wrong with that request. Please try again.