Exemple #1
0
 function Test_of_transactions()
 {
     $AkTestUser = new AkTestUser();
     //$AkTestUser->_db->debug = true;
     $AkTestUser->transactionStart();
     for ($i = 1; $i <= 5; $i++) {
         $AkTestUser->create(array('user_name' => 'from transaction', 'country' => 100));
     }
     $AkTestUser->transactionFail();
     $this->assertTrue($AkTestUser->transactionHasFailed());
     $AkTestUser->transactionComplete();
     $this->assertFalse($AkTestUser->find('all', array('conditions' => "country = 100")), 'Transactions are not working on current database. If you are using MySQL please check that  your server supports InnoDB tables');
     $AkTestUser->transactionStart();
     for ($i = 1; $i <= 5; $i++) {
         $AkTestUser->create(array('user_name' => 'from transaction', 'country' => $i));
     }
     $this->assertFalse($AkTestUser->transactionHasFailed());
     $AkTestUser->transactionComplete();
     $this->assertEqual(count($AkTestUser->find('all', array('conditions' => "user_name = 'from transaction'"))), 5);
     //$AkTestUser->_db->debug = false;
 }
Exemple #2
0
 public function Test_of_create()
 {
     $Users = new AkTestUser();
     $Got = $Users->create(array('first_name' => 'Jane', 'last_name' => 'Williams'));
     $Expected = $Users->find('first', "last_name = 'Williams'");
     $this->assertEqual($Got->first_name, $Expected->first_name);
     $this->assertEqual($Got->last_name, $Expected->last_name);
     $this->assertEqual($Got->created_at, $Expected->created_at);
     $Users->transactionStart();
     $Got = $Users->create(array('first_name' => 'Paulo', 'last_name' => 'Coelho', 'expires_on' => '+2 days'));
     $Expected = $Users->find('first', "last_name = 'Coelho'");
     $this->assertEqual($Got->first_name, $Expected->first_name);
     $this->assertEqual($Got->last_name, $Expected->last_name);
     $this->assertEqual($Got->created_at, $Expected->created_at);
     $this->assertEqual($Got->expires_on, $Expected->expires_on);
     $Users->transactionFail();
     $Users->transactionComplete();
 }