public function testRegularUserAllDefaultControllerActions()
 {
     MarketingListTestHelper::createMarketingListByName('MarketingListName02', 'MarketingList Description', 'first', '*****@*****.**');
     $campaign = CampaignTestHelper::createCampaign('campaign02', 'campaign subject 02', 'text content for campaign 02', 'html content for campaign 02', 'fromCampaign', '*****@*****.**');
     $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default');
     $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/index');
     $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/list');
     $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/create');
     $this->setGetArray(array('id' => $campaign->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/edit');
     $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/details');
     $this->resetGetArray();
     $this->user->setRight('CampaignsModule', CampaignsModule::getAccessRight());
     $this->assertTrue($this->user->save());
     $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default');
     $this->assertContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content);
     $this->user->setRight('MarketingListsModule', MarketingListsModule::getAccessRight());
     $this->user->setRight('EmailTemplatesModule', EmailTemplatesModule::getAccessRight());
     $this->assertTrue($this->user->save());
     $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default');
     $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content);
     $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/index');
     $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content);
     $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list');
     $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content);
     $this->setGetArray(array('id' => $campaign->id));
     $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/details');
     $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content);
     $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/details');
     $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content);
     $this->resetGetArray();
     $this->user->setRight('CampaignsModule', CampaignsModule::getCreateRight());
     $this->assertTrue($this->user->save());
     $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/create');
     $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content);
     $this->setGetArray(array('id' => $campaign->id));
     $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/details');
     $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content);
     $this->resetGetArray();
     $this->user->setRight('CampaignsModule', CampaignsModule::getCreateRight());
     $this->assertTrue($this->user->save());
     $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/create');
     $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content);
     $this->setGetArray(array('id' => $campaign->id));
     $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/edit');
     $this->assertNotContains('<p>To manage campaigns you must have access to email templates and ' . 'marketing lists. Contact the CRM administrator about this issue.</p>', $content);
     $this->user->setRight('CampaignsModule', CampaignsModule::getDeleteRight());
     $this->assertTrue($this->user->save());
     $this->runControllerWithRedirectExceptionAndGetUrl('campaigns/default/delete');
     $this->setGetArray(array('id' => static::$campaignOwnedBySuper->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/edit');
     $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/details');
     $this->runControllerShouldResultInAccessFailureAndGetContent('campaigns/default/delete');
 }
 public function testAllDefaultControllerActions()
 {
     $this->user->setRight('ContactsModule', ContactsModule::getAccessRight());
     $this->assertTrue($this->user->save());
     $emailTemplate = EmailTemplateTestHelper::create('Test Name Regular 01', 'Test Subject Regular 01', 'Contact', 'Test HtmlContent Regular 01', 'Test TextContent Regular 01');
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default');
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/index');
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/listForMarketing');
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/listForWorkflow');
     $this->setGetArray(array('type' => EmailTemplate::TYPE_CONTACT));
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/create');
     $this->setGetArray(array('id' => $emailTemplate->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/edit');
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/details');
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/delete');
     $this->resetGetArray();
     $this->user->setRight('EmailTemplatesModule', EmailTemplatesModule::getAccessRight());
     $this->assertTrue($this->user->save());
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default');
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/index');
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/listForMarketing');
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/listForWorkflow');
     $this->setGetArray(array('id' => $emailTemplate->id));
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/details');
     $this->resetGetArray();
     $this->user->setRight('EmailTemplatesModule', EmailTemplatesModule::getCreateRight());
     $this->assertTrue($this->user->save());
     $this->setGetArray(array('type' => EmailTemplate::TYPE_CONTACT, 'builtType' => EmailTemplate::BUILT_TYPE_PLAIN_TEXT_ONLY));
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/create');
     $this->setGetArray(array('type' => EmailTemplate::TYPE_WORKFLOW, 'builtType' => EmailTemplate::BUILT_TYPE_PLAIN_TEXT_ONLY));
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/create');
     $this->setGetArray(array('id' => $emailTemplate->id));
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/edit');
     $this->user->setRight('EmailTemplatesModule', EmailTemplatesModule::getDeleteRight());
     $this->assertTrue($this->user->save());
     $this->runControllerWithRedirectExceptionAndGetUrl('emailTemplates/default/delete');
     $this->setGetArray(array('id' => static::$templateOwnedBySuper->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/edit');
     RedBeanModel::forgetAll();
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/details');
     RedBeanModel::forgetAll();
     $this->runControllerShouldResultInAccessFailureAndGetContent('emailTemplates/default/delete');
 }