コード例 #1
0
 public function setup()
 {
     parent::setUp();
     Yii::app()->user->userModel = User::getByUsername('super');
     DisplayAttributeForReportForm::resetCount();
     DrillDownDisplayAttributeForReportForm::resetCount();
 }
 public function setup()
 {
     parent::setUp();
     Yii::app()->user->userModel = User::getByUsername('super');
     Yii::app()->user->userModel->timeZone = 'America/Chicago';
     DisplayAttributeForReportForm::resetCount();
 }
コード例 #3
0
 /**
  * @depends testMakeStringForMultipleLinks
  */
 public function testMakeStringForLinkOrLinks()
 {
     $accounts = Account::getByName('account1');
     $account1 = $accounts[0];
     $account2 = $accounts[1];
     $displayAttribute = new DisplayAttributeForReportForm('AccountsModule', 'Account', Report::TYPE_ROWS_AND_COLUMNS);
     $displayAttribute->setModelAliasUsingTableAliasName('abc');
     $displayAttribute->attributeIndexOrDerivedType = 'name';
     $reportResultsRowData = new ReportResultsRowData(array($displayAttribute), 4);
     $reportResultsRowData->addModelAndAlias($account2, 'abc');
     $result = ReportResultsGridUtil::makeStringForLinkOrLinks('attribute0', $reportResultsRowData, true, 'account1');
     $this->assertContains('<span class="tooltip">2</span>', $result);
     $result = ReportResultsGridUtil::makeStringForLinkOrLinks('attribute0', $reportResultsRowData, false, 'account1');
     $this->assertContains('a target="new"', $result);
     $this->assertContains('id=' . $account2->id, $result);
     $this->assertNotContains('tooltip', $result);
 }
コード例 #4
0
 protected function resolveParamsForCurrencyTypes(DisplayAttributeForReportForm $displayAttribute, &$params)
 {
     assert('is_array($params)');
     if ($displayAttribute->isATypeOfCurrencyValue()) {
         $params['currencyValueConversionType'] = $this->report->getCurrencyConversionType();
         $params['spotConversionCurrencyCode'] = $this->report->getSpotConversionCurrencyCode();
         $params['fromBaseToSpotRate'] = $this->report->getFromBaseToSpotRate();
     }
 }
 public function testExportRelationAttributes()
 {
     $report = new Report();
     $report->setType(Report::TYPE_ROWS_AND_COLUMNS);
     $report->setModuleClassName('EmailMessagesModule');
     $report->setFiltersStructure('');
     $emailMessage = new EmailMessage();
     $emailMessage->owner = Yii::app()->user->userModel;
     $emailMessage->subject = 'A test email';
     $emailContent = new EmailMessageContent();
     $emailContent->textContent = 'A test text message from Zurmo.';
     $emailContent->htmlContent = 'A test text message from Zurmo.';
     $emailMessage->content = $emailContent;
     $sender = new EmailMessageSender();
     $sender->fromAddress = '*****@*****.**';
     $sender->fromName = 'super';
     $sender->personsOrAccounts->add(Yii::app()->user->userModel);
     $emailMessage->sender = $sender;
     $recipient = new EmailMessageRecipient();
     $recipient->toAddress = '*****@*****.**';
     $recipient->toName = 'Test Recipient';
     $recipient->type = EmailMessageRecipient::TYPE_TO;
     $emailMessage->recipients->add($recipient);
     $box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
     $emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_SENT);
     $this->assertTrue($emailMessage->save());
     $displayAttribute1 = new DisplayAttributeForReportForm('EmailMessagesModule', 'EmailMessage', Report::TYPE_ROWS_AND_COLUMNS);
     $displayAttribute1->setModelAliasUsingTableAliasName('relatedModel');
     $displayAttribute1->attributeIndexOrDerivedType = 'sender___User__personsOrAccounts__Inferred___firstName';
     $report->addDisplayAttribute($displayAttribute1);
     $displayAttribute2 = new DisplayAttributeForReportForm('EmailMessagesModule', 'EmailMessage', Report::TYPE_ROWS_AND_COLUMNS);
     $displayAttribute2->setModelAliasUsingTableAliasName('relatedModel');
     $displayAttribute2->attributeIndexOrDerivedType = 'sender___Contact__personsOrAccounts__Inferred___firstName';
     $report->addDisplayAttribute($displayAttribute2);
     $dataProvider = new RowsAndColumnsReportDataProvider($report);
     $adapter = ReportToExportAdapterFactory::createReportToExportAdapter($report, $dataProvider);
     $compareHeaderData = array('Sender >> Users >> First Name', 'Sender >> Contacts >> First Name');
     $compareRowData = array(array('Clark', ''));
     $this->assertEquals($compareHeaderData, $adapter->getHeaderData());
     $this->assertEquals($compareRowData, $adapter->getData());
 }
コード例 #6
0
 public function setUp()
 {
     parent::setUp();
     Yii::app()->user->userModel = User::getByUsername('super');
     DisplayAttributeForReportForm::resetCount();
     $freeze = false;
     if (RedBeanDatabase::isFrozen()) {
         RedBeanDatabase::unfreeze();
         $freeze = true;
     }
     $this->freeze = $freeze;
 }
コード例 #7
0
 /**
  * @return string
  */
 public static function getTreeType()
 {
     return DisplayAttributeForReportForm::getType();
 }
コード例 #8
0
 /**
  * @depends testExportByModelIds
  */
 public function testExportReportWithMultiplePagesOfData()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $numberOfUserNotifications = Notification::getCountByTypeAndUser('ExportProcessCompleted', Yii::app()->user->userModel);
     $report = new Report();
     $report->setType(Report::TYPE_ROWS_AND_COLUMNS);
     $report->setModuleClassName('AccountsModule');
     $report->setFiltersStructure('');
     $displayAttribute = new DisplayAttributeForReportForm('AccountsModule', 'Account', Report::TYPE_ROWS_AND_COLUMNS);
     $displayAttribute->setModelAliasUsingTableAliasName('model1');
     $displayAttribute->attributeIndexOrDerivedType = 'name';
     $report->addDisplayAttribute($displayAttribute);
     $dataProvider = new RowsAndColumnsReportDataProvider($report);
     $exportItem = new ExportItem();
     $exportItem->isCompleted = 0;
     $exportItem->exportFileType = 'csv';
     $exportItem->exportFileName = 'rowAndColumnsTest2';
     $exportItem->modelClassName = 'SavedReport';
     $exportItem->serializedData = ExportUtil::getSerializedDataForExport($dataProvider);
     $this->assertTrue($exportItem->save());
     $id = $exportItem->id;
     $exportItem->forget();
     unset($exportItem);
     //Delete queued jobs from test exportItems created above
     Yii::app()->jobQueue->deleteAll();
     ExportModule::$asynchronousPageSize = 2;
     $job = new ExportJob();
     $this->assertEquals(0, count(Yii::app()->jobQueue->getAll()));
     $this->assertTrue($job->run());
     $this->assertEquals(0, count(Yii::app()->jobQueue->getAll()));
     $exportItem = ExportItem::getById($id);
     $fileModel = $exportItem->exportFileModel;
     $this->assertEquals(1, $exportItem->isCompleted);
     $this->assertEquals(0, $exportItem->processOffset);
     $this->assertEquals('csv', $exportItem->exportFileType);
     $this->assertEquals('rowAndColumnsTest2', $exportItem->exportFileName);
     $this->assertTrue($fileModel instanceof ExportFileModel);
     $accounts = Account::getAll();
     $headerData = array('Name');
     $data = array();
     foreach ($accounts as $account) {
         $data[] = array($account->name);
     }
     $output = ExportItemToCsvFileUtil::export($data, $headerData, 'rowAndColumnsTest2.csv', false);
     $this->assertEquals($output, $fileModel->fileContent->content);
     // Check if user got notification message, and if its type is ExportProcessCompleted
     $this->assertEquals($numberOfUserNotifications + 1, Notification::getCountByTypeAndUser('ExportProcessCompleted', Yii::app()->user->userModel));
     //Matrix report should not paginate
     $report = new Report();
     $report->setType(Report::TYPE_MATRIX);
     $report->setModuleClassName('AccountsModule');
     $report->setFiltersStructure('');
     $displayAttribute = new DisplayAttributeForReportForm('AccountsModule', 'Account', Report::TYPE_MATRIX);
     $displayAttribute->setModelAliasUsingTableAliasName('model1');
     $displayAttribute->attributeIndexOrDerivedType = 'Count';
     $report->addDisplayAttribute($displayAttribute);
     $groupBy = new GroupByForReportForm('AccountsModule', 'Account', Report::TYPE_MATRIX);
     $groupBy->attributeIndexOrDerivedType = 'name';
     $groupBy->axis = 'y';
     $report->addGroupBy($groupBy);
     $groupBy = new GroupByForReportForm('AccountsModule', 'Account', Report::TYPE_MATRIX);
     $groupBy->attributeIndexOrDerivedType = 'officePhone';
     $report->addGroupBy($groupBy);
     $dataProvider = new MatrixReportDataProvider($report);
     $exportItem = new ExportItem();
     $exportItem->isCompleted = 0;
     $exportItem->exportFileType = 'csv';
     $exportItem->exportFileName = 'matrixTest1';
     $exportItem->modelClassName = 'SavedReport';
     $exportItem->serializedData = ExportUtil::getSerializedDataForExport($dataProvider);
     $this->assertTrue($exportItem->save());
     $id = $exportItem->id;
     $exportItem->forget();
     unset($exportItem);
     //Delete queued jobs from test exportItems created above
     Yii::app()->jobQueue->deleteAll();
     ExportModule::$asynchronousPageSize = 2;
     $job = new ExportJob();
     $this->assertTrue($job->run());
     $exportItem = ExportItem::getById($id);
     $fileModel = $exportItem->exportFileModel;
     $this->assertEquals(1, $exportItem->isCompleted);
     $this->assertEquals(0, $exportItem->processOffset);
     $this->assertEquals('csv', $exportItem->exportFileType);
     $this->assertEquals('matrixTest1', $exportItem->exportFileName);
     $this->assertTrue($fileModel instanceof ExportFileModel);
     $fileContent = $fileModel->fileContent->content;
     $this->assertContains('Test Account', $fileContent);
     $this->assertContains('Test Account 2', $fileContent);
     $this->assertContains('Test Account 3', $fileContent);
     $this->assertContains('Test Account 4', $fileContent);
     // Check if user got notification message, and if its type is ExportProcessCompleted
     $this->assertEquals($numberOfUserNotifications + 2, Notification::getCountByTypeAndUser('ExportProcessCompleted', Yii::app()->user->userModel));
 }
コード例 #9
0
 /**
  * There was a bug with showing address->state on a contact rows and columns report. it was showing the
  * contact->state instead. this test passes after this bug was fixed
  */
 public function testDisplayingAOwnedModelAttributeThatIsAlsoDefinedAsAnAttributeOnTheOwningModel()
 {
     $contactStates = ContactState::getByName('Qualified');
     $contact = new Contact();
     $contact->owner = Yii::app()->user->userModel;
     $contact->title->value = 'Mr.';
     $contact->firstName = 'Super';
     $contact->lastName = 'Man';
     $contact->jobTitle = 'Superhero';
     $contact->description = 'Some Description';
     $contact->department = 'Red Tape';
     $contact->officePhone = '1234567890';
     $contact->mobilePhone = '0987654321';
     $contact->officeFax = '1222222222';
     $contact->state = $contactStates[0];
     $contact->primaryAddress->state = 'IL';
     $this->assertTrue($contact->save());
     $displayAttribute = new DisplayAttributeForReportForm('ContactsModule', 'Contact', Report::TYPE_ROWS_AND_COLUMNS);
     $displayAttribute->setModelAliasUsingTableAliasName('abc');
     $displayAttribute->attributeIndexOrDerivedType = 'primaryAddress___state';
     $this->assertEquals('col0', $displayAttribute->columnAliasName);
     $reportResultsRowData = new ReportResultsRowData(array($displayAttribute), 4);
     $reportResultsRowData->addModelAndAlias($contact, 'abc');
     $model = $reportResultsRowData->getModel('attribute0');
     $this->assertEquals('IL', $model->primaryAddress->state);
     $this->assertEquals('IL', $reportResultsRowData->attribute0);
 }
コード例 #10
0
 /**
  * Test for viaSelect and viaModel together
  * @depends testExportSummationAttributes
  */
 public function testViaSelectAndViaModelTogether()
 {
     $reportModelTestItem = new ReportModelTestItem();
     $report = new Report();
     //viaSelect attribute
     $displayAttribute1 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute1->attributeIndexOrDerivedType = 'integer__Minimum';
     $displayAttribute1->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute1->columnAliasName == 'col0');
     //viaModel attribute
     $reportModelTestItem->boolean = true;
     $displayAttribute2 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_ROWS_AND_COLUMNS);
     $displayAttribute2->setModelAliasUsingTableAliasName('model1');
     $displayAttribute2->attributeIndexOrDerivedType = 'boolean';
     $reportResultsRowData = new ReportResultsRowData(array($displayAttribute1, $displayAttribute2), 4);
     $reportResultsRowData->addSelectedColumnNameAndValue('col0', 9000);
     $reportResultsRowData->addModelAndAlias($reportModelTestItem, 'model1');
     $adapter = new ReportToExportAdapter($reportResultsRowData, $report);
     $compareHeaderData = array('Integer -(Min)', 'Boolean');
     $compareRowData = array(9000, true);
     $this->assertEquals($compareHeaderData, $adapter->getHeaderData());
     $this->assertEquals($compareRowData, $adapter->getData());
 }
 public function testDynamicallyDerivedAttributeOnSelf()
 {
     $q = DatabaseCompatibilityUtil::getQuote();
     //2 __User attributes on the same model
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('ReportModelTestItem9');
     $selectQueryAdapter = new RedBeanModelSelectQueryAdapter();
     $builder = new DisplayAttributesReportQueryBuilder($joinTablesAdapter, $selectQueryAdapter);
     $displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem9', Report::TYPE_ROWS_AND_COLUMNS);
     $displayAttribute->attributeIndexOrDerivedType = 'createdByUser__User';
     $displayAttribute2 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem9', Report::TYPE_ROWS_AND_COLUMNS);
     $displayAttribute2->attributeIndexOrDerivedType = 'modifiedByUser__User';
     $content = $builder->makeQueryContent(array($displayAttribute, $displayAttribute2));
     $compareContent = "select {$q}reportmodeltestitem9{$q}.{$q}id{$q} reportmodeltestitem9id ";
     $this->assertEquals($compareContent, $content);
     $this->assertEquals(0, $joinTablesAdapter->getFromTableJoinCount());
     $this->assertEquals(0, $joinTablesAdapter->getLeftTableJoinCount());
     $idTableAliasesAndModelClassNames = $selectQueryAdapter->getIdTableAliasesAndModelClassNames();
     $this->assertCount(1, $idTableAliasesAndModelClassNames);
     $this->assertEquals('ReportModelTestItem9', $idTableAliasesAndModelClassNames['reportmodeltestitem9']);
     //2 __User attributes on the same model, one is owned, so not originating both from Item
     DisplayAttributeForReportForm::resetCount();
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('ReportModelTestItem9');
     $selectQueryAdapter = new RedBeanModelSelectQueryAdapter();
     $builder = new DisplayAttributesReportQueryBuilder($joinTablesAdapter, $selectQueryAdapter);
     $displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem9', Report::TYPE_ROWS_AND_COLUMNS);
     $displayAttribute->attributeIndexOrDerivedType = 'createdByUser__User';
     $displayAttribute2 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem9', Report::TYPE_ROWS_AND_COLUMNS);
     $displayAttribute2->attributeIndexOrDerivedType = 'owner__User';
     $content = $builder->makeQueryContent(array($displayAttribute, $displayAttribute2));
     $compareContent = "select {$q}reportmodeltestitem9{$q}.{$q}id{$q} reportmodeltestitem9id ";
     $this->assertEquals($compareContent, $content);
     $this->assertEquals(0, $joinTablesAdapter->getFromTableJoinCount());
     $this->assertEquals(0, $joinTablesAdapter->getLeftTableJoinCount());
     $idTableAliasesAndModelClassNames = $selectQueryAdapter->getIdTableAliasesAndModelClassNames();
     $this->assertCount(1, $idTableAliasesAndModelClassNames);
     $this->assertEquals('ReportModelTestItem9', $idTableAliasesAndModelClassNames['reportmodeltestitem9']);
     $idTableAliasesAndModelClassNames = $selectQueryAdapter->getIdTableAliasesAndModelClassNames();
     $this->assertCount(1, $idTableAliasesAndModelClassNames);
     $this->assertEquals('ReportModelTestItem9', $idTableAliasesAndModelClassNames['reportmodeltestitem9']);
 }
コード例 #12
0
 /**
  * @param DisplayAttributeForReportForm $displayAttribute
  * @param mixed $value
  * @return mixed
  * @throws NotSupportedException if the currencyConversionType is invalid or null, when the displayAttribute
  * is a currency type
  */
 protected function formatValue(DisplayAttributeForReportForm $displayAttribute, $value)
 {
     if ($displayAttribute->isATypeOfCurrencyValue()) {
         if ($this->report->getCurrencyConversionType() == Report::CURRENCY_CONVERSION_TYPE_ACTUAL) {
             return Yii::app()->numberFormatter->formatDecimal((double) $value);
         } elseif ($this->report->getCurrencyConversionType() == Report::CURRENCY_CONVERSION_TYPE_BASE) {
             return Yii::app()->numberFormatter->formatCurrency((double) $value, Yii::app()->currencyHelper->getBaseCode());
         } elseif ($this->report->getCurrencyConversionType() == Report::CURRENCY_CONVERSION_TYPE_SPOT) {
             return Yii::app()->numberFormatter->formatCurrency((double) $value * $this->report->getFromBaseToSpotRate(), $this->report->getSpotConversionCurrencyCode());
         } else {
             throw new NotSupportedException();
         }
     } elseif ($displayAttribute->getDisplayElementType() == 'Decimal') {
         return Yii::app()->numberFormatter->formatDecimal((double) $value);
     } elseif ($displayAttribute->getDisplayElementType() == 'Integer') {
         return Yii::app()->numberFormatter->formatDecimal((int) $value);
     } elseif ($displayAttribute->getDisplayElementType() == 'Date') {
         return DateTimeUtil::resolveValueForDateLocaleFormattedDisplay($value);
     } elseif ($displayAttribute->getDisplayElementType() == 'DateTime') {
         return DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($value);
     } else {
         return $value;
     }
 }
 public function testResolveValueOnBaseModelAndRelatedModel()
 {
     $reportModelTestItem11 = new ReportModelTestItem11();
     $reportModelTestItem11->integer = 5;
     $currencies = Currency::getAll();
     $currencyValue = new CurrencyValue();
     $currencyValue->value = 100;
     $currencyValue->currency = $currencies[0];
     $reportModelTestItem11->amount = $currencyValue;
     $reportModelTestItem11b = new ReportModelTestItem11();
     $reportModelTestItem11b->integer = 7;
     $currencyValue = new CurrencyValue();
     $currencyValue->value = 200;
     $currencyValue->currency = $currencies[0];
     $reportModelTestItem11b->amount = $currencyValue;
     $reportModelTestItem10 = new ReportModelTestItem10();
     $reportModelTestItem10->integer = 12;
     $currencyValue = new CurrencyValue();
     $currencyValue->value = 400;
     $currencyValue->currency = $currencies[0];
     $reportModelTestItem10->currencyValue = $currencyValue;
     $reportModelTestItem10->reportModelTestItem11->add($reportModelTestItem11);
     $reportModelTestItem10->reportModelTestItem11->add($reportModelTestItem11b);
     $saved = $reportModelTestItem10->save();
     $this->assertTrue($saved);
     $displayAttributeX = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem10', Report::TYPE_ROWS_AND_COLUMNS);
     $displayAttributeX->setModelAliasUsingTableAliasName('abc');
     $displayAttributeX->attributeIndexOrDerivedType = 'reportModelTestItem11___calculated2';
     $this->assertEquals('col0', $displayAttributeX->columnAliasName);
     $displayAttributeY = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem10', Report::TYPE_ROWS_AND_COLUMNS);
     $displayAttributeY->setModelAliasUsingTableAliasName('def');
     $displayAttributeY->attributeIndexOrDerivedType = 'calculated';
     $this->assertEquals('col1', $displayAttributeY->columnAliasName);
     $reportResultsRowData = new ReportResultsRowData(array($displayAttributeX, $displayAttributeY), 4);
     $reportResultsRowData->addModelAndAlias($reportModelTestItem11b, 'abc');
     $reportResultsRowData->addModelAndAlias($reportModelTestItem10, 'def');
     //Get value for calculated which is on base model
     $value = CalculatedNumberForReportListViewColumnAdapter::resolveValue('attribute1', $reportResultsRowData);
     $this->assertEquals('$412.00', $value);
     //Get value for calculated2 which is on a relateds model
     $value = CalculatedNumberForReportListViewColumnAdapter::resolveValue('attribute0', $reportResultsRowData);
     $this->assertEquals('$207.00', $value);
 }
コード例 #14
0
 /**
  * @param DisplayAttributeForReportForm $displayAttribute
  * @param RedBeanModel $model
  * @return mixed $value
  */
 protected function resolveRawValueByModel(DisplayAttributeForReportForm $displayAttribute, RedBeanModel $model)
 {
     $type = $displayAttribute->getDisplayElementType();
     $attribute = $displayAttribute->getResolvedAttribute();
     if ($type == 'CurrencyValue') {
         return $model->{$attribute}->value;
     } elseif ($type == 'User') {
         $realAttributeName = $displayAttribute->getResolvedAttributeRealAttributeName();
         return $model->{$realAttributeName}->id;
     } elseif ($type == 'DropDown') {
         return $model->{$attribute}->value;
     } elseif (null != ($rawValueRelatedAttribute = $displayAttribute->getRawValueRelatedAttribute())) {
         return $model->{$attribute}->{$rawValueRelatedAttribute};
     } else {
         return $this->resolveModelAttributeValueForPenultimateRelation($model, $attribute, $displayAttribute);
     }
 }
コード例 #15
0
 public function testSqlQueryWithLinkTypeSpecificOnRelatedModels()
 {
     $quote = DatabaseCompatibilityUtil::getQuote();
     Yii::app()->user->userModel = User::getByUsername('super');
     $reportModelTestItem2 = new ReportModelTestItem2();
     $reportModelTestItem2->name = 'name';
     $this->assertTrue($reportModelTestItem2->save());
     $reportModelTestItem = new ReportModelTestItem();
     $reportModelTestItem->lastName = 'lastName';
     $reportModelTestItem->string = 'string';
     $reportModelTestItem->hasOne = $reportModelTestItem2;
     $this->assertTrue($reportModelTestItem->save());
     $report = new Report();
     $report->setType(Report::TYPE_ROWS_AND_COLUMNS);
     $report->setModuleClassName('ReportsTest2Module');
     $report->setFiltersStructure('');
     $displayAttribute1 = new DisplayAttributeForReportForm('ReportsTest2Module', 'ReportModelTestItem2', Report::TYPE_ROWS_AND_COLUMNS);
     $displayAttribute1->setModelAliasUsingTableAliasName('relatedModel');
     $displayAttribute1->attributeIndexOrDerivedType = 'hasMany2___FullName';
     $report->addDisplayAttribute($displayAttribute1);
     $dataProvider = new RowsAndColumnsReportDataProvider($report);
     $content = $dataProvider->makeSqlQueryForDisplay();
     $compareContent = "select {$quote}reportmodeltestitem{$quote}.{$quote}id{$quote} reportmodeltestitemid " . "from {$quote}reportmodeltestitem2{$quote} " . "left join {$quote}reportmodeltestitem{$quote} on " . "{$quote}reportmodeltestitem{$quote}.{$quote}hasone_reportmodeltestitem2_id{$quote} " . "= {$quote}reportmodeltestitem2{$quote}.{$quote}id{$quote}  limit 10 offset 0";
     $this->assertEquals($compareContent, $content);
 }
コード例 #16
0
 /**
  * @param array $data
  * @param Report $report
  */
 protected static function resolveDisplayAttributes($data, Report $report)
 {
     $report->removeAllDisplayAttributes();
     DisplayAttributeForReportForm::resetCount();
     $moduleClassName = $report->getModuleClassName();
     if (count($displayAttributesData = ArrayUtil::getArrayValue($data, ComponentForReportForm::TYPE_DISPLAY_ATTRIBUTES)) > 0) {
         foreach ($displayAttributesData as $key => $displayAttributeData) {
             $displayAttribute = new DisplayAttributeForReportForm($moduleClassName, $moduleClassName::getPrimaryModelName(), $report->getType(), $key);
             $displayAttribute->setAttributes($displayAttributeData);
             $report->addDisplayAttribute($displayAttribute);
         }
     } else {
         $report->removeAllDisplayAttributes();
     }
 }
コード例 #17
0
 public function testGetDisplayLabel()
 {
     $displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute->attributeIndexOrDerivedType = 'string';
     $this->assertEquals('String', $displayAttribute->getDisplayLabel());
     $displayAttribute->attributeIndexOrDerivedType = 'hasOne___name';
     $this->assertEquals('ReportModelTestItem2 >> Name', $displayAttribute->getDisplayLabel());
     $displayAttribute->attributeIndexOrDerivedType = 'hasMany___name';
     $this->assertEquals('ReportModelTestItem3s >> Name', $displayAttribute->getDisplayLabel());
     $displayAttribute->attributeIndexOrDerivedType = 'primaryAddress___street1';
     $this->assertEquals('Primary Address >> Street 1', $displayAttribute->getDisplayLabel());
 }
コード例 #18
0
 /**
  * @param DisplayAttributeForReportForm $displayAttribute
  * @return array
  */
 protected function resolveParamsForColumnElement(DisplayAttributeForReportForm $displayAttribute)
 {
     $params = array();
     if ($displayAttribute->isALinkableAttribute() == 'name') {
         $params['isLink'] = true;
     } elseif ($displayAttribute->isATypeOfCurrencyValue()) {
         $params['currencyValueConversionType'] = $this->dataProvider->getReport()->getCurrencyConversionType();
         $params['spotConversionCurrencyCode'] = $this->dataProvider->getReport()->getSpotConversionCurrencyCode();
         $params['fromBaseToSpotRate'] = $this->dataProvider->getReport()->getFromBaseToSpotRate();
     }
     return $params;
 }
 public function testViaSelectAndViaModelTogether()
 {
     $reportModelTestItem = new ReportModelTestItem();
     $reportModelTestItem->string = 'string';
     $reportModelTestItem->lastName = 'lastName';
     $reportModelTestItem->integer = 9000;
     $reportModelTestItem->boolean = true;
     $this->assertTrue($reportModelTestItem->save());
     $report = new Report();
     $report->setType(Report::TYPE_SUMMATION);
     $report->setModuleClassName('ReportsTestModule');
     $report->setFiltersStructure('');
     //viaSelect attribute
     $displayAttribute1 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute1->attributeIndexOrDerivedType = 'integer__Minimum';
     $displayAttribute1->madeViaSelectInsteadOfViaModel = true;
     $this->assertTrue($displayAttribute1->columnAliasName == 'col0');
     $report->addDisplayAttribute($displayAttribute1);
     //viaModel attribute
     $reportModelTestItem->boolean = true;
     $displayAttribute2 = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttribute2->setModelAliasUsingTableAliasName('model1');
     $displayAttribute2->attributeIndexOrDerivedType = 'boolean';
     $report->addDisplayAttribute($displayAttribute2);
     $dataProvider = new SummationReportDataProvider($report);
     $adapter = ReportToExportAdapterFactory::createReportToExportAdapter($report, $dataProvider);
     $compareHeaderData = array('Integer -(Min)', 'Boolean');
     $compareRowData = array(array(9000, true), array('Total'));
     $this->assertEquals($compareHeaderData, $adapter->getHeaderData());
     $this->assertEquals($compareRowData, $adapter->getData());
     $reportModelTestItem->delete();
 }
コード例 #20
0
 public function testValidateDisplayAttributes()
 {
     $rowsAndColumnsReportWizardForm = new RowsAndColumnsReportWizardForm();
     $reportModelTestItem = new ReportModelTestItem();
     $reportModelTestItem->date = '2013-02-12';
     $displayAttribute = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_ROWS_AND_COLUMNS);
     $displayAttribute->setModelAliasUsingTableAliasName('model1');
     $displayAttribute->attributeIndexOrDerivedType = 'date';
     $rowsAndColumnsReportWizardForm->displayAttributes = array($displayAttribute);
     $rowsAndColumnsReportWizardForm->validateDisplayAttributes();
     $this->assertFalse($rowsAndColumnsReportWizardForm->hasErrors());
 }
コード例 #21
0
 public function testGetAttributeLabel()
 {
     $reportModelTestItemX = new ReportModelTestItem();
     $reportModelTestItemX->string = 'someString';
     $displayAttributeX = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttributeX->setModelAliasUsingTableAliasName('abc');
     $displayAttributeX->attributeIndexOrDerivedType = 'string';
     $displayAttributeY = new DisplayAttributeForReportForm('ReportsTestModule', 'ReportModelTestItem', Report::TYPE_SUMMATION);
     $displayAttributeY->attributeIndexOrDerivedType = 'integer__Maximum';
     $reportResultsRowData = new ReportResultsRowData(array($displayAttributeX, $displayAttributeY), 4);
     $reportResultsRowData->addModelAndAlias($reportModelTestItemX, 'abc');
     $reportResultsRowData->addSelectedColumnNameAndValue('col1', 55);
     //Test a viaModel attribute
     $this->assertEquals('String', $reportResultsRowData->getAttributeLabel('attribute0'));
     //Test a viaSelect attriubte
     $this->assertEquals('Integer -(Max)', $reportResultsRowData->getAttributeLabel('col1'));
 }