Пример #1
0
 public function testDefault()
 {
     $companyCount = EQM::queryByArray(['entity' => 'Company'])->count();
     EQM::begin();
     $company = new Company();
     $company->name = 'Test for Transaction 1';
     $company->remark = 'Remark for Transaction 1';
     EQM::insert($company);
     EQM::insert($company);
     EQM::commit();
     $afterCompanyCount = EQM::queryByArray(['entity' => 'Company'])->count();
     $this->assertEquals($companyCount + 2, $afterCompanyCount);
     EQM::begin();
     $company = new Company();
     $company->name = 'Test for Transaction 2';
     $company->remark = 'Remark for Transaction 2';
     EQM::insert($company);
     EQM::insert($company);
     EQM::rollBack();
     $companyCount = EQM::queryByArray(['entity' => 'Company'])->count();
     $this->assertEquals($companyCount, $afterCompanyCount);
 }
Пример #2
0
 public function testInsertError()
 {
     $c = new Company();
     try {
         EQM::insert($c);
         $r = true;
     } catch (EQMException $e) {
         $r = false;
     }
     $this->assertFalse($r);
     $c = new Bootstrap\Company();
     try {
         EQM::insert($c);
         $r = true;
     } catch (EQMException $e) {
         $r = false;
     }
     $this->assertFalse($r);
     $c->name = null;
     $c->remark = 'no no not good';
     try {
         EQM::insert($c);
         $r = true;
     } catch (EQMException $e) {
         $r = false;
     }
     $this->assertFalse($r);
     $p = new Project();
     try {
         EQM::insert($p);
         $r = true;
     } catch (EQMException $e) {
         $r = false;
     }
     $this->assertFalse($r);
     $p->id = null;
     $p->name = 'not good as I said';
     $p->value = 999;
     try {
         EQM::insert($p);
         $r = true;
     } catch (EQMException $e) {
         $r = false;
     }
     $this->assertFalse($r);
     $p->companyId = 1;
     $p->name = 'not good as I said';
     $p->value = 9999;
     try {
         EQM::insert($p);
         $r = true;
     } catch (EQMException $e) {
         $r = false;
     }
     $this->assertFalse($r);
 }
Пример #3
0
function generate($max_i, $max_j, $max_k)
{
    $c = new Company();
    for ($i = 0; $i < $max_i; $i++) {
        $c->name = (isset($c->id) ? $c->id + 1 : 1) . ' A Company Name';
        $c->remark = 'A remark for a company with the name ' . $c->name;
        EQM::insert($c);
        $p = new Project();
        for ($j = 0; $j < $max_j; $j++) {
            $p->id = $c->id . '_' . ($j + 1) . '_PROJECT';
            $p->companyId = $c->id;
            $p->name = 'A project with the id ' . $p->id;
            $p->value = $j % 10 * 100 + $c->id % $j / $j;
            EQM::insert($p);
            $pa = new ProjectActivity();
            for ($k = 0; $k < $max_k; $k++) {
                $pa->id = 100 + $k;
                $pa->projectId = $p->id;
                $pa->name = 'Activity for ' . $p->id . ' with ' . $pa->id;
                EQM::insert($pa);
            }
        }
    }
}
Пример #4
0
 /**
  * inserts a record to the table
  *
  * @return bool|object if auto_increment
  */
 public function insert()
 {
     return EQM::insert($this);
 }
Пример #5
0
 public function testPostDelete()
 {
     $c = new CCompany();
     $c->name = 'NAME';
     EQM::insert($c);
     EQM::delete($c);
     $this->assertEquals($c->remark, 'DELETED');
 }