public function testOtherFind() { $pq = EQM::query(Project::class)->where('companyId = ?', 2)->result(); $pm = Project::findByCompanyId(2); $this->assertEquals($pq->count(), $pm->count()); $this->assertEquals($pq->one()->name, $pm->one()->name); }
public function testAliasing() { $result = EQM::query()->select('*')->from('Company Firma')->where('Firma.id = ?', 2)->result()->one(); $this->assertEquals(2, $result->id); $result = EQM::query('Company Firma')->innerJoin('Project Projekt', 'Firma.id = Projekt.companyId')->innerJoin('ProjectActivity Aktivitaet', 'Projekt.id = Aktivitaet.projectId')->where('Aktivitaet.id = :id', ['id' => 100])->groupBy('Firma.id')->result(); $this->assertEquals(27, $result->count()); }
public function testResult() { $result = EQM::query(Company::class)->result(); $count = $result->count(); $all = $result->all(); $this->assertEquals($all, $all->all()); $this->assertInstanceOf(Company::class, $all->one()); $this->assertEquals($all->count(), $count); }
/** * @return \troba\EQM\Query query object of the called class */ public static function query() { return EQM::query(get_called_class()); }
public function testPreDelete() { $c = new BCompany(); $c->name = 'NAME'; EQM::insert($c); EQM::delete($c); $q = EQM::query(Company::class)->where('name = ?', ['PRE_INS_NAME_DEL'])->all(); $this->assertEquals($q->count(), 1); $this->assertEquals($q[0]->name, 'PRE_INS_NAME_DEL'); }