/**
  * @depends testGetAvailableAttributesForSummationOrderBys
  */
 public function testGetAvailableAttributesForSummationOrderBysThatAreDisplayCalculations()
 {
     //You can only order what is grouped on or a display calculation attribute
     $model = new ReportModelTestItem();
     $rules = new ReportsTestReportRules();
     $report = new Report();
     $report->setType(Report::TYPE_SUMMATION);
     $report->setModuleClassName('ReportsTestModule');
     $adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model, $rules, $report->getType());
     $attributes = $adapter->getAttributesForOrderBys($report->getGroupBys(), $report->getDisplayAttributes());
     $this->assertEquals(0, count($attributes));
     $displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $this->assertNull($displayAttribute->label);
     $displayAttribute->attributeIndexOrDerivedType = 'createdDateTime__Minimum';
     $report->addDisplayAttribute($displayAttribute);
     $adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model, $rules, $report->getType());
     $attributes = $adapter->getAttributesForOrderBys($report->getGroupBys(), $report->getDisplayAttributes());
     $this->assertEquals(1, count($attributes));
     $this->assertTrue(isset($attributes['createdDateTime__Minimum']));
     $compareData = array('label' => 'Created Date Time -(Min)');
     $this->assertEquals($compareData, $attributes['createdDateTime__Minimum']);
     $displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $this->assertNull($displayAttribute->label);
     $displayAttribute->attributeIndexOrDerivedType = 'integer__Minimum';
     $report->addDisplayAttribute($displayAttribute);
     $adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model, $rules, $report->getType());
     $attributes = $adapter->getAttributesForOrderBys($report->getGroupBys(), $report->getDisplayAttributes());
     $this->assertEquals(2, count($attributes));
     $this->assertTrue(isset($attributes['integer__Minimum']));
     $compareData = array('label' => 'Integer -(Min)');
     $this->assertEquals($compareData, $attributes['integer__Minimum']);
     //This should not add because we are at the wrong point in the chain
     $displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $this->assertNull($displayAttribute->label);
     $displayAttribute->attributeIndexOrDerivedType = 'hasOne___createdDateTime__Minimum';
     $report->addDisplayAttribute($displayAttribute);
     $adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model, $rules, $report->getType());
     $attributes = $adapter->getAttributesForOrderBys($report->getGroupBys(), $report->getDisplayAttributes());
     $this->assertEquals(2, count($attributes));
     $this->assertFalse(isset($attributes['hasOne___createdDateTime__Minimum']));
 }
 /**
  * @depends testGetAttributesForDisplayAttributes
  */
 public function testGetAttributesForOrderBysOnUser()
 {
     $model = new ReportModelTestItem();
     $rules = new ReportsTestReportRules();
     $report = new Report();
     $report->setType(Report::TYPE_SUMMATION);
     $report->setModuleClassName('ReportsTestModule');
     $groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'owner__User';
     $groupBy->axis = 'x';
     $report->addGroupBy($groupBy);
     $groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'createdDateTime__Day';
     $groupBy->axis = 'x';
     $report->addGroupBy($groupBy);
     $displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $displayAttribute->attributeIndexOrDerivedType = 'owner__User';
     $report->addDisplayAttribute($displayAttribute);
     $adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model, $rules, $report->getType());
     $attributes = $adapter->getAttributesForOrderBys($report->getGroupBys(), $report->getDisplayAttributes());
     $this->assertEquals(2, count($attributes));
     $this->assertTrue(isset($attributes['owner__User']));
     $this->assertEquals('Owner', $attributes['owner__User']['label']);
     $this->assertEquals('Created Date Time -(Day)', $attributes['createdDateTime__Day']['label']);
 }