public function testValidateFiltersForErrors()
 {
     $rowsAndColumnsReportWizardForm = new RowsAndColumnsReportWizardForm();
     $filter = new FilterForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_ROWS_AND_COLUMNS);
     $filter->attributeIndexOrDerivedType = 'string';
     $filter->operator = OperatorRules::TYPE_EQUALS;
     $rowsAndColumnsReportWizardForm->filters = array($filter);
     $validated = $filter->validate();
     $this->assertFalse($validated);
     $errors = $filter->getErrors();
     $compareErrors = array('value' => array('Value cannot be blank.'));
     $this->assertEquals($compareErrors, $errors);
 }
 /**
  * @return ModelRelationsAndAttributesToReportAdapter
  */
 protected function makeModelRelationsAndAttributesToReportAdapter()
 {
     return ModelRelationsAndAttributesToReportAdapter::make($this->filter->getResolvedAttributeModuleClassName(), $this->filter->getResolvedAttributeModelClassName(), $this->filter->getReportType());
 }
 /**
  * @param string $moduleClassName
  * @param string $modelClassName
  * @param string $reportType
  * @param array $filterData
  * @return array
  */
 protected static function sanitizeFilterData($moduleClassName, $modelClassName, $reportType, $filterData)
 {
     assert('is_string($moduleClassName)');
     assert('is_string($modelClassName)');
     assert('is_string($reportType)');
     assert('is_array($filterData)');
     $filterForSanitizing = new FilterForReportForm($moduleClassName, $moduleClassName::getPrimaryModelName(), $reportType);
     $filterForSanitizing->setAttributes($filterData);
     $valueElementType = null;
     $valueElementType = $filterForSanitizing->getValueElementType();
     if ($valueElementType == 'MixedDateTypesForReport') {
         if (isset($filterData['value']) && $filterData['value'] !== null) {
             $filterData['value'] = DateTimeUtil::resolveValueForDateDBFormatted($filterData['value']);
         }
         if (isset($filterData['secondValue']) && $filterData['secondValue'] !== null) {
             $filterData['secondValue'] = DateTimeUtil::resolveValueForDateDBFormatted($filterData['secondValue']);
         }
     }
     return $filterData;
 }
 /**
  * @return string
  */
 public static function getTreeType()
 {
     return FilterForReportForm::getType();
 }
 /**
  * @depends testValidateEmailAttribute
  */
 public function testValidateAttributeWithUniqueValidator()
 {
     $filter = new FilterForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_ROWS_AND_COLUMNS);
     $filter->attributeIndexOrDerivedType = 'modifiedByUser___username';
     $validated = $filter->validate();
     $this->assertFalse($validated);
     $errors = $filter->getErrors();
     $compareErrors = array('operator' => array('Operator cannot be blank.'));
     $this->assertEquals($compareErrors, $errors);
     $filter->operator = OperatorRules::TYPE_EQUALS;
     $validated = $filter->validate();
     $this->assertFalse($validated);
     $errors = $filter->getErrors();
     $compareErrors = array('value' => array('Value cannot be blank.'));
     $this->assertEquals($compareErrors, $errors);
     $filter->value = 'jason';
     $validated = $filter->validate();
     $this->assertTrue($validated);
     //Test when not null is set as attribute, now the value is not required
     $filter->operator = OperatorRules::TYPE_IS_NOT_NULL;
     $filter->value = null;
     $validated = $filter->validate();
     $this->assertTrue($validated);
 }
 /**
  * @depends testValidatePhoneAttribute
  */
 public function testValidateEmailAttribute()
 {
     $filter = new FilterForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_ROWS_AND_COLUMNS);
     $filter->attributeIndexOrDerivedType = 'primaryEmail___emailAddress';
     $validated = $filter->validate();
     $this->assertFalse($validated);
     $errors = $filter->getErrors();
     $compareErrors = array('operator' => array('Operator cannot be blank.'));
     $this->assertEquals($compareErrors, $errors);
     $filter->operator = OperatorRules::TYPE_EQUALS;
     $validated = $filter->validate();
     $this->assertFalse($validated);
     $errors = $filter->getErrors();
     $compareErrors = array('value' => array('Value cannot be blank.'));
     $this->assertEquals($compareErrors, $errors);
     $filter->value = '*****@*****.**';
     $validated = $filter->validate();
     $this->assertTrue($validated);
     //Test when not null is set as attribute, now the value is not required
     $filter->operator = OperatorRules::TYPE_IS_NOT_NULL;
     $filter->value = null;
     $validated = $filter->validate();
     $this->assertTrue($validated);
 }