/** * @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()); }