| @@ 3038-3070 (lines=33) @@ | ||
| 3035 | * |
|
| 3036 | * @return void |
|
| 3037 | */ |
|
| 3038 | public function testSaveAllBelongsTo() { |
|
| 3039 | $model = new Comment(); |
|
| 3040 | $model->deleteAll(true); |
|
| 3041 | $this->assertEquals(array(), $model->find('all')); |
|
| 3042 | ||
| 3043 | $model->Article->deleteAll(true); |
|
| 3044 | $this->assertEquals(array(), $model->Article->find('all')); |
|
| 3045 | ||
| 3046 | $this->assertTrue($model->saveAll(array( |
|
| 3047 | 'Comment' => array( |
|
| 3048 | 'comment' => 'Article comment', |
|
| 3049 | 'article_id' => 1, |
|
| 3050 | 'user_id' => 1 |
|
| 3051 | ), |
|
| 3052 | 'Article' => array( |
|
| 3053 | 'title' => 'Model Associations 101', |
|
| 3054 | 'user_id' => 1 |
|
| 3055 | )))); |
|
| 3056 | $result = $model->find('all', array('fields' => array( |
|
| 3057 | 'Comment.id', 'Comment.comment', 'Comment.article_id', 'Article.id', 'Article.title' |
|
| 3058 | ))); |
|
| 3059 | $expected = array(array( |
|
| 3060 | 'Comment' => array( |
|
| 3061 | 'id' => '1', |
|
| 3062 | 'article_id' => '1', |
|
| 3063 | 'comment' => 'Article comment' |
|
| 3064 | ), |
|
| 3065 | 'Article' => array( |
|
| 3066 | 'id' => '1', |
|
| 3067 | 'title' => 'Model Associations 101' |
|
| 3068 | ))); |
|
| 3069 | $this->assertEquals($expected, $result); |
|
| 3070 | } |
|
| 3071 | ||
| 3072 | /** |
|
| 3073 | * testSaveAllHasOneValidation method |
|
| @@ 5244-5276 (lines=33) @@ | ||
| 5241 | * |
|
| 5242 | * @return void |
|
| 5243 | */ |
|
| 5244 | public function testSaveAssociatedBelongsTo() { |
|
| 5245 | $model = new Comment(); |
|
| 5246 | $model->deleteAll(true); |
|
| 5247 | $this->assertEquals(array(), $model->find('all')); |
|
| 5248 | ||
| 5249 | $model->Article->deleteAll(true); |
|
| 5250 | $this->assertEquals(array(), $model->Article->find('all')); |
|
| 5251 | ||
| 5252 | $this->assertTrue($model->saveAssociated(array( |
|
| 5253 | 'Comment' => array( |
|
| 5254 | 'comment' => 'Article comment', |
|
| 5255 | 'article_id' => 1, |
|
| 5256 | 'user_id' => 1 |
|
| 5257 | ), |
|
| 5258 | 'Article' => array( |
|
| 5259 | 'title' => 'Model Associations 101', |
|
| 5260 | 'user_id' => 1 |
|
| 5261 | )))); |
|
| 5262 | $result = $model->find('all', array('fields' => array( |
|
| 5263 | 'Comment.id', 'Comment.comment', 'Comment.article_id', 'Article.id', 'Article.title' |
|
| 5264 | ))); |
|
| 5265 | $expected = array(array( |
|
| 5266 | 'Comment' => array( |
|
| 5267 | 'id' => '1', |
|
| 5268 | 'article_id' => '1', |
|
| 5269 | 'comment' => 'Article comment' |
|
| 5270 | ), |
|
| 5271 | 'Article' => array( |
|
| 5272 | 'id' => '1', |
|
| 5273 | 'title' => 'Model Associations 101' |
|
| 5274 | ))); |
|
| 5275 | $this->assertEquals($expected, $result); |
|
| 5276 | } |
|
| 5277 | ||
| 5278 | /** |
|
| 5279 | * testSaveAssociatedHasOneValidation method |
|