コード例 #1
0
 /**
  * ensure that exists() does not persist between method calls reset on create
  *
  * @return void
  */
 public function testResetOfExistsOnCreate()
 {
     $this->loadFixtures('Boat');
     $Boat = new Boat();
     $Boat->id = 1;
     $Boat->saveField('title', 'Reset me');
     $Boat->delete();
     $Boat->id = 1;
     $this->assertFalse($Boat->exists());
     $Boat->create();
     $this->assertFalse($Boat->exists());
     $Boat->id = 2;
     $Boat->saveField('title', 'Staying alive');
     $result = $Boat->read(null, 2);
     $this->assertEquals('Staying alive', $result['Boat']['title']);
 }
コード例 #2
0
ファイル: ModelDeleteTest.php プロジェクト: saikais/cruise
 /**
  * testDeleteDependent method
  *
  * @return void
  */
 public function testDeleteDependent()
 {
     $this->loadFixtures('Bidding', 'BiddingMessage', 'Boat', 'boatsTag', '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);
     $Boat = new Boat();
     $result = $Boat->Comment->find('count', array('conditions' => array('Comment.article_id' => 1)));
     $this->assertEquals(4, $result);
     $result = $Boat->delete(1, true);
     $this->assertTrue($result);
     $result = $Boat->Comment->find('count', array('conditions' => array('Comment.article_id' => 1)));
     $this->assertEquals(0, $result);
 }
コード例 #3
0
ファイル: PostgresTest.php プロジェクト: saikais/cruise
 /**
  * Test nested transaction
  *
  * @return void
  */
 public function testNestedTransaction()
 {
     $this->Dbo->useNestedTransactions = true;
     $this->skipIf($this->Dbo->nestedTransactionSupported() === false, 'The Postgres server do not support nested transaction');
     $this->loadFixtures('Boat');
     $model = new Boat();
     $model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array();
     $model->cacheQueries = false;
     $this->Dbo->cacheMethods = false;
     $this->assertTrue($this->Dbo->begin());
     $this->assertNotEmpty($model->read(null, 1));
     $this->assertTrue($this->Dbo->begin());
     $this->assertTrue($model->delete(1));
     $this->assertEmpty($model->read(null, 1));
     $this->assertTrue($this->Dbo->rollback());
     $this->assertNotEmpty($model->read(null, 1));
     $this->assertTrue($this->Dbo->begin());
     $this->assertTrue($model->delete(1));
     $this->assertEmpty($model->read(null, 1));
     $this->assertTrue($this->Dbo->commit());
     $this->assertEmpty($model->read(null, 1));
     $this->assertTrue($this->Dbo->rollback());
     $this->assertNotEmpty($model->read(null, 1));
 }