/**
  * Delete category.
  *
  * @param CatalogCategory $category
  * @return void
  */
 public function test(CatalogCategory $category)
 {
     // Preconditions:
     $category->persist();
     // Steps:
     $this->catalogCategoryIndex->open();
     $this->catalogCategoryIndex->getTreeCategories()->selectCategory($category);
     $this->catalogCategoryIndex->getFormPageActions()->deleteAndAcceptAlert();
 }
 /**
  * Create category.
  *
  * @param CatalogCategory $category
  * @param string $addCategory
  * @return void
  */
 public function test(CatalogCategory $category, $addCategory)
 {
     // Steps
     $this->catalogCategoryIndex->open();
     $this->catalogCategoryIndex->getTreeCategories()->selectCategory($category, false);
     $this->catalogCategoryIndex->getTreeCategories()->{$addCategory}();
     $this->catalogCategoryIndex->getCategoryForm()->fill($category);
     $this->catalogCategoryIndex->getFormPageActions()->save();
 }
 /**
  * Assert that displayed category data on edit page(backend) equals passed from fixture.
  *
  * @param CatalogCategory $category
  * @param CatalogCategoryIndex $catalogCategoryIndex
  * @return void
  */
 public function processAssert(CatalogCategory $category, CatalogCategoryIndex $catalogCategoryIndex)
 {
     $data = $category->getData();
     $catalogCategoryIndex->open();
     $catalogCategoryIndex->getTreeCategories()->selectCategory($category);
     $dataForm = $catalogCategoryIndex->getCategoryForm()->getDataCategory($category);
     $error = $this->verifyData($data, $dataForm);
     \PHPUnit_Framework_Assert::assertEmpty($error, $error);
 }
 /**
  * Update category.
  *
  * @param CatalogCategory $category
  * @param CatalogCategory $initialCategory
  * @param string $unassignedProductsKeys [optional]
  * @return array
  */
 public function test(CatalogCategory $category, CatalogCategory $initialCategory, $unassignedProductsKeys = '')
 {
     $this->unassignedProductsKeys = $unassignedProductsKeys;
     $initialCategory->persist();
     $this->catalogCategoryIndex->open();
     $this->catalogCategoryIndex->getTreeCategories()->selectCategory($initialCategory);
     $category = $this->updateCategoryFixture($initialCategory, $category);
     $this->catalogCategoryIndex->getCategoryForm()->fill($category);
     $this->catalogCategoryIndex->getFormPageActions()->save();
     return ['category' => $category, 'unassignedProducts' => $this->unassignedProducts];
 }
 /**
  * Assert that user have custom role.
  *
  * @param User $user
  * @param AdminAuthLogin $adminAuth
  * @param Dashboard $dashboard
  * @param CatalogCategoryIndex $categoryIndex
  * @param User $customAdmin [optional]
  * @return void
  */
 public function processAssert(User $user, AdminAuthLogin $adminAuth, Dashboard $dashboard, CatalogCategoryIndex $categoryIndex, User $customAdmin = null)
 {
     $adminUser = $customAdmin === null ? $user : $customAdmin;
     $adminPanelHeader = $dashboard->getAdminPanelHeader();
     if ($adminPanelHeader->isVisible()) {
         $adminPanelHeader->logOut();
     }
     $adminAuth->getLoginBlock()->loginToAdminPanel($adminUser->getData());
     $role = $user->getDataFieldConfig('role_id')['source']->getRole();
     $menuItems = $this->getMenuItems($role);
     foreach ($menuItems as $item) {
         \PHPUnit_Framework_Assert::assertTrue($adminPanelHeader->checkMenu(ucfirst($item)), "Menu {$item} is absent on top menu.");
     }
     // Check access denied message on category page.
     $categoryIndex->open();
     \PHPUnit_Framework_Assert::assertTrue($categoryIndex->getContentBlock()->checkAccessDeniedMessage());
 }
 /**
  * Assert that category is not displayed in backend catalog category tree.
  *
  * @param CatalogCategoryIndex $catalogCategoryIndex
  * @param CatalogCategory $category
  * @return void
  */
 public function processAssert(CatalogCategoryIndex $catalogCategoryIndex, CatalogCategory $category)
 {
     $catalogCategoryIndex->open();
     \PHPUnit_Framework_Assert::assertFalse($catalogCategoryIndex->getTreeCategories()->isCategoryVisible($category), 'Category is displayed in backend catalog category tree.');
 }