public static function setUpBeforeClass() { parent::setUpBeforeClass(); SecurityTestHelper::createSuperAdmin(); SavedReportTestHelper::makeSummationWithDrillDownReport(); SavedReportTestHelper::makeSimpleContactRowsAndColumnsReport(); }
public function testRegularUserAllControllerActionsNoElevation() { $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); SavedReportTestHelper::makeSimpleContactRowsAndColumnsReport(); $savedReports = SavedReport::getAll(); $nobody = $this->logoutCurrentUserLoginNewUserAndGetByUsername('nobody'); //should fail $this->setGetArray(array('id' => $savedReports[0]->id)); $this->resetPostArray(); $this->runControllerShouldResultInAccessFailureAndGetContent('reports/default/details'); $this->setGetArray(array('id' => $savedReports[0]->id)); $this->resetPostArray(); $this->runControllerShouldResultInAccessFailureAndGetContent('reports/default/edit'); $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); $this->assertTrue($savedReports[0]->delete()); }
/** * @depends testApplyAndResetRuntimeFilters */ public function testDrillDownDetails() { $savedReport = SavedReportTestHelper::makeSummationWithDrillDownReport(); $this->setGetArray(array('id' => $savedReport->id, 'rowId' => 2, 'runReport' => true, 'groupByRowValueowner__User' => Yii::app()->user->userModel->id)); $postData = static::makeSummationReportPostData(); $this->setPostArray($postData); $content = $this->runControllerWithNoExceptionsAndGetContent('reports/default/drillDownDetails'); $this->assertContains('<th id="report-results-grid-view2_c2">Currency Value</th>', $content); $this->assertContains('No results found', $content); //Check drillDown works with runtime filters $this->setPostArray(array('SummationReportWizardForm' => array('Filters' => array(array('attributeIndexOrDerivedType' => 'string', 'operator' => OperatorRules::TYPE_EQUALS, 'value' => 'string1'))))); $this->runControllerWithNoExceptionsAndGetContent('reports/default/applyRuntimeFilters', true); $content = $this->runControllerWithNoExceptionsAndGetContent('reports/default/drillDownDetails'); $this->assertContains('<th id="report-results-grid-view2_c2">Currency Value</th>', $content); $this->assertContains('1 result(s)', $content); }
public function testMakeReportDataProviderAndResolveAttributeName() { $contactReport = SavedReportTestHelper::makeSimpleContactRowsAndColumnsReport(); $contact1 = ContactTestHelper::createContactByNameForOwner('contact01', $this->super); $contact2 = ContactTestHelper::createContactByNameForOwner('contact02', $this->super); $attributeName = null; $reportDataProvider = MarketingListMembersUtil::makeReportDataProviderAndResolveAttributeName($contactReport->id, 1, $attributeName); $this->assertEquals('attribute1', $attributeName); $this->assertInstanceOf('RowsAndColumnsReportDataProvider', $reportDataProvider); $this->assertCount(1, $reportDataProvider->getData()); $attributeName = null; $reportDataProvider = MarketingListMembersUtil::makeReportDataProviderAndResolveAttributeName($contactReport->id, 2, $attributeName); $this->assertEquals('attribute1', $attributeName); $this->assertInstanceOf('RowsAndColumnsReportDataProvider', $reportDataProvider); $this->assertCount(2, $reportDataProvider->getData()); }
public function testSubscribeContactsForReportType() { $type = 'report'; $report = SavedReportTestHelper::makeSimpleContactRowsAndColumnsReport(); $marketingList = MarketingListTestHelper::createMarketingListByName('MarketingList5', 'MarketingList Description5'); $marketingListId = $marketingList->id; $contactCount = Contact::getCount(); $this->assertNotNull($report); $this->setGetArray(array('marketingListId' => $marketingListId, 'id' => $report->id, 'type' => $type)); $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/defaultPortlet/subscribeContacts'); $contentArray = CJSON::decode($content); $this->assertNotEmpty($contentArray); $this->assertArrayHasKey('type', $contentArray); $this->assertArrayHasKey('message', $contentArray); $this->assertEquals($contactCount . ' subscribed.', $contentArray['message']); $this->assertEquals('message', $contentArray['type']); $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/defaultPortlet/subscribeContacts'); $contentArray = CJSON::decode($content); $this->assertNotEmpty($contentArray); $this->assertArrayHasKey('type', $contentArray); $this->assertArrayHasKey('message', $contentArray); $this->assertEquals('0 subscribed. ' . $contactCount . ' skipped, already in the list.', $contentArray['message']); $this->assertEquals('message', $contentArray['type']); Yii::app()->pagination->setForCurrentUserByType('reportResultsListPageSize', 1); $this->setGetArray(array('marketingListId' => $marketingListId, 'id' => $report->id, 'type' => $type, 'page' => 2)); $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/defaultPortlet/subscribeContacts'); $contentArray = CJSON::decode($content); $percent = round(2 / $contactCount * 100, 0); // Not Coding Standard $this->assertNotEmpty($contentArray); $this->assertArrayHasKey('type', $contentArray); $this->assertArrayHasKey('message', $contentArray); $this->assertEquals("Processing: {$percent} % complete", $contentArray['message']); $this->assertEquals('message', $contentArray['type']); $this->assertEquals(3, $contentArray['nextPage']); $this->assertEquals(0, $contentArray['subscribedCount']); $this->assertEquals(1, $contentArray['skippedCount']); $this->setGetArray(array('marketingListId' => $marketingListId, 'id' => $report->id, 'type' => $type, 'page' => $contactCount, 'skippedCount' => $contactCount - 1, 'subscribedCount' => 0)); $content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/defaultPortlet/subscribeContacts'); $contentArray = CJSON::decode($content); $this->assertNotEmpty($contentArray); $this->assertArrayHasKey('type', $contentArray); $this->assertArrayHasKey('message', $contentArray); $this->assertEquals("0 subscribed. {$contactCount} skipped, already in the list.", $contentArray['message']); $this->assertEquals('message', $contentArray['type']); }
public function testSubscribeContactsForReportTypeFromPortletController() { $type = 'report'; $report = SavedReportTestHelper::makeSimpleContactRowsAndColumnsReport(); $this->assertNotNull($report); $contactCount = Contact::getCount(); $this->setGetArray(array('marketingListId' => static::$marketingList->id, 'id' => $report->id, 'type' => $type)); $content = $this->runControllerWithNoExceptionsAndGetContent($this->portletSubscribeContactsUrl); $contentArray = CJSON::decode($content); $this->assertNotEmpty($contentArray); $this->assertArrayHasKey('type', $contentArray); $this->assertArrayHasKey('message', $contentArray); $this->assertEquals('0 subscribed. ' . $contactCount . ' skipped, already in the list.', $contentArray['message']); $this->assertEquals('message', $contentArray['type']); $this->assertEquals(1, MarketingListMember::getCount()); }
/** * @depends testApplyAndResetRuntimeFilters */ public function testDrillDownDetails() { $savedReport = SavedReportTestHelper::makeSummationWithDrillDownReport(); if (RedBeanDatabase::isFrozen()) { return; } $this->setGetArray(array('id' => $savedReport->id, 'rowId' => 2, 'runReport' => true, 'groupByRowValueowner__User' => Yii::app()->user->userModel->id)); $postData = static::makeSummationReportPostData(); $this->setPostArray($postData); $content = $this->runControllerWithNoExceptionsAndGetContent('reports/default/drillDownDetails'); $this->assertTrue(strpos($content, '<th id="report-results-grid-view2_c2">Currency Value</th>') !== false); }
public function testRegularUserActionsWithMarketingListRightAndRequiredPermissions() { $this->setGetArray(array('id' => static::$regularUserMemberId)); $this->runControllerWithNoExceptionsAndGetContent('marketingLists/defaultPortlet/toggleUnsubscribed', true); $this->runControllerWithNoExceptionsAndGetContent('marketingLists/defaultPortlet/delete', true); $this->setGetArray(array('marketingListId' => static::$regularUserMarketingListId)); $this->runControllerWithNoExceptionsAndGetContent('marketingLists/defaultPortlet/countMembers'); $type = 'contact'; $account = AccountTestHelper::createAccountByNameForOwner('account2', $this->user); $contact8 = ContactTestHelper::createContactWithAccountByNameForOwner('contact8', $this->user, $account); $this->setGetArray(array('marketingListId' => static::$regularUserMarketingListId, 'id' => $contact8->id, 'type' => $type)); $this->runControllerWithNoExceptionsAndGetContent('marketingLists/defaultPortlet/subscribeContacts'); //$this->user->setRight('ReportsModule', ReportsModule::getAccessRight()); $this->user->setRight('ContactsModule', ContactsModule::getAccessRight()); // or leads. Else PartialRightsForReportSecurityException $this->assertTrue($this->user->save()); $type = 'report'; $report = SavedReportTestHelper::makeSimpleContactRowsAndColumnsReport(); $this->setGetArray(array('marketingListId' => static::$regularUserMarketingListId, 'id' => $report->id, 'type' => $type)); $this->runControllerWithNoExceptionsAndGetContent('marketingLists/defaultPortlet/subscribeContacts'); }