/** * @depends testSetAndGetGroupBy */ public function testValidate() { $orderBy = new OrderByForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION); $orderBy->attributeIndexOrDerivedType = 'string'; $orderBy->order = null; $validated = $orderBy->validate(); $this->assertFalse($validated); $errors = $orderBy->getErrors(); $compareErrors = array('order' => array('Order cannot be blank.')); $this->assertEquals($compareErrors, $errors); $orderBy->order = 'z'; $validated = $orderBy->validate(); $this->assertFalse($validated); $errors = $orderBy->getErrors(); $compareErrors = array('order' => array('Order must be asc or desc.')); $this->assertEquals($compareErrors, $errors); $orderBy->order = 'desc'; $validated = $orderBy->validate(); $this->assertTrue($validated); }
public function testValidateOrderBysForErrors() { $rowsAndColumnsReportWizardForm = new RowsAndColumnsReportWizardForm(); $orderBy = new OrderByForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_ROWS_AND_COLUMNS); $this->assertEquals('asc', $orderBy->order); $orderBy->attributeIndexOrDerivedType = 'modifiedDateTime'; $orderBy->order = 'desc1'; $rowsAndColumnsReportWizardForm->orderBys = array($orderBy); $rowsAndColumnsReportWizardForm->validateOrderBys(); $errors = $orderBy->getErrors(); $compareErrors = array('order' => array('Order must be asc or desc.')); $this->assertEquals($compareErrors, $errors); $this->assertTrue($rowsAndColumnsReportWizardForm->hasErrors()); }
public function testValidateOrderBysForErrors() { $summationReportWizardForm = new SummationReportWizardForm(); $orderBy = new OrderByForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_ROWS_AND_COLUMNS); $this->assertEquals('asc', $orderBy->order); $orderBy->attributeIndexOrDerivedType = 'modifiedDateTime'; $orderBy->order = null; $validated = $orderBy->validate(); $this->assertFalse($validated); $errors = $orderBy->getErrors(); $summationReportWizardForm->orderBys = array($orderBy); $summationReportWizardForm->validateOrderBys(); $errors = $orderBy->getErrors(); $compareErrors = array('order' => array('Order cannot be blank.')); $this->assertEquals($compareErrors, $errors); $this->assertTrue($summationReportWizardForm->hasErrors()); }
/** * @return string */ public static function getTreeType() { return OrderByForReportForm::getType(); }
/** * @param array $data * @param Report $report */ protected static function resolveOrderBys($data, Report $report) { $report->removeAllOrderBys(); $moduleClassName = $report->getModuleClassName(); if (count($orderBysData = ArrayUtil::getArrayValue($data, ComponentForReportForm::TYPE_ORDER_BYS)) > 0) { foreach ($orderBysData as $key => $orderByData) { $orderBy = new OrderByForReportForm($moduleClassName, $moduleClassName::getPrimaryModelName(), $report->getType(), $key); $orderBy->setAttributes($orderByData); $report->addOrderBy($orderBy); } } else { $report->removeAllOrderBys(); } }