public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     ProductTestHelper::createProductByNameForOwner('First Product', User::getByUsername('super'));
     sleep(3);
     ProductTestHelper::createProductByNameForOwner('Second Product', User::getByUsername('super'));
 }
 /**
  * Walkthrough test for synchronous download
  */
 public function testDownloadDefaultControllerActions()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $products = array();
     for ($i = 0; $i < 2; $i++) {
         $products[] = ProductTestHelper::createProductByNameForOwner('superProduct' . $i, $super);
     }
     // Check if access is denied if user doesn't have access privileges at all to export actions
     Yii::app()->user->userModel = User::getByUsername('nobody');
     $nobody = $this->logoutCurrentUserLoginNewUserAndGetByUsername('nobody');
     $this->runControllerShouldResultInAccessFailureAndGetContent('products/default/list');
     $this->setGetArray(array('Product_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '', 'selectedIds' => ''));
     $this->runControllerShouldResultInAccessFailureAndGetContent('products/default/export');
     // Check if user have access to module action, but not to export action
     // Now test peon with elevated rights to accounts
     $nobody->setRight('ProductsModule', ProductsModule::RIGHT_ACCESS_PRODUCTS);
     $nobody->setRight('ProductsModule', ProductsModule::RIGHT_CREATE_PRODUCTS);
     $nobody->setRight('ProductsModule', ProductsModule::RIGHT_DELETE_PRODUCTS);
     $nobody->setRight('ExportModule', ExportModule::RIGHT_ACCESS_EXPORT);
     $this->assertTrue($nobody->save());
     // Check if access is denied if user doesn't have access privileges at all to export actions
     $nobody = $this->logoutCurrentUserLoginNewUserAndGetByUsername('nobody');
     Yii::app()->user->userModel = User::getByUsername('nobody');
     $this->runControllerWithNoExceptionsAndGetContent('products/default/list');
     $this->setGetArray(array('Product_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '', 'selectedIds' => ''));
     $response = $this->runControllerWithRedirectExceptionAndGetUrl('products/default/export');
     $this->assertTrue(strstr($response, 'products/default/index') !== false);
     $this->setGetArray(array('ProductsSearchForm' => array('anyMixedAttributesScope' => array(0 => 'All'), 'anyMixedAttributes' => '', 'name' => 'superProduct'), 'multiselect_ProductsSearchForm_anyMixedAttributesScope' => 'All', 'Product_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '1', 'selectedIds' => ''));
     //TODO Need to ask jason
     $response = $this->runControllerWithRedirectExceptionAndGetUrl('products/default/export');
     $this->assertTrue(strstr($response, 'products/default/index') !== false);
     $this->setGetArray(array('ProductsSearchForm' => array('anyMixedAttributesScope' => array(0 => 'All'), 'anyMixedAttributes' => '', 'name' => 'superProduct'), 'multiselect_ProductsSearchForm_anyMixedAttributesScope' => 'All', 'Product_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '', 'selectedIds' => "{$products[0]->id}, {$products[1]->id}"));
     $response = $this->runControllerWithRedirectExceptionAndGetUrl('products/default/export');
     $this->assertTrue(strstr($response, 'products/default/index') !== false);
     $this->assertContains('There is no data to export.', Yii::app()->user->getFlash('notification'));
     //give nobody access to read and write
     Yii::app()->user->userModel = $super;
     foreach ($products as $product) {
         $product->addPermissions($nobody, Permission::READ_WRITE_CHANGE_PERMISSIONS);
         ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($product, $nobody);
         $this->assertTrue($product->save());
     }
     //Now the nobody user should be able to access the edit view and still the details view.
     Yii::app()->user->userModel = $nobody;
     $this->setGetArray(array('ProductsSearchForm' => array('anyMixedAttributesScope' => array(0 => 'All'), 'anyMixedAttributes' => '', 'name' => 'superProduct'), 'multiselect_ProductsSearchForm_anyMixedAttributesScope' => 'All', 'Product_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '1', 'selectedIds' => ''));
     //TODO Need to ask jason
     $response = $this->runControllerWithExitExceptionAndGetContent('products/default/export');
     $this->assertEquals('Testing download.', $response);
     $this->setGetArray(array('ProductsSearchForm' => array('anyMixedAttributesScope' => array(0 => 'All'), 'anyMixedAttributes' => '', 'name' => 'superProduct'), 'multiselect_ProductsSearchForm_anyMixedAttributesScope' => 'All', 'Product_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '', 'selectedIds' => "{$products[0]->id}, {$products[1]->id}"));
     $response = $this->runControllerWithExitExceptionAndGetContent('products/default/export');
     $this->assertEquals('Testing download.', $response);
     // No mathces
     $this->setGetArray(array('ProductsSearchForm' => array('anyMixedAttributesScope' => array(0 => 'All'), 'anyMixedAttributes' => '', 'name' => 'missingName'), 'multiselect_ProductsSearchForm_anyMixedAttributesScope' => 'All', 'Product_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '1', 'selectedIds' => ''));
     $response = $this->runControllerWithRedirectExceptionAndGetUrl('products/default/export');
     $this->assertTrue(strstr($response, 'products/default/index') !== false);
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     ProductTestHelper::createProductByNameForOwner('My First Prod', Yii::app()->user->userModel);
     ProductTestHelper::createProductByNameForOwner('My Second Prod', Yii::app()->user->userModel);
     CalendarTestHelper::createSavedCalendarByName("My Cal 1", '#315AB0');
     CalendarTestHelper::createSavedCalendarByName("My Cal 2", '#66367b');
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     Currency::makeBaseCurrency();
     //Create a Product for testing.
     ProductTestHelper::createProductByNameForOwner('superProduct', $super);
     //Create a account for testing.
     $account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     //Setup test data owned by the super user.
     $account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
     $contact = ContactTestHelper::createContactWithAccountByNameForOwner('superContact', $super, $account);
     ProductTestHelper::createProductByNameForOwner("My Product 1", $super);
     //Setup test data owned by the super user.
     ProductTemplateTestHelper::createProductTemplateByName('My Product Template');
 }
Example #6
0
 public function testResolveProductHasManyProductCategoriesFromPost()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $category1 = ProductCategoryTestHelper::createProductCategoryByName('Test Product Category');
     $category2 = ProductCategoryTestHelper::createProductCategoryByName('Test Product Category2');
     $product = ProductTestHelper::createProductByNameForOwner('I am testing products', $super);
     $postData = array('categoryIds' => $category1->id . ',' . $category2->id);
     // Not Coding Standard
     $id = $product->id;
     $product->forget();
     unset($product);
     $product = Product::getById($id);
     $categories = ProductCategoriesUtil::resolveProductHasManyProductCategoriesFromPost($product, $postData);
     $this->assertEquals(count($categories), 2);
     $this->assertEquals($categories[$category1->id]->id, $category1->id);
 }
 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);
 }
 /**
  * Walkthrough test for synchronous download
  */
 public function testAsynchronousDownloadDefaultControllerActions()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $notificationsBeforeCount = Notification::getCount();
     $notificationMessagesBeforeCount = NotificationMessage::getCount();
     $products = Product::getAll();
     if (count($products)) {
         foreach ($products as $product) {
             $product->delete();
         }
     }
     $products = array();
     for ($i = 0; $i <= ExportModule::$asynchronousThreshold + 1; $i++) {
         $products[] = ProductTestHelper::createProductByNameForOwner('superProduct' . $i, $super);
     }
     $this->setGetArray(array('Product_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '1', 'selectedIds' => ''));
     $this->runControllerWithRedirectExceptionAndGetUrl('products/default/export');
     // Start background job
     $job = new ExportJob();
     $this->assertTrue($job->run());
     $exportItems = ExportItem::getAll();
     $this->assertEquals(1, count($exportItems));
     $fileModel = $exportItems[0]->exportFileModel;
     $this->assertEquals(1, $exportItems[0]->isCompleted);
     $this->assertEquals('csv', $exportItems[0]->exportFileType);
     $this->assertEquals('products', $exportItems[0]->exportFileName);
     $this->assertTrue($fileModel instanceof ExportFileModel);
     $this->assertEquals($notificationsBeforeCount + 1, Notification::getCount());
     $this->assertEquals($notificationMessagesBeforeCount + 1, NotificationMessage::getCount());
     // Check export job, when many ids are selected.
     // This will probably never happen, but we need test for this case too.
     $notificationsBeforeCount = Notification::getCount();
     $notificationMessagesBeforeCount = NotificationMessage::getCount();
     // Now test case when multiple ids are selected
     $exportItems = ExportItem::getAll();
     if (count($exportItems)) {
         foreach ($exportItems as $exportItem) {
             $exportItem->delete();
         }
     }
     $selectedIds = "";
     foreach ($products as $product) {
         $selectedIds .= $product->id . ",";
         // Not Coding Standard
     }
     $this->setGetArray(array('ProductsSearchForm' => array('anyMixedAttributesScope' => array(0 => 'All'), 'anyMixedAttributes' => '', 'quantity' => ''), 'multiselect_ProductsSearchForm_anyMixedAttributesScope' => 'All', 'Product_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '', 'selectedIds' => "{$selectedIds}"));
     $this->runControllerWithRedirectExceptionAndGetUrl('products/default/export');
     // Start background job
     $job = new ExportJob();
     $this->assertTrue($job->run());
     $exportItems = ExportItem::getAll();
     $this->assertEquals(1, count($exportItems));
     $fileModel = $exportItems[0]->exportFileModel;
     $this->assertEquals(1, $exportItems[0]->isCompleted);
     $this->assertEquals('csv', $exportItems[0]->exportFileType);
     $this->assertEquals('products', $exportItems[0]->exportFileName);
     $this->assertTrue($fileModel instanceof ExportFileModel);
     $this->assertEquals($notificationsBeforeCount + 1, Notification::getCount());
     $this->assertEquals($notificationMessagesBeforeCount + 1, NotificationMessage::getCount());
 }
 public function testCloningWithAnotherProduct()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     Yii::app()->user->userModel = $super;
     $product = ProductTestHelper::createProductByNameForOwner("My Product 1", $super);
     $id = $product->id;
     $this->setGetArray(array('id' => $id));
     $content = $this->runControllerWithNoExceptionsAndGetContent('products/default/copy');
     $this->assertTrue(strpos($content, 'My Product 1') > 0);
     $products = Product::getAll();
     $this->assertEquals(1, count($products));
 }
 public function testUpdateRelatedCatalogItemOnAProductBySellPriceCriteria()
 {
     $super = User::getByUsername('super');
     $contactStates = ContactState::getAll();
     //Create workflow
     $workflow = new Workflow();
     $workflow->setDescription('aDescription');
     $workflow->setIsActive(true);
     $workflow->setOrder(1);
     $workflow->setModuleClassName('ProductsModule');
     $workflow->setName('myFirstProductWorkflow');
     $workflow->setTriggerOn(Workflow::TRIGGER_ON_NEW_AND_EXISTING);
     $workflow->setType(Workflow::TYPE_ON_SAVE);
     $workflow->setTriggersStructure('1');
     //Add Trigger
     $trigger = new TriggerForWorkflowForm('ProductsModule', 'Product', Workflow::TYPE_ON_SAVE);
     $trigger->attributeIndexOrDerivedType = 'sellPrice';
     $trigger->value = 600;
     $trigger->operator = 'greaterThanOrEqualTo';
     $workflow->addTrigger($trigger);
     //Add action
     $currencies = Currency::getAll();
     $action = new ActionForWorkflowForm('Product', Workflow::TYPE_ON_SAVE);
     $action->type = ActionForWorkflowForm::TYPE_UPDATE_RELATED;
     $action->relation = 'productTemplate';
     $attributes = array('description' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'Set Price'), 'priceFrequency' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 2), 'listPrice' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 800, 'currencyId' => $currencies[0]->id), 'cost' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 700, 'currencyId' => $currencies[0]->id));
     $action->setAttributes(array(ActionForWorkflowForm::ACTION_ATTRIBUTES => $attributes));
     $workflow->addAction($action);
     //Create the saved Workflow
     $savedWorkflow = new SavedWorkflow();
     SavedWorkflowToWorkflowAdapter::resolveWorkflowToSavedWorkflow($workflow, $savedWorkflow);
     $saved = $savedWorkflow->save();
     $this->assertTrue($saved);
     $productTemplate = ProductTemplateTestHelper::createProductTemplateByName('superProductTemplate');
     $productTemplates = ProductTemplate::getByName('superProductTemplate');
     $product = ProductTestHelper::createProductByNameForOwner('Test Product', $super);
     $this->assertTrue($product->id > 0);
     $product->productTemplate = $productTemplates[0];
     //Change product sell price
     $product->sellPrice->value = 650;
     $this->assertTrue(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $product));
     $saved = $product->save();
     $this->assertTrue($saved);
     $productId = $product->id;
     $product->forget();
     $product = Product::getById($productId);
     $this->assertEquals('Set Price', $product->productTemplate->description);
     $this->assertEquals(2, $product->productTemplate->priceFrequency);
     $this->assertEquals(700, $product->productTemplate->cost->value);
     $this->assertEquals(800, $product->productTemplate->listPrice->value);
 }
 public function testPriceValidation()
 {
     $user = UserTestHelper::createBasicUser('Steven3');
     $product = ProductTestHelper::createProductByNameForOwner('Product 2', $user);
     $productTemplate = ProductTemplateTestHelper::createProductTemplateByVariables($product, ProductTemplate::PRICE_FREQUENCY_ONE_TIME, ProductTemplate::TYPE_PRODUCT, ProductTemplate::STATUS_ACTIVE, SellPriceFormula::TYPE_EDITABLE);
     $productTemplate->cost->value = -200;
     $this->assertFalse($productTemplate->save());
     $productTemplate->sellPrice->value = -200;
     $this->assertFalse($productTemplate->save());
     $productTemplate->listPrice->value = -200;
     $this->assertFalse($productTemplate->save());
     $productTemplate->listPrice->value = 100;
     $productTemplate->sellPrice->value = 100;
     $productTemplate->cost->value = 100;
     $this->assertTrue($productTemplate->save());
 }
 protected function addProduct($relatedFieldName)
 {
     $primaryModel = $this->getPrimaryModel();
     $this->assertEquals(0, count($primaryModel->products));
     $product = ProductTestHelper::createProductByNameForOwner($this->modelClass . ' Product', Yii::app()->user->userModel);
     $product->{$relatedFieldName} = $this->selectedModels[1];
     $product->save();
 }
 /**
  * @deletes selected products.
  */
 public function testRegularMassDeleteActionsForSelectedIds()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $confused = User::getByUsername('confused');
     $nobody = User::getByUsername('nobody');
     $this->assertEquals(Right::DENY, $confused->getEffectiveRight('ZurmoModule', ZurmoModule::RIGHT_BULK_DELETE));
     $confused->setRight('ZurmoModule', ZurmoModule::RIGHT_BULK_DELETE);
     //Load MassDelete view
     $products = Product::getAll();
     $this->assertEquals(9, count($products));
     $product1 = ProductTestHelper::createProductByNameForOwner('productDelete1', $confused);
     $product2 = ProductTestHelper::createProductByNameForOwner('productDelete2', $confused);
     $product3 = ProductTestHelper::createProductByNameForOwner('productDelete3', $nobody);
     $product4 = ProductTestHelper::createProductByNameForOwner('productDelete4', $confused);
     $product5 = ProductTestHelper::createProductByNameForOwner('productDelete5', $confused);
     $product6 = ProductTestHelper::createProductByNameForOwner('productDelete6', $nobody);
     $selectedIds = $product1->id . ',' . $product2->id . ',' . $product3->id;
     // Not Coding Standard
     $this->setGetArray(array('selectedIds' => $selectedIds, 'selectAll' => ''));
     // Not Coding Standard
     $this->resetPostArray();
     $content = $this->runControllerWithNoExceptionsAndGetContent('products/default/massDelete');
     $this->assertFalse(strpos($content, '<strong>3</strong>&#160;Products selected for removal') === false);
     $pageSize = Yii::app()->pagination->getForCurrentUserByType('massDeleteProgressPageSize');
     $this->assertEquals(5, $pageSize);
     //calculating products after adding 6 new records
     $products = Product::getAll();
     $this->assertEquals(15, count($products));
     //Deleting 6 opportunities for pagination scenario
     //Run Mass Delete using progress save for page1
     $selectedIds = $product1->id . ',' . $product2->id . ',' . $product3->id . ',' . $product4->id . ',' . $product5->id . ',' . $product6->id;
     // Not Coding Standard
     $this->setGetArray(array('selectedIds' => $selectedIds, 'selectAll' => '', 'Product_page' => 1));
     $this->setPostArray(array('selectedRecordCount' => 6));
     $content = $this->runControllerWithExitExceptionAndGetContent('products/default/massDelete');
     $products = Product::getAll();
     $this->assertEquals(10, count($products));
     //Run Mass Delete using progress save for page2
     $selectedIds = $product1->id . ',' . $product2->id . ',' . $product3->id . ',' . $product4->id . ',' . $product5->id . ',' . $product6->id;
     // Not Coding Standard
     $this->setGetArray(array('selectedIds' => $selectedIds, 'selectAll' => '', 'Product_page' => 2));
     $this->setPostArray(array('selectedRecordCount' => 6));
     $content = $this->runControllerWithNoExceptionsAndGetContent('products/default/massDeleteProgress');
     $products = Product::getAll();
     $this->assertEquals(9, count($products));
 }
 /**
  * @covers CalendarItemsDataProviderFactory::getDataProviderByDateRangeType
  * @covers CalendarItemsDataProvider::fetchData
  * @covers CalendarRowsAndColumnsReportDataProvider::makeSelectQueryAdapter
  * @covers CalendarRowsAndColumnsReportDataProvider::resolveSqlQueryAdapterForCount
  * @covers CalendarRowsAndColumnsReportDataProvider::getData
  */
 public function testGetDataProviderByDateRangeType()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $product = ProductTestHelper::createProductByNameForOwner('Test Product', Yii::app()->user->userModel);
     $savedCalendar = CalendarTestHelper::createSavedCalendarByName('Test Cal', '#315AB0');
     $currentDateTime = new DateTime('NOW');
     $currentDateTime->add(new DateInterval('P1D'));
     $savedCalendarSubscriptions = SavedCalendarSubscriptions::makeByUser(Yii::app()->user->userModel, (string) $savedCalendar->id);
     $dp = CalendarItemsDataProviderFactory::getDataProviderByDateRangeType($savedCalendarSubscriptions, '2014-01-01', $currentDateTime->format('Y-m-d'), SavedCalendar::DATERANGE_TYPE_MONTH);
     $this->assertInstanceOf('CalendarItemsDataProvider', $dp);
     $this->assertEquals('2014-01-01', $dp->getStartDate());
     $this->assertEquals($currentDateTime->format('Y-m-d'), $dp->getEndDate());
     $this->assertEquals(SavedCalendar::DATERANGE_TYPE_MONTH, $dp->getDateRangeType());
     $savedCalendarsData = $dp->getSavedCalendarSubscriptions()->getMySavedCalendarsAndSelected();
     $keys = array_keys($savedCalendarsData);
     $this->assertEquals($savedCalendar->id, $keys[0]);
     $items = CalendarUtil::getFullCalendarItems($dp);
     $this->assertCount(1, $items);
     $this->assertEquals($product->id, $items[0]['modelId']);
 }