Code Duplication    Length = 25-25 lines in 2 locations

lib/Cake/Test/Case/Model/ModelWriteTest.php 2 locations

@@ 2913-2937 (lines=25) @@
2910
 *
2911
 * @return void
2912
 */
2913
	public function testSaveAllHabtm() {
2914
		$this->loadFixtures('Article', 'Tag', 'Comment', 'User', 'ArticlesTag');
2915
		$data = array(
2916
			'Article' => array(
2917
				'user_id' => 1,
2918
				'title' => 'Article Has and belongs to Many Tags'
2919
			),
2920
			'Tag' => array(
2921
				'Tag' => array(1, 2)
2922
			),
2923
			'Comment' => array(
2924
				array(
2925
					'comment' => 'Article comment',
2926
					'user_id' => 1
2927
		)));
2928
		$Article = new Article();
2929
		$result = $Article->saveAll($data);
2930
		$this->assertFalse(empty($result));
2931
2932
		$result = $Article->read();
2933
		$this->assertEquals(2, count($result['Tag']));
2934
		$this->assertEquals('tag1', $result['Tag'][0]['tag']);
2935
		$this->assertEquals(1, count($result['Comment']));
2936
		$this->assertEquals(1, count($result['Comment'][0]['comment']));
2937
	}
2938
2939
/**
2940
 * Test SaveAll with Habtm relations and extra join table fields
@@ 5119-5143 (lines=25) @@
5116
 *
5117
 * @return void
5118
 */
5119
	public function testSaveAssociatedHabtm() {
5120
		$this->loadFixtures('Article', 'Tag', 'Comment', 'User', 'ArticlesTag');
5121
		$data = array(
5122
			'Article' => array(
5123
				'user_id' => 1,
5124
				'title' => 'Article Has and belongs to Many Tags'
5125
			),
5126
			'Tag' => array(
5127
				'Tag' => array(1, 2)
5128
			),
5129
			'Comment' => array(
5130
				array(
5131
					'comment' => 'Article comment',
5132
					'user_id' => 1
5133
		)));
5134
		$Article = new Article();
5135
		$result = $Article->saveAssociated($data);
5136
		$this->assertFalse(empty($result));
5137
5138
		$result = $Article->read();
5139
		$this->assertEquals(2, count($result['Tag']));
5140
		$this->assertEquals('tag1', $result['Tag'][0]['tag']);
5141
		$this->assertEquals(1, count($result['Comment']));
5142
		$this->assertEquals(1, count($result['Comment'][0]['comment']));
5143
	}
5144
5145
/**
5146
 * Test SaveAssociated with Habtm relations and extra join table fields