/**
  * @depends testGetAvailableAttributesForSummationDisplayAttributes
  */
 public function testGroupingOnDifferentModelAndMakingSureCorrectDisplayAttributesAreAvailable()
 {
     //Grouping on ReportModelTestItem, but we are looking at attributes in ReportModelTestItem2
     //so the name attribute should not show up as being available.
     $report = new Report();
     $report->setType(Report::TYPE_SUMMATION);
     $groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'phone';
     $model = new ReportModelTestItem2();
     $rules = new ReportsTestReportRules();
     $report->addGroupBy($groupBy);
     $report->setModuleClassName('ReportsTestModule');
     $adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model, $rules, $report->getType());
     $attributes = $adapter->getAttributesForDisplayAttributes($report->getGroupBys(), new ReportModelTestItem(), 'hasOne');
     $this->assertEquals(5, count($attributes));
     $compareData = array('label' => 'Count');
     $this->assertEquals($compareData, $attributes['Count']);
     $compareData = array('label' => 'Created Date Time -(Min)');
     $this->assertEquals($compareData, $attributes['createdDateTime__Minimum']);
     $compareData = array('label' => 'Created Date Time -(Max)');
     $this->assertEquals($compareData, $attributes['createdDateTime__Maximum']);
     $compareData = array('label' => 'Modified Date Time -(Min)');
     $this->assertEquals($compareData, $attributes['modifiedDateTime__Minimum']);
     $compareData = array('label' => 'Modified Date Time -(Max)');
     $this->assertEquals($compareData, $attributes['modifiedDateTime__Maximum']);
     //Now test where there is a second group by and it is the name attribute on ReportModelTestItem2
     $groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'hasOne___name';
     $report->addGroupBy($groupBy);
     $adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model, $rules, $report->getType());
     $attributes = $adapter->getAttributesForDisplayAttributes($report->getGroupBys(), new ReportModelTestItem(), 'hasOne');
     $this->assertEquals(6, count($attributes));
     $compareData = array('label' => 'Name');
     $this->assertEquals($compareData, $attributes['name']);
     $compareData = array('label' => 'Count');
     $this->assertEquals($compareData, $attributes['Count']);
     $compareData = array('label' => 'Created Date Time -(Min)');
     $this->assertEquals($compareData, $attributes['createdDateTime__Minimum']);
     $compareData = array('label' => 'Created Date Time -(Max)');
     $this->assertEquals($compareData, $attributes['createdDateTime__Maximum']);
     $compareData = array('label' => 'Modified Date Time -(Min)');
     $this->assertEquals($compareData, $attributes['modifiedDateTime__Minimum']);
     $compareData = array('label' => 'Modified Date Time -(Max)');
     $this->assertEquals($compareData, $attributes['modifiedDateTime__Maximum']);
     //Now test where there is a second group by and it is the name attribute on ReportModelTestItem2 but we
     //are coming from a different relationship
     $adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model, $rules, $report->getType());
     $attributes = $adapter->getAttributesForDisplayAttributes($report->getGroupBys(), new ReportModelTestItem(), 'hasOneAgain');
     $this->assertEquals(5, count($attributes));
     $this->assertFalse(isset($attributes['name']));
     //Test where the group by is 2 levels above
     $model = new ReportModelTestItem3();
     $groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'hasOne___hasMany3___somethingOn3';
     $report->addGroupBy($groupBy);
     $adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model, $rules, $report->getType());
     $attributes = $adapter->getAttributesForDisplayAttributes($report->getGroupBys(), new ReportModelTestItem2(), 'hasMany3');
     $this->assertEquals(6, count($attributes));
     $compareData = array('label' => 'Something On 3');
     $this->assertEquals($compareData, $attributes['somethingOn3']);
     $compareData = array('label' => 'Count');
     $this->assertEquals($compareData, $attributes['Count']);
     $compareData = array('label' => 'Created Date Time -(Min)');
     $this->assertEquals($compareData, $attributes['createdDateTime__Minimum']);
     $compareData = array('label' => 'Created Date Time -(Max)');
     $this->assertEquals($compareData, $attributes['createdDateTime__Maximum']);
     $compareData = array('label' => 'Modified Date Time -(Min)');
     $this->assertEquals($compareData, $attributes['modifiedDateTime__Minimum']);
     $compareData = array('label' => 'Modified Date Time -(Max)');
     $this->assertEquals($compareData, $attributes['modifiedDateTime__Maximum']);
 }
 /**
  * @depends testGetAttributesForOrderBys
  */
 public function testGetAttributesForDisplayAttributes()
 {
     $model = new ReportModelTestItem();
     $model2 = new ReportModelTestItem2();
     $rules = new ReportsTestReportRules();
     $report = new Report();
     $report->setType(Report::TYPE_SUMMATION);
     $report->setModuleClassName('ReportsTestModule');
     $groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'hasOne___name';
     $groupBy->axis = 'x';
     $report->addGroupBy($groupBy);
     $groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'hasOne___createdDateTime__Day';
     $groupBy->axis = 'x';
     $report->addGroupBy($groupBy);
     $groupBy = new GroupByForReportForm('ReportsTestModule', 'ReportModelTestItem', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'hasOne___owner__User';
     $groupBy->axis = 'x';
     $report->addGroupBy($groupBy);
     $adapter = new ModelRelationsAndAttributesToSummationReportAdapter($model2, $rules, $report->getType());
     $attributes = $adapter->getAttributesForDisplayAttributes($report->getGroupBys(), $model, 'hasOne');
     $this->assertEquals(8, count($attributes));
     $this->assertTrue(isset($attributes['name']));
     $this->assertTrue(isset($attributes['Count']));
     $this->assertTrue(isset($attributes['createdDateTime__Maximum']));
     $this->assertEquals('Name', $attributes['name']['label']);
     $this->assertEquals('Created Date Time -(Day)', $attributes['createdDateTime__Day']['label']);
     $this->assertEquals('Owner', $attributes['owner__User']['label']);
 }