Exemplo n.º 1
0
 public function loadModel($id)
 {
     $model = Bidding::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * test that save() resets whitelist on failed save
  */
 public function testSaveFieldListResetsWhitelistOnFailedSave()
 {
     $this->loadFixtures('Bidding');
     $model = new Bidding();
     $whitelist = array('title');
     $model->whitelist = $whitelist;
     $result = $model->save(array(), array('fieldList' => array('body')));
     $this->assertFalse($result);
     $this->assertEquals($whitelist, $model->whitelist);
 }
Exemplo n.º 3
0
 /**
  * testDeleteDependent method
  *
  * @return void
  */
 public function testDeleteDependent()
 {
     $this->loadFixtures('Bidding', 'BiddingMessage', 'Article', 'ArticlesTag', 'Comment', 'User', 'Attachment');
     $Bidding = new Bidding();
     $result = $Bidding->find('all', array('order' => array('Bidding.id' => 'ASC')));
     $expected = array(array('Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1')), array('Bidding' => array('id' => 2, 'bid' => 'Two', 'name' => 'Bid 2'), 'BiddingMessage' => array('bidding' => 'Two', 'name' => 'Message 2')), array('Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3')), array('Bidding' => array('id' => 4, 'bid' => 'Five', 'name' => 'Bid 5'), 'BiddingMessage' => array('bidding' => '', 'name' => '')));
     $this->assertEquals($expected, $result);
     $Bidding->delete(4, true);
     $result = $Bidding->find('all', array('order' => array('Bidding.id' => 'ASC')));
     $expected = array(array('Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1')), array('Bidding' => array('id' => 2, 'bid' => 'Two', 'name' => 'Bid 2'), 'BiddingMessage' => array('bidding' => 'Two', 'name' => 'Message 2')), array('Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3')));
     $this->assertEquals($expected, $result);
     $Bidding->delete(2, true);
     $result = $Bidding->find('all', array('order' => array('Bidding.id' => 'ASC')));
     $expected = array(array('Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1')), array('Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3')));
     $this->assertEquals($expected, $result);
     $result = $Bidding->BiddingMessage->find('all', array('order' => array('BiddingMessage.name' => 'ASC')));
     $expected = array(array('BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1'), 'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1')), array('BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3'), 'Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3')), array('BiddingMessage' => array('bidding' => 'Four', 'name' => 'Message 4'), 'Bidding' => array('id' => '', 'bid' => '', 'name' => '')));
     $this->assertEquals($expected, $result);
     $Article = new Article();
     $result = $Article->Comment->find('count', array('conditions' => array('Comment.article_id' => 1)));
     $this->assertEquals(4, $result);
     $result = $Article->delete(1, true);
     $this->assertSame($result, true);
     $result = $Article->Comment->find('count', array('conditions' => array('Comment.article_id' => 1)));
     $this->assertEquals(0, $result);
 }
Exemplo n.º 4
0
 /**
  * testDeleteDependent method
  *
  * @access public
  * @return void
  */
 function testDeleteDependent()
 {
     $this->loadFixtures('Bidding', 'BiddingMessage');
     $Bidding = new Bidding();
     $result = $Bidding->find('all');
     $expected = array(array('Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1')), array('Bidding' => array('id' => 2, 'bid' => 'Two', 'name' => 'Bid 2'), 'BiddingMessage' => array('bidding' => 'Two', 'name' => 'Message 2')), array('Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3')), array('Bidding' => array('id' => 4, 'bid' => 'Five', 'name' => 'Bid 5'), 'BiddingMessage' => array('bidding' => '', 'name' => '')));
     $this->assertEqual($result, $expected);
     $Bidding->delete(4, true);
     $result = $Bidding->find('all');
     $expected = array(array('Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1')), array('Bidding' => array('id' => 2, 'bid' => 'Two', 'name' => 'Bid 2'), 'BiddingMessage' => array('bidding' => 'Two', 'name' => 'Message 2')), array('Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3')));
     $this->assertEqual($result, $expected);
     $Bidding->delete(2, true);
     $result = $Bidding->find('all');
     $expected = array(array('Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1')), array('Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3')));
     $this->assertEqual($result, $expected);
     $result = $Bidding->BiddingMessage->find('all', array('order' => array('BiddingMessage.name' => 'ASC')));
     $expected = array(array('BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1'), 'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1')), array('BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3'), 'Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3')), array('BiddingMessage' => array('bidding' => 'Four', 'name' => 'Message 4'), 'Bidding' => array('id' => '', 'bid' => '', 'name' => '')));
     $this->assertEqual($result, $expected);
 }