/** * @param $modelAttributeToDataProviderAdapter * @param null |string $onTableAliasName * @return string */ protected function resolveFinalContent($modelAttributeToDataProviderAdapter, $onTableAliasName = null) { $columnContent = ModelDataProviderUtil::resolveGroupByAttributeColumnName($modelAttributeToDataProviderAdapter, $this->joinTablesAdapter, $onTableAliasName); return $this->resolveColumnContentForCalculatedModifier($columnContent); }
/** * @depends testResolveGroupByAttributeColumnName */ public function testResolveGroupByWhenThereAreTableAliases() { $quote = DatabaseCompatibilityUtil::getQuote(); //Test a customField like TestCustomFieldsModel->industry $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('TestCustomFieldsModel'); $modelAttributeToDataProviderAdapter = new RedBeanModelAttributeToDataProviderAdapter('TestCustomFieldsModel', 'industry', 'value'); $groupBy = ModelDataProviderUtil::resolveGroupByAttributeColumnName($modelAttributeToDataProviderAdapter, $joinTablesAdapter); $this->assertEquals("{$quote}customfield{$quote}.{$quote}value{$quote}", $groupBy); $this->assertEquals(0, $joinTablesAdapter->getFromTableJoinCount()); $this->assertEquals(1, $joinTablesAdapter->getLeftTableJoinCount()); $leftTables = $joinTablesAdapter->getLeftTablesAndAliases(); $this->assertEquals('customfield', $leftTables[0]['tableName']); //Now add a second sort on a different CustomField $modelAttributeToDataProviderAdapter = new RedBeanModelAttributeToDataProviderAdapter('TestCustomFieldsModel', 'market', 'value'); $groupBy = ModelDataProviderUtil::resolveGroupByAttributeColumnName($modelAttributeToDataProviderAdapter, $joinTablesAdapter); $this->assertEquals("{$quote}customfield1{$quote}.{$quote}value{$quote}", $groupBy); $this->assertEquals(0, $joinTablesAdapter->getFromTableJoinCount()); $this->assertEquals(2, $joinTablesAdapter->getLeftTableJoinCount()); $leftTables = $joinTablesAdapter->getLeftTablesAndAliases(); $this->assertEquals('customfield', $leftTables[1]['tableName']); $this->assertEquals('customfield1', $leftTables[1]['tableAliasName']); }