public static function setUpBeforeClass() { parent::setUpBeforeClass(); SecurityTestHelper::createSuperAdmin(); $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; //Make sure everyone group is created $group = Group::getByName(Group::EVERYONE_GROUP_NAME); $group->save(); //Setup test data owned by the super user. $account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super); ContactTestHelper::createContactWithAccountByNameForOwner('superContact', $super, $account); OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpportunity', $super, $account); ProductTestHelper::createProductStagesIfDoesNotExist(); ProductTestHelper::createProductByNameForOwner("My Product 1", $super); //Setup test data owned by the super user. ProductTemplateTestHelper::createProductTemplateByName('My Product Template'); }
public function testFilteredResultsByStageForProductPortlet() { $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); Yii::app()->user->userModel = $super; //Setup test data owned by the super user. $account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super); ProductTestHelper::createProductStagesIfDoesNotExist(); $superProductId = self::getModelIdByModelNameAndName('Product', 'My Product 1'); $product = Product::getById($superProductId); $product->account = $account; $product->stage->value = 'Open'; $this->assertTrue($product->save()); ProductTestHelper::createProductByNameForOwner("My Product 2", $super); $superProductId2 = self::getModelIdByModelNameAndName('Product', 'My Product 2'); $product = Product::getById($superProductId2); $product->account = $account; $product->stage->value = 'Won'; $this->assertTrue($product->save()); $portlet = new Portlet(); $portlet->column = 1; $portlet->position = 1; $portlet->layoutId = 'AccountDetailsAndRelationsView'; $portlet->user = $super; $portlet->viewType = 'ProductsForAccountRelatedList'; $this->assertTrue($portlet->save()); $this->setGetArray(array('id' => $account->id, 'portletParams' => array('relationModuleId' => 'accounts', 'relationModelId' => $account->id), 'ProductsConfigurationForm' => array('filteredByStage' => 'Open'), 'redirectUrl' => Yii::app()->createUrl('accounts/default/details', array('id' => $account->id)), 'portletId' => $portlet->id, 'uniqueLayoutId' => 'AccountDetailsAndRelationsView_' . $portlet->id)); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/modalRefresh'); $this->assertContains('My Product 1', $content); $this->assertNotContains('My Product 2', $content); $this->setGetArray(array('id' => $account->id, 'portletParams' => array('relationModuleId' => 'accounts', 'relationModelId' => $account->id), 'ProductsConfigurationForm' => array('filteredByStage' => 'All'), 'redirectUrl' => Yii::app()->createUrl('accounts/default/details', array('id' => $account->id)), 'portletId' => $portlet->id, 'uniqueLayoutId' => 'AccountDetailsAndRelationsView_' . $portlet->id)); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/modalRefresh'); $this->assertContains('My Product 1', $content); $this->assertContains('My Product 2', $content); $this->setGetArray(array('id' => $account->id, 'portletParams' => array('relationModuleId' => 'accounts', 'relationModelId' => $account->id), 'ProductsConfigurationForm' => array('filteredByStage' => 'Won'), 'redirectUrl' => Yii::app()->createUrl('accounts/default/details', array('id' => $account->id)), 'portletId' => $portlet->id, 'uniqueLayoutId' => 'AccountDetailsAndRelationsView_' . $portlet->id)); $content = $this->runControllerWithNoExceptionsAndGetContent('accounts/defaultPortlet/modalRefresh'); $this->assertNotContains('My Product 1', $content); $this->assertContains('My Product 2', $content); }