/**
  * testDeepAssociationsBelongsTo
  *
  * @link https://github.com/CakeDC/tags/issues/15
  * @return void
  */
 public function testDeepAssociationsBelongsTo()
 {
     $this->Tagged->bindModel(array('belongsTo' => array('Article' => array('className' => 'TaggedArticle', 'foreignKey' => 'foreign_key'))));
     $this->Tagged->Article->bindModel(array('belongsTo' => array('User' => array())));
     $result = $this->Tagged->find('all', array('contain' => array('Article' => array('User'))));
     $this->assertEquals($result[0]['Article']['User']['name'], 'CakePHP');
 }
 /**
  * Test custom _findTagged method with additional conditions on the model
  *
  * @return void
  */
 public function testFindTaggedWithConditions()
 {
     $this->Tagged->recursive = -1;
     $result = $this->Tagged->find('tagged', array('by' => 'cakephp', 'model' => 'Article', 'conditions' => array('Article.title LIKE' => 'Second %')));
     $this->assertEqual(count($result), 0);
     $result = $this->Tagged->find('tagged', array('by' => 'cakephp', 'model' => 'Article', 'conditions' => array('Article.title LIKE' => 'First %')));
     $this->assertEqual(count($result), 1);
     $this->assertEqual($result[0]['Article']['id'], 'article-1');
 }
Beispiel #3
0
 /**
  * Test custom _findTagged method
  * 
  * @return void
  */
 public function testFindTagged()
 {
     $result = $this->Tagged->find('tagged', array('by' => 'cakephp', 'model' => 'Article'));
     $this->assertEqual(count($result), 1);
     $this->assertEqual($result[0]['Article']['id'], 1);
     $result = $this->Tagged->find('tagged', array('model' => 'Article'));
     $this->assertEqual(count($result), 2);
     // Test call to paginateCount by Controller::pagination()
     $result = $this->Tagged->paginateCount(array(), 1, array('model' => 'Article', 'type' => 'tagged'));
     $this->assertEqual($result, 2);
 }