/** * @depends testSetAndGetChart */ public function testValidate() { $chart = new ChartForReportForm(); $validated = $chart->validate(); $this->assertTrue($validated); $chart->type = 'Bar2D'; $validated = $chart->validate(); $this->assertFalse($validated); $errors = $chart->getErrors(); $compareErrors = array('firstSeries' => array('First Series cannot be blank.'), 'firstRange' => array('First Range cannot be blank.')); $this->assertEquals($compareErrors, $errors); $chart->firstSeries = 'dropDown'; $chart->firstRange = 'float__Summation'; $validated = $chart->validate(); $this->assertTrue($validated); //When the type is a StackedColumn2D, it should require the second series and range $chart->type = 'StackedColumn2D'; $validated = $chart->validate(); $this->assertFalse($validated); $errors = $chart->getErrors(); $compareErrors = array('secondSeries' => array('Second Series cannot be blank.'), 'secondRange' => array('Second Range cannot be blank.')); $this->assertEquals($compareErrors, $errors); $chart->secondSeries = 'integer'; $chart->secondRange = 'integer__Summation'; $validated = $chart->validate(); $this->assertTrue($validated); }
public function testValidateChartForErrors() { $summationReportWizardForm = new SummationReportWizardForm(); $chart = new ChartForReportForm(); $summationReportWizardForm->chart = $chart; $chart->type = 'Bar2D'; $chart->firstSeries = 'dropDown'; $summationReportWizardForm->validateChart(); $validated = $chart->validate(); $this->assertFalse($validated); $errors = $chart->getErrors(); $compareErrors = array('firstRange' => array('First Range cannot be blank.')); $this->assertEquals($compareErrors, $errors); $this->assertTrue($summationReportWizardForm->hasErrors()); }