@@ 4889-4916 (lines=28) @@ | ||
4886 | * |
|
4887 | * @return void |
|
4888 | */ |
|
4889 | public function testBindMultipleTimesWithDifferentResetSettings() { |
|
4890 | $this->loadFixtures('User', 'Comment', 'Article'); |
|
4891 | $TestModel = new User(); |
|
4892 | ||
4893 | $result = $TestModel->hasMany; |
|
4894 | $expected = array(); |
|
4895 | $this->assertEquals($expected, $result); |
|
4896 | ||
4897 | $result = $TestModel->bindModel(array( |
|
4898 | 'hasMany' => array('Comment') |
|
4899 | )); |
|
4900 | $this->assertTrue($result); |
|
4901 | $result = $TestModel->bindModel( |
|
4902 | array('hasMany' => array('Article')), |
|
4903 | false |
|
4904 | ); |
|
4905 | $this->assertTrue($result); |
|
4906 | ||
4907 | $result = array_keys($TestModel->hasMany); |
|
4908 | $expected = array('Comment', 'Article'); |
|
4909 | $this->assertEquals($expected, $result); |
|
4910 | ||
4911 | $TestModel->resetAssociations(); |
|
4912 | ||
4913 | $result = array_keys($TestModel->hasMany); |
|
4914 | $expected = array('Article'); |
|
4915 | $this->assertEquals($expected, $result); |
|
4916 | } |
|
4917 | ||
4918 | /** |
|
4919 | * test that bindModel behaves with Custom primary Key associations |
|
@@ 4959-4986 (lines=28) @@ | ||
4956 | * |
|
4957 | * @return void |
|
4958 | */ |
|
4959 | public function testUnBindMultipleTimesWithDifferentResetSettings() { |
|
4960 | $this->loadFixtures('User', 'Comment', 'Article'); |
|
4961 | $TestModel = new Comment(); |
|
4962 | ||
4963 | $result = array_keys($TestModel->belongsTo); |
|
4964 | $expected = array('Article', 'User'); |
|
4965 | $this->assertEquals($expected, $result); |
|
4966 | ||
4967 | $result = $TestModel->unbindModel(array( |
|
4968 | 'belongsTo' => array('User') |
|
4969 | )); |
|
4970 | $this->assertTrue($result); |
|
4971 | $result = $TestModel->unbindModel( |
|
4972 | array('belongsTo' => array('Article')), |
|
4973 | false |
|
4974 | ); |
|
4975 | $this->assertTrue($result); |
|
4976 | ||
4977 | $result = array_keys($TestModel->belongsTo); |
|
4978 | $expected = array(); |
|
4979 | $this->assertEquals($expected, $result); |
|
4980 | ||
4981 | $TestModel->resetAssociations(); |
|
4982 | ||
4983 | $result = array_keys($TestModel->belongsTo); |
|
4984 | $expected = array('User'); |
|
4985 | $this->assertEquals($expected, $result); |
|
4986 | } |
|
4987 | ||
4988 | /** |
|
4989 | * testAssociationAfterFind method |