Ejemplo n.º 1
0
 /**
  * Constructor
  *
  * @constructor
  * @param FixtureFactory $fixtureFactory
  * @param array $data
  * @param array $params [optional]
  */
 public function __construct(FixtureFactory $fixtureFactory, array $data, array $params = [])
 {
     $this->params = $params;
     if ($data['preset']) {
         $this->currentPreset = $data['preset'];
         $this->data = $this->getPreset($this->currentPreset);
         if (!empty($data['products'])) {
             $this->data['products'] = [];
             $this->data['products'] = explode('|', $data['products']);
             foreach ($this->data['products'] as $key => $products) {
                 $this->data['products'][$key] = explode(',', $products);
             }
         }
     }
     if (!empty($this->data['products'])) {
         $productsSelections = $this->data['products'];
         $this->data['products'] = [];
         foreach ($productsSelections as $index => $products) {
             $productSelection = [];
             foreach ($products as $key => $product) {
                 list($fixture, $dataSet) = explode('::', $product);
                 $productSelection[$key] = $fixtureFactory->createByCode($fixture, ['dataSet' => $dataSet]);
                 $productSelection[$key]->persist();
                 $this->data['bundle_options'][$index]['assigned_products'][$key]['search_data']['name'] = $productSelection[$key]->getName();
             }
             $this->data['products'][] = $productSelection;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * "Selections" source constructor
  *
  * @param FixtureFactory $fixtureFactory
  * @param array $data
  * @param array $params [optional]
  * @throws \Exception
  */
 public function __construct(FixtureFactory $fixtureFactory, array $data, array $params = [])
 {
     $this->params = $params;
     if ($data['preset']) {
         $this->currentPreset = $data['preset'];
         $this->data = $this->getPreset($this->currentPreset);
         if (!empty($data['products'])) {
             $this->data['products'] = [];
             $this->data['products'][] = explode(',', $data['products']);
         }
     }
     if (!empty($this->data['products'])) {
         $productsSelections = $this->data['products'];
         $this->data['products'] = [];
         foreach ($productsSelections as $products) {
             $productSelection = [];
             foreach ($products as $product) {
                 list($fixture, $dataSet) = explode('::', $product);
                 /** @var $productFixture InjectableFixture */
                 $productFixture = $fixtureFactory->createByCode($fixture, ['dataSet' => $dataSet]);
                 if (!$productFixture->hasData('id')) {
                     $productFixture->persist();
                 }
                 $productSelection[] = $productFixture;
             }
             $this->data['products'][] = $productSelection;
         }
         foreach ($this->data['bundle_options'] as $optionKey => &$bundleOption) {
             foreach ($bundleOption['assigned_products'] as $productKey => &$assignedProducts) {
                 $assignedProducts['search_data']['name'] = $this->data['products'][$optionKey][$productKey]->getName();
             }
             unset($bundleOption, $assignedProducts);
         }
     }
 }
 /**
  * Assert that displayed category data on category page equals to passed from fixture
  *
  * @param CatalogCategory $category
  * @param CatalogCategory $initialCategory
  * @param FixtureFactory $fixtureFactory
  * @param CatalogCategoryView $categoryView
  * @param Browser $browser
  * @return void
  */
 public function processAssert(CatalogCategory $category, CatalogCategory $initialCategory, FixtureFactory $fixtureFactory, CatalogCategoryView $categoryView, Browser $browser)
 {
     $product = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'default', 'data' => ['category_ids' => ['category' => $initialCategory]]]);
     $categoryData = array_merge($initialCategory->getData(), $category->getData());
     $product->persist();
     $url = $_ENV['app_frontend_url'] . strtolower($category->getUrlKey()) . '.html';
     $browser->open($url);
     \PHPUnit_Framework_Assert::assertEquals($url, $browser->getUrl(), 'Wrong page URL.' . "\nExpected: " . $url . "\nActual: " . $browser->getUrl());
     if (isset($categoryData['name'])) {
         $title = $categoryView->getTitleBlock()->getTitle();
         \PHPUnit_Framework_Assert::assertEquals($categoryData['name'], $title, 'Wrong page title.' . "\nExpected: " . $categoryData['name'] . "\nActual: " . $title);
     }
     if (isset($categoryData['description'])) {
         $description = $categoryView->getViewBlock()->getDescription();
         \PHPUnit_Framework_Assert::assertEquals($categoryData['description'], $description, 'Wrong category description.' . "\nExpected: " . $categoryData['description'] . "\nActual: " . $description);
     }
     if (isset($categoryData['default_sort_by'])) {
         $sortBy = strtolower($categoryData['default_sort_by']);
         $sortType = $categoryView->getTopToolbar()->getSelectSortType();
         \PHPUnit_Framework_Assert::assertEquals($sortBy, $sortType, 'Wrong sorting type.' . "\nExpected: " . $sortBy . "\nActual: " . $sortType);
     }
     if (isset($categoryData['available_sort_by'])) {
         $availableSortType = array_filter($categoryData['available_sort_by'], function (&$value) {
             return $value !== '-' && ucfirst($value);
         });
         if ($availableSortType) {
             $availableSortType = array_values($availableSortType);
             $availableSortTypeOnPage = $categoryView->getTopToolbar()->getSortType();
             \PHPUnit_Framework_Assert::assertEquals($availableSortType, $availableSortTypeOnPage, 'Wrong available sorting type.' . "\nExpected: " . implode(PHP_EOL, $availableSortType) . "\nActual: " . implode(PHP_EOL, $availableSortTypeOnPage));
         }
     }
 }
 /**
  * Inject page
  *
  * @param UrlrewriteEdit $urlRewriteEdit
  * @param UrlrewriteIndex $urlRewriteIndex
  * @param FixtureFactory $fixtureFactory
  * @return array
  */
 public function __inject(UrlrewriteEdit $urlRewriteEdit, UrlRewriteIndex $urlRewriteIndex, FixtureFactory $fixtureFactory)
 {
     $this->urlRewriteEdit = $urlRewriteEdit;
     $this->urlRewriteIndex = $urlRewriteIndex;
     $category = $fixtureFactory->createByCode('catalogCategory', ['dataSet' => 'default_subcategory']);
     $category->persist();
     return ['category' => $category];
 }
 /**
  * Prepare dataSets and pages
  *
  * @param UrlrewriteIndex $urlRewriteIndex
  * @param UrlrewriteEdit $urlRewriteEdit
  * @param FixtureFactory $fixtureFactory
  * @param CatalogCategory $category
  * @return array
  */
 public function __inject(UrlrewriteIndex $urlRewriteIndex, UrlrewriteEdit $urlRewriteEdit, FixtureFactory $fixtureFactory, CatalogCategory $category)
 {
     $this->urlRewriteIndex = $urlRewriteIndex;
     $this->urlRewriteEdit = $urlRewriteEdit;
     $category->persist();
     $categoryRedirect = $fixtureFactory->createByCode('urlRewrite', ['dataSet' => 'default', 'data' => ['id_path' => ['category/' . $category->getId()]]]);
     $categoryRedirect->persist();
     return ['categoryRedirect' => $categoryRedirect, 'category' => $category];
 }
 /**
  * Assert that deleted attribute can't be mapped to Google Attribute (attribute doesn't appear in Attributes
  * Mapping -> Google Content - Attributes after selecting attribute set)
  *
  * @param FixtureFactory $fixtureFactory
  * @param CatalogAttributeSet $productTemplate
  * @param GoogleShoppingTypesIndex $shoppingTypesIndex
  * @param GoogleShoppingTypesNew $shoppingTypesNew
  * @return void
  */
 public function processAssert(FixtureFactory $fixtureFactory, CatalogAttributeSet $productTemplate, GoogleShoppingTypesIndex $shoppingTypesIndex, GoogleShoppingTypesNew $shoppingTypesNew)
 {
     $shoppingTypesIndex->open();
     $shoppingTypesIndex->getPageActionsBlock()->addNew();
     $shoppingAttributes = $fixtureFactory->createByCode('googleShoppingAttribute', ['dataSet' => 'default', 'data' => ['attribute_set_id' => ['attribute_set' => $productTemplate]]]);
     $shoppingTypesNew->getGoogleShoppingForm()->fill($shoppingAttributes);
     $shoppingTypesNew->getGoogleShoppingForm()->clickAddNewAttribute();
     $attributeCode = $productTemplate->getDataFieldConfig('assigned_attributes')['source']->getAttributes()[0]->getAttributeCode();
     \PHPUnit_Framework_Assert::assertFalse($shoppingTypesNew->getGoogleShoppingForm()->findAttribute($attributeCode), "Attribute " . $attributeCode . " is present in Attribute set mapping");
 }
 /**
  * Assert check whether the attribute is used to create a configurable products
  *
  * @param CatalogProductAttribute $productAttribute
  * @param CatalogProductAttribute $attribute
  * @param CatalogProductIndex $productGrid
  * @param FixtureFactory $fixtureFactory
  * @param CatalogProductNew $newProductPage
  */
 public function processAssert(CatalogProductAttribute $attribute, CatalogProductIndex $productGrid, FixtureFactory $fixtureFactory, CatalogProductNew $newProductPage, CatalogProductAttribute $productAttribute = null)
 {
     $this->attribute = !is_null($productAttribute) ? $productAttribute : $attribute;
     $productGrid->open();
     $productGrid->getGridPageActionBlock()->addProduct('configurable');
     $productConfigurable = $fixtureFactory->createByCode('catalogProductConfigurable', ['dataSet' => 'default', 'data' => ['configurable_attributes_data' => ['preset' => 'one_variation', 'attributes' => [$this->attribute]]]]);
     $productBlockForm = $newProductPage->getProductForm();
     $productBlockForm->fill($productConfigurable);
     \PHPUnit_Framework_Assert::assertTrue($productBlockForm->checkAttributeInSearchAttributeForm($this->attribute), "Product attribute is absent on the product page.");
 }
Ejemplo n.º 8
0
 /**
  * Prepare data
  *
  * @param FixtureFactory $fixtureFactory
  * @return array
  */
 public function __prepare(FixtureFactory $fixtureFactory)
 {
     /** @var CatalogProductSimple $productSymbols */
     $productSymbols = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'abc_dfj_simple_for_advancedsearch']);
     $productSymbols->persist();
     /** @var CatalogProductSimple $productNumbers */
     $productNumbers = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'adc_123_simple_for_advancedsearch']);
     $productNumbers->persist();
     return ['productsSearch' => ['simple_1' => $productSymbols, 'simple_2' => $productNumbers]];
 }
 /**
  * Assert that Compare Products block is presented on CMS pages.
  * Block contains information about compared products
  *
  * @param array $products
  * @param CmsIndex $cmsIndex
  * @param FixtureFactory $fixtureFactory
  * @param Browser $browser
  * @return void
  */
 public function processAssert(array $products, CmsIndex $cmsIndex, FixtureFactory $fixtureFactory, Browser $browser)
 {
     $newCmsPage = $fixtureFactory->createByCode('cmsPage', ['dataSet' => '3_column_template']);
     $newCmsPage->persist();
     $browser->open($_ENV['app_frontend_url'] . $newCmsPage->getIdentifier());
     foreach ($products as &$product) {
         $product = $product->getName();
     }
     \PHPUnit_Framework_Assert::assertEquals($products, $cmsIndex->getCompareProductsBlock()->getProducts(), 'Compare product block contains NOT valid information about compared products.');
 }
Ejemplo n.º 10
0
 /**
  * Create products
  *
  * @return array
  */
 public function run()
 {
     $products = [];
     $productsDataSets = explode(',', $this->products);
     foreach ($productsDataSets as $key => $productDataSet) {
         list($fixtureClass, $dataSet) = explode('::', $productDataSet);
         /** @var FixtureInterface[] $products */
         $products[$key] = $this->fixtureFactory->createByCode(trim($fixtureClass), ['dataSet' => trim($dataSet)]);
         $products[$key]->persist();
     }
     return ['products' => $products];
 }
Ejemplo n.º 11
0
 /**
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (isset($data['dataSet'])) {
         /** @var CatalogAttributeSet $attributeSet */
         $attributeSet = $fixtureFactory->createByCode('catalogAttributeSet', ['dataSet' => $data['dataSet']]);
         $this->prepareData($attributeSet);
     }
     if (isset($data['attribute_set']) && $data['attribute_set'] instanceof CatalogAttributeSet) {
         $this->prepareData($data['attribute_set']);
     }
 }
 /**
  * Assert that created product template:
  * 1. Displays in product template suggest container dropdown
  * 2. Can be used for new created product.
  *
  * @param FixtureFactory $fixtureFactory
  * @param CatalogProductEdit $productEdit
  * @param CatalogProductIndex $productGrid
  * @param CatalogAttributeSet $attributeSet
  * @param CatalogProductNew $newProductPage
  * @param CatalogProductAttribute $productAttributeOriginal
  * @return void
  */
 public function processAssert(FixtureFactory $fixtureFactory, CatalogProductEdit $productEdit, CatalogProductIndex $productGrid, CatalogAttributeSet $attributeSet, CatalogProductNew $newProductPage, CatalogProductAttribute $productAttributeOriginal)
 {
     $productGrid->open();
     $productGrid->getGridPageActionBlock()->addProduct('simple');
     $productBlockForm = $newProductPage->getProductForm();
     /**@var CatalogProductSimple $catalogProductSimple */
     $productSimple = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'default', 'data' => ['attribute_set_id' => ['attribute_set' => $attributeSet]]]);
     $productBlockForm->fill($productSimple);
     \PHPUnit_Framework_Assert::assertTrue($productEdit->getProductForm()->isTabVisible($attributeSet->getGroup()), "Product Group is absent on Product form tabs.");
     $productEdit->getProductForm()->openCustomTab($attributeSet->getGroup());
     \PHPUnit_Framework_Assert::assertTrue($productEdit->getProductForm()->checkAttributeLabel($productAttributeOriginal), "Product Attribute is absent on Product form.");
 }
Ejemplo n.º 13
0
 /**
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param string $data
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, $data)
 {
     $this->params = $params;
     if (preg_match('`%(.*?)%`', $data, $store)) {
         /** @var Store $storeFixture */
         $storeFixture = $fixtureFactory->createByCode('store', ['dataSet' => $store[1]]);
         if (!$storeFixture->hasData('store_id')) {
             $storeFixture->persist();
         }
         $data = str_replace('%' . $store[1] . '%', $storeFixture->getName(), $data);
     }
     $this->data = $data;
 }
Ejemplo n.º 14
0
 /**
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (isset($data['dataSet']) && $data['dataSet'] !== '-') {
         $attributeSet = $fixtureFactory->createByCode('catalogAttributeSet', ['dataSet' => $data['dataSet']]);
     }
     if (isset($data['attribute_set']) && $data['attribute_set'] instanceof CatalogAttributeSet) {
         $attributeSet = $data['attribute_set'];
     }
     /** @var CatalogAttributeSet $attributeSet */
     $this->data = $attributeSet->getAttributeSetName();
     $this->attributeSet = $attributeSet;
 }
Ejemplo n.º 15
0
 /**
  * Constructor
  *
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data [optional]
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (isset($data['dataSet'])) {
         $website = $fixtureFactory->createByCode('website', ['dataSet' => $data['dataSet']]);
         /** @var Website $website */
         if (!$website->getWebsiteId()) {
             $website->persist();
         }
         $this->website = $website;
         $this->data = $website->getName();
     }
 }
Ejemplo n.º 16
0
 /**
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (isset($data['dataSet']) && $data['dataSet'] !== '-') {
         $parentSet = $fixtureFactory->createByCode('catalogAttributeSet', ['dataSet' => $data['dataSet']]);
         if (!$parentSet->hasData('attribute_set_id')) {
             $parentSet->persist();
         }
         /** @var CatalogAttributeSet $parentSet */
         $this->data = $parentSet->getAttributeSetName();
         $this->attributeSet = $parentSet;
     }
 }
Ejemplo n.º 17
0
 /**
  * @constructor
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array|int $data
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, $data = [])
 {
     $this->params = $params;
     if ($data['dataSet']) {
         $this->parentCategory = $fixtureFactory->createByCode('catalogCategory', ['dataSet' => $data['dataSet']]);
         if (!$this->parentCategory->hasData('id')) {
             $this->parentCategory->persist();
         }
         $this->data = $this->parentCategory->getId();
     } else {
         $this->data = $data;
     }
 }
Ejemplo n.º 18
0
 /**
  * @constructor
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data [optional]
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (isset($data['dataSet'])) {
         list($typeFixture, $dataSet) = explode('::', $data['dataSet']);
         $fixture = $fixtureFactory->createByCode($typeFixture, ['dataSet' => $dataSet]);
         if (!$fixture->hasData('id')) {
             $fixture->persist();
         }
         $this->entity = $fixture;
         $this->data = $fixture->getId();
     }
 }
Ejemplo n.º 19
0
 /**
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     $explodeValue = explode('::', $data['value']);
     if (!empty($explodeValue) && count($explodeValue) > 1) {
         /** @var FixtureInterface $fixture */
         $fixture = $fixtureFactory->createByCode($explodeValue[0]);
         $fixture->persist();
         $this->data = $fixture->{$explodeValue}[1]();
     } else {
         $this->data = strval($data['value']);
     }
 }
Ejemplo n.º 20
0
 /**
  * Constructor
  *
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data [optional]
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (isset($data['dataSet'])) {
         $category = $fixtureFactory->createByCode('catalogCategory', ['dataSet' => $data['dataSet']]);
         /** @var CatalogCategory $category */
         if (!$category->getId()) {
             $category->persist();
         }
         $this->category = $category;
         $this->data = $category->getName();
     }
 }
 /**
  * Assert that customer group find on account information page
  *
  * @param FixtureFactory $fixtureFactory
  * @param CustomerGroupInjectable $customerGroup
  * @param CustomerIndexNew $customerIndexNew
  * @param CustomerIndex $customerIndex
  * @return void
  */
 public function processAssert(FixtureFactory $fixtureFactory, CustomerGroupInjectable $customerGroup, CustomerIndexNew $customerIndexNew, CustomerIndex $customerIndex)
 {
     /** @var CustomerInjectable $customer */
     $customer = $fixtureFactory->createByCode('customerInjectable', ['dataSet' => 'defaultBackend', 'data' => ['group_id' => ['customerGroup' => $customerGroup]]]);
     $filter = ['email' => $customer->getEmail()];
     $customerIndexNew->open();
     $customerIndexNew->getCustomerForm()->fillCustomer($customer);
     $customerIndexNew->getPageActionsBlock()->save();
     $customerIndex->getCustomerGridBlock()->searchAndOpen($filter);
     $customerFormData = $customerIndexNew->getCustomerForm()->getData($customer);
     $customerFixtureData = $customer->getData();
     $diff = array_diff($customerFixtureData, $customerFormData);
     \PHPUnit_Framework_Assert::assertTrue(empty($diff), "Customer group {$customerGroup->getCustomerGroupCode()} not in customer form.");
 }
Ejemplo n.º 22
0
 /**
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data)
 {
     $this->params = $params;
     if (isset($data['dataSet']) && $data['dataSet'] !== '-') {
         $dataSet = $data['dataSet'];
         /** @var \Magento\Tax\Test\Fixture\TaxClass $taxClass */
         $taxClass = $fixtureFactory->createByCode('taxClass', ['dataSet' => $dataSet]);
         if (!$taxClass->hasData('id')) {
             $taxClass->persist();
         }
         $this->data = $taxClass->getClassName();
         $this->taxClass = $taxClass;
     }
 }
Ejemplo n.º 23
0
 /**
  * @construct
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (isset($data['dataSet']) && $data['dataSet'] !== '-') {
         $dataSets = explode(',', $data['dataSet']);
         foreach ($dataSets as $dataSet) {
             $adminUser = $fixtureFactory->createByCode('user', ['dataSet' => trim($dataSet)]);
             if (!$adminUser->hasData('user_id')) {
                 $adminUser->persist();
             }
             $this->adminUsers[] = $adminUser;
             $this->data[] = $adminUser->getUsername();
         }
     }
 }
Ejemplo n.º 24
0
 /**
  * @construct
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (isset($data['dataSet']) && $data['dataSet'] !== '-') {
         $this->role = $fixtureFactory->createByCode('adminUserRole', ['dataSet' => $data['dataSet']]);
         if (!$this->role->hasData('role_id')) {
             $this->role->persist();
         }
         $this->data = $this->role->getRoleName();
     }
     if (isset($data['role']) && $data['role'] instanceof AdminUserRole) {
         $this->role = $data['role'];
         $this->data = $data['role']->getRoleName();
     }
 }
Ejemplo n.º 25
0
 /**
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (isset($data['dataSet'])) {
         $dataSets = $data['dataSet'];
         foreach ($dataSets as $dataSet) {
             if ($dataSet !== '-') {
                 /** @var \Magento\Tax\Test\Fixture\TaxRate $taxRate */
                 $taxRate = $fixtureFactory->createByCode('taxRate', ['dataSet' => $dataSet]);
                 $this->fixture[] = $taxRate;
                 $this->data[] = $taxRate->getCode();
             }
         }
     }
 }
Ejemplo n.º 26
0
 /**
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     /** @var \Magento\Tax\Test\Fixture\TaxClass $taxClass */
     if (isset($data['dataSet']) && $data['dataSet'] !== '-') {
         $taxClass = $fixtureFactory->createByCode('taxClass', ['dataSet' => $data['dataSet']]);
         $this->taxClass = $taxClass;
         $this->data = $taxClass->getClassName();
     }
     if (isset($data['tax_product_class']) && $data['tax_product_class'] instanceof \Magento\Tax\Test\Fixture\TaxClass) {
         $taxClass = $data['tax_product_class'];
         $this->taxClass = $taxClass;
         $this->data = $taxClass->getClassName();
     }
 }
Ejemplo n.º 27
0
 /**
  * @constructor
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data [optional]
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     foreach ($data as $rating) {
         if (isset($rating['dataSet'])) {
             /** @var Rating $fixtureRating */
             $fixtureRating = $fixtureFactory->createByCode('rating', ['dataSet' => $rating['dataSet']]);
             if (!$fixtureRating->hasData('id')) {
                 $fixtureRating->persist();
             }
             $this->ratings[] = $fixtureRating;
             $this->data[] = ['title' => $fixtureRating->getRatingCode(), 'rating' => $rating['rating']];
         }
     }
 }
 /**
  * Assert that created product template:
  * 1. Displays in product template suggest container dropdown
  * 2. Can be used for new created product.
  *
  * @param FixtureFactory $fixtureFactory
  * @param CatalogProductEdit $productEdit
  * @param CatalogProductIndex $productGrid
  * @param CatalogAttributeSet $attributeSet
  * @param CatalogProductNew $newProductPage
  * @param CatalogProductAttribute $productAttribute
  * @return void
  */
 public function processAssert(FixtureFactory $fixtureFactory, CatalogProductEdit $productEdit, CatalogProductIndex $productGrid, CatalogAttributeSet $attributeSet, CatalogProductNew $newProductPage, CatalogProductAttribute $productAttribute)
 {
     $productGrid->open();
     $productGrid->getProductBlock()->addProduct('simple');
     $productBlockForm = $newProductPage->getForm();
     /**@var CatalogProductSimple $catalogProductSimple */
     $productSimple = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'default', 'data' => ['attribute_set_id' => ['attribute_set' => $attributeSet]]]);
     $productBlockForm->fillProduct($productSimple);
     $newProductPage->getFormAction()->save();
     $formData = $productEdit->getForm()->getData($productSimple);
     $formAttributeSet = $formData['attribute_set_id'];
     \PHPUnit_Framework_Assert::assertEquals($attributeSet->getAttributeSetName(), $formAttributeSet, 'Attribute Set not found on Product form.' . "\nExpected: " . $attributeSet->getAttributeSetName() . "\nActual: " . $formAttributeSet);
     $productEdit->getForm()->openTab('product-details');
     \PHPUnit_Framework_Assert::assertTrue($productEdit->getForm()->checkAttributeLabel($productAttribute), "Product Attribute is absent on Product form.");
 }
Ejemplo n.º 29
0
 /**
  * @constructor
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data [optional]
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (isset($data['presets']) && $data['presets'] !== '-') {
         $presets = explode(',', $data['presets']);
         foreach ($presets as $preset) {
             /** @var CatalogProductAttribute $attribute */
             $attribute = $fixtureFactory->createByCode('catalogProductAttribute', ['dataSet' => $preset]);
             $attribute->persist();
             $this->data[] = $attribute->getAttributeCode();
             $this->attributes[] = $attribute;
         }
     } else {
         $this->data = $data;
     }
 }
 /**
  * Add this attribute to Default attribute Template. Create product and Assert that created attribute
  * is displayed on product form (Products > Inventory > Catalog)
  *
  * @param FixtureFactory $fixtureFactory
  * @param CatalogProductSetIndex $productSet
  * @param CatalogProductSetEdit $productSetEdit
  * @param CatalogAttributeSet $productTemplate
  * @param CatalogProductIndex $productGrid
  * @param CatalogProductAttribute $productAttributeOriginal
  * @param CatalogProductEdit $productEdit
  * @param CatalogProductAttribute|null $productAttribute
  * @return void
  */
 public function processAssert(FixtureFactory $fixtureFactory, CatalogProductSetIndex $productSet, CatalogProductSetEdit $productSetEdit, CatalogAttributeSet $productTemplate, CatalogProductIndex $productGrid, CatalogProductEdit $productEdit, CatalogProductAttribute $productAttribute, CatalogProductAttribute $productAttributeOriginal = null)
 {
     $filterAttribute = ['set_name' => $productTemplate->getAttributeSetName()];
     $productSet->open();
     $productSet->getGrid()->searchAndOpen($filterAttribute);
     $attributeData = $productAttributeOriginal !== null ? array_merge($productAttribute->getData(), $productAttributeOriginal->getData()) : $productAttribute->getData();
     $productSetEdit->getAttributeSetEditBlock()->moveAttribute($attributeData, 'Product Details');
     $productSetEdit->getPageActions()->save();
     $product = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'product_with_category', 'data' => ['attribute_set_id' => ['attribute_set' => $productTemplate]]]);
     $product->persist();
     $filterProduct = ['sku' => $product->getSku()];
     $productGrid->open();
     $productGrid->getProductGrid()->searchAndOpen($filterProduct);
     $catalogProductAttribute = $productAttributeOriginal !== null ? array_merge($productAttributeOriginal->getData(), $productAttribute->getData()) : $productAttribute->getData();
     \PHPUnit_Framework_Assert::assertTrue($productEdit->getProductForm()->checkAttributeLabel($catalogProductAttribute), "Product Attribute is absent on Product form.");
 }