/**
  * testBindUnbind method
  *
  * @return void
  */
 public function testBindUnbind()
 {
     $this->loadFixtures('User', 'Comment', 'FeatureSet', 'DeviceType', 'DeviceTypeCategory', 'ExteriorTypeCategory', 'Device', 'Document', 'DocumentDirectory');
     $TestModel = new User();
     $result = $TestModel->hasMany;
     $expected = array();
     $this->assertEquals($expected, $result);
     $result = $TestModel->bindModel(array('hasMany' => array('Comment')));
     $this->assertTrue($result);
     $result = $TestModel->find('all', array('fields' => 'User.id, User.user', 'order' => array('User.id' => 'ASC')));
     $expected = array(array('User' => array('id' => '1', 'user' => 'mariano'), 'Comment' => array(array('id' => '3', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31'), array('id' => '4', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31'), array('id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31'))), array('User' => array('id' => '2', 'user' => 'nate'), 'Comment' => array(array('id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'), array('id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31'))), array('User' => array('id' => '3', 'user' => 'larry'), 'Comment' => array()), array('User' => array('id' => '4', 'user' => 'garrett'), 'Comment' => array(array('id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'))));
     $this->assertEquals($expected, $result);
     $TestModel->resetAssociations();
     $result = $TestModel->hasMany;
     $this->assertSame(array(), $result);
     $result = $TestModel->bindModel(array('hasMany' => array('Comment')), false);
     $this->assertTrue($result);
     $result = $TestModel->find('all', array('fields' => 'User.id, User.user', 'order' => array('User.id' => 'ASC')));
     $expected = array(array('User' => array('id' => '1', 'user' => 'mariano'), 'Comment' => array(array('id' => '3', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31'), array('id' => '4', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31'), array('id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31'))), array('User' => array('id' => '2', 'user' => 'nate'), 'Comment' => array(array('id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'), array('id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31'))), array('User' => array('id' => '3', 'user' => 'larry'), 'Comment' => array()), array('User' => array('id' => '4', 'user' => 'garrett'), 'Comment' => array(array('id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'))));
     $this->assertEquals($expected, $result);
     $result = $TestModel->hasMany;
     $expected = array('Comment' => array('className' => 'Comment', 'foreignKey' => 'user_id', 'conditions' => null, 'fields' => null, 'order' => null, 'limit' => null, 'offset' => null, 'dependent' => null, 'exclusive' => null, 'finderQuery' => null, 'counterQuery' => null));
     $this->assertEquals($expected, $result);
     $result = $TestModel->unbindModel(array('hasMany' => array('Comment')));
     $this->assertTrue($result);
     $result = $TestModel->hasMany;
     $expected = array();
     $this->assertEquals($expected, $result);
     $result = $TestModel->find('all', array('fields' => 'User.id, User.user', 'order' => array('User.id' => 'ASC')));
     $expected = array(array('User' => array('id' => '1', 'user' => 'mariano')), array('User' => array('id' => '2', 'user' => 'nate')), array('User' => array('id' => '3', 'user' => 'larry')), array('User' => array('id' => '4', 'user' => 'garrett')));
     $this->assertEquals($expected, $result);
     $result = $TestModel->find('all', array('fields' => 'User.id, User.user', 'order' => array('User.id' => 'ASC')));
     $expected = array(array('User' => array('id' => '1', 'user' => 'mariano'), 'Comment' => array(array('id' => '3', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31'), array('id' => '4', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31'), array('id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31'))), array('User' => array('id' => '2', 'user' => 'nate'), 'Comment' => array(array('id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'), array('id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31'))), array('User' => array('id' => '3', 'user' => 'larry'), 'Comment' => array()), array('User' => array('id' => '4', 'user' => 'garrett'), 'Comment' => array(array('id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'))));
     $this->assertEquals($expected, $result);
     $result = $TestModel->unbindModel(array('hasMany' => array('Comment')), false);
     $this->assertTrue($result);
     $result = $TestModel->find('all', array('fields' => 'User.id, User.user', 'order' => array('User.id' => 'ASC')));
     $expected = array(array('User' => array('id' => '1', 'user' => 'mariano')), array('User' => array('id' => '2', 'user' => 'nate')), array('User' => array('id' => '3', 'user' => 'larry')), array('User' => array('id' => '4', 'user' => 'garrett')));
     $this->assertEquals($expected, $result);
     $result = $TestModel->hasMany;
     $expected = array();
     $this->assertEquals($expected, $result);
     $result = $TestModel->bindModel(array('hasMany' => array('Comment' => array('className' => 'Comment', 'conditions' => 'Comment.published = \'Y\''))));
     $this->assertTrue($result);
     $result = $TestModel->find('all', array('fields' => 'User.id, User.user', 'order' => array('User.id' => 'ASC')));
     $expected = array(array('User' => array('id' => '1', 'user' => 'mariano'), 'Comment' => array(array('id' => '3', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31'), array('id' => '5', 'article_id' => '2', 'user_id' => '1', 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31'))), array('User' => array('id' => '2', 'user' => 'nate'), 'Comment' => array(array('id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'), array('id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31'))), array('User' => array('id' => '3', 'user' => 'larry'), 'Comment' => array()), array('User' => array('id' => '4', 'user' => 'garrett'), 'Comment' => array(array('id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'))));
     $this->assertEquals($expected, $result);
     $TestModel2 = new DeviceType();
     $expected = array('className' => 'FeatureSet', 'foreignKey' => 'feature_set_id', 'conditions' => '', 'fields' => '', 'order' => '', 'counterCache' => '');
     $this->assertEquals($expected, $TestModel2->belongsTo['FeatureSet']);
     $TestModel2->bindModel(array('belongsTo' => array('FeatureSet' => array('className' => 'FeatureSet', 'conditions' => array('active' => true)))));
     $expected['conditions'] = array('active' => true);
     $this->assertEquals($expected, $TestModel2->belongsTo['FeatureSet']);
     $TestModel2->bindModel(array('belongsTo' => array('FeatureSet' => array('className' => 'FeatureSet', 'foreignKey' => false, 'conditions' => array('Feature.name' => 'DeviceType.name')))));
     $expected['conditions'] = array('Feature.name' => 'DeviceType.name');
     $expected['foreignKey'] = false;
     $this->assertEquals($expected, $TestModel2->belongsTo['FeatureSet']);
     $TestModel2->bindModel(array('hasMany' => array('NewFeatureSet' => array('className' => 'FeatureSet', 'conditions' => array('active' => true)))));
     $expected = array('className' => 'FeatureSet', 'conditions' => array('active' => true), 'foreignKey' => 'device_type_id', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'dependent' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => '');
     $this->assertEquals($expected, $TestModel2->hasMany['NewFeatureSet']);
     $this->assertTrue(is_object($TestModel2->NewFeatureSet));
 }