Exemplo n.º 1
0
 public function testSortedQuery()
 {
     $result = EQM::query('Company')->orderBy('id DESC')->one();
     $this->assertEquals(CNT_COMPANY + 6, $result->id);
     $result->name = 'ZZZ' . $result->name;
     EQM::update($result);
     $result = EQM::query('Company')->orderBy('name DESC')->one();
     $this->assertEquals('ZZZ', substr($result->name, 0, 3));
 }
Exemplo n.º 2
0
 public function testUpdateError()
 {
     $c = new Company();
     try {
         EQM::update($c);
         $r = true;
     } catch (EQMException $e) {
         $r = false;
     }
     $this->assertFalse($r);
 }
Exemplo n.º 3
0
 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());
 }
Exemplo n.º 4
0
 /**
  * updates a record of the table
  *
  * @return bool
  */
 public function update()
 {
     return EQM::update($this);
 }
Exemplo n.º 5
0
 public function testPostUpdate()
 {
     $c = new ACompany();
     $c->name = 'NAME';
     EQM::insert($c);
     EQM::update($c);
     $this->assertEquals($c->name, 'POST_UPD_NAME');
     EQM::delete($c);
 }