コード例 #1
0
ファイル: EQMTransactionTest.php プロジェクト: scandio/troba
 public function testComplex()
 {
     $companies = EQM::queryByArray(['entity' => 'Company']);
     $count = $companies->count();
     EQM::begin();
     foreach ($companies as $company) {
         $company->remark = 'Transaction remark';
         EQM::update($company);
         $projects = EQM::queryByArray(['entity' => Project::class, 'query' => 'id = ?', 'params' => $company->id]);
         foreach ($projects as $project) {
             $project->value = 999.99;
             EQM::update($project);
         }
     }
     EQM::rollBack();
     $companyCount = EQM::queryByArray(['entity' => 'Company'])->count();
     $this->assertEquals($count, $companyCount);
     $companies = EQM::queryByArray(['entity' => 'Company', 'query' => 'remark = ?', 'params' => 'Transaction remark']);
     $this->assertEquals(0, $companies->count());
 }