本文整理匯總了PHP中Magento\Mtf\Fixture\FixtureFactory類的典型用法代碼示例。如果您正苦於以下問題:PHP FixtureFactory類的具體用法?PHP FixtureFactory怎麽用?PHP FixtureFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了FixtureFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __prepare
/**
* Prepare data.
*
* @param FixtureFactory $fixtureFactory
* @param Customer $customer
* @return array
*/
public function __prepare(FixtureFactory $fixtureFactory, Customer $customer)
{
$product = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => '100_dollar_product']);
$product->persist();
$customer->persist();
return ['product' => $product, 'customer' => $customer];
}
示例2: __construct
/**
* Constructor
*
* @constructor
* @param FixtureFactory $fixtureFactory
* @param array $data
* @param array $params [optional]
*/
public function __construct(FixtureFactory $fixtureFactory, array $data, array $params = [])
{
$this->params = $params;
$this->data = !isset($data['preset']) ? $data : [];
if (isset($data['preset'])) {
$this->data = $this->getPreset($data['preset']);
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) {
if ($product instanceof FixtureInterface) {
$productSelection[$key] = $product;
continue;
}
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;
}
}
}
示例3: __prepare
/**
* Create custom admin user and setup configuration.
*
* @param FixtureFactory $fixtureFactory
* @return array
*/
public function __prepare(FixtureFactory $fixtureFactory)
{
$adminUser = $fixtureFactory->createByCode('user', ['dataSet' => 'custom_admin']);
$adminUser->persist();
$this->objectManager->create('Mage\\Core\\Test\\TestStep\\SetupConfigurationStep', ['configData' => 'max_admin_login_failures'])->run();
return ['adminUser' => $adminUser];
}
示例4: __construct
/**
* @constructor
* @param FixtureFactory $fixtureFactory
* @param string $data
* @param array $params [optional]
*/
public function __construct(FixtureFactory $fixtureFactory, $data, array $params = [])
{
$this->params = $params;
$explodedData = explode('::', $data);
switch (sizeof($explodedData)) {
case 1:
$this->data = $explodedData[0];
break;
case 3:
list($fixture, $dataset, $field) = $explodedData;
$entity = $fixtureFactory->createByCode($fixture, ['dataset' => $dataset]);
if (!$entity->hasData('id')) {
$entity->persist();
}
$this->data = $entity->getData($field);
$this->entity = $entity;
break;
case 4:
list($fixture, $dataset, $source, $field) = $explodedData;
$entity = $fixtureFactory->createByCode($fixture, ['dataset' => $dataset]);
if (!$entity->hasData('id')) {
$entity->persist();
}
$source = $source == 'product' ? $entity->getEntityId()['products'][0] : $entity->getData($source);
$this->data = $source->getData($field);
$this->entity = $entity;
break;
}
}
示例5: __inject
/**
* Injection data
*
* @param CatalogProductIndex $productGrid
* @param CatalogProductEdit $editProductPage
* @param Category $category
* @param FixtureFactory $fixtureFactory
* @return void
*/
public function __inject(CatalogProductIndex $productGrid, CatalogProductEdit $editProductPage, Category $category, FixtureFactory $fixtureFactory)
{
$this->product = $fixtureFactory->createByCode('catalogProductVirtual', ['dataset' => 'default', 'data' => ['category_ids' => ['category' => $category]]]);
$this->product->persist();
$this->productGrid = $productGrid;
$this->editProductPage = $editProductPage;
}
示例6: __construct
/**
* @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'])) {
$productsList = array_map('trim', explode(',', $data['dataset']));
foreach ($productsList as $productData) {
list($fixtureCode, $dataset) = explode('::', $productData);
$this->products[] = $fixtureFactory->createByCode($fixtureCode, ['dataset' => $dataset]);
}
}
if (isset($data['products'])) {
foreach ($data['products'] as $product) {
$this->products[] = $product;
}
}
foreach ($this->products as $product) {
if (!$product->hasData('id')) {
$product->persist();
}
$this->data[] = ['id' => $product->getId(), 'name' => $product->getName(), 'sku' => $product->getSku()];
}
if (isset($data['data'])) {
$this->data = array_replace_recursive($this->data, $data['data']);
}
}
示例7: __construct
/**
* @constructor
* @param FixtureFactory $fixtureFactory
* @param array $params
* @param array $data
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
{
$this->params = $params;
if (!empty($data['category']) && empty($data['dataset']) && $data['category'] instanceof Category) {
/** @var Category $category */
$category = $data['category'];
if (!$category->hasData('id')) {
$category->persist();
}
$this->data[] = $category->getName();
$this->categories[] = $category;
} elseif (isset($data['dataset'])) {
$datasets = explode(',', $data['dataset']);
foreach ($datasets as $dataset) {
if (trim($dataset) == '-') {
$this->data[] = '';
continue;
}
$category = $fixtureFactory->createByCode('category', ['dataset' => $dataset]);
if (!isset($data['new_category']) || $data['new_category'] !== 'yes') {
$category->persist();
}
/** @var Category $category */
$this->data[] = $category->getName();
$this->categories[] = $category;
}
}
}
示例8: __construct
/**
* @constructor
* @param FixtureFactory $fixtureFactory
* @param array $params
* @param array $data
*/
public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
{
$this->params = $params;
if (!empty($data['category']) && empty($data['presets'])) {
/** @var CatalogCategory $category */
$category = $data['category'];
if (!$category->hasData('id')) {
$category->persist();
}
$this->data[] = $category->getName();
$this->categories[] = $category;
} elseif (isset($data['presets'])) {
$presets = explode(',', $data['presets']);
foreach ($presets as $preset) {
$category = $fixtureFactory->createByCode('catalogCategory', ['dataSet' => $preset]);
$category->persist();
/** @var CatalogCategory $category */
$this->data[] = $category->getName();
$this->categories[] = $category;
}
}
if (!empty($this->categories) && count($this->categories) == 1) {
$this->productCategory = $this->categories[0];
}
}
示例9: processAssert
/**
* Check whether the attribute filter is displayed on the frontend in Layered navigation.
*
* @param CatalogCategoryView $catalogCategoryView
* @param InjectableFixture $product
* @param CatalogProductAttribute $attribute
* @param CmsIndex $cmsIndex
* @param FixtureFactory $fixtureFactory
* @return void
*/
public function processAssert(CatalogCategoryView $catalogCategoryView, InjectableFixture $product, CatalogProductAttribute $attribute, CmsIndex $cmsIndex, FixtureFactory $fixtureFactory)
{
$fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'product_with_category_with_anchor', 'data' => ['category_ids' => ['presets' => null, 'category' => $product->getDataFieldConfig('category_ids')['source']->getCategories()[0]]]])->persist();
$cmsIndex->open()->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]);
$label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel();
\PHPUnit_Framework_Assert::assertTrue(in_array($label, $catalogCategoryView->getLayeredNavigationBlock()->getFilters()), 'Attribute is absent in layered navigation on category page.');
}
示例10: __construct
/**
* @param OrderCreateIndex $orderCreateIndex
* @param array $payment
* @param FixtureFactory $fixtureFactory
* @param $creditCardClass
* @param array $creditCard
* @param string $creditCardSave
*/
public function __construct(OrderCreateIndex $orderCreateIndex, array $payment, FixtureFactory $fixtureFactory, $creditCardClass, array $creditCard, $creditCardSave = 'No')
{
$this->orderCreatePage = $orderCreateIndex;
$this->payment = $payment;
$this->creditCard = $fixtureFactory->createByCode($creditCardClass, ['dataset' => $creditCard['dataset']]);
$this->creditCardSave = $creditCardSave;
}
示例11: __construct
/**
* @constructor
* @param FixtureFactory $fixtureFactory
* @param DataInterface $configuration
* @param array $params
* @param array|string $data [optional]
*/
public function __construct(FixtureFactory $fixtureFactory, DataInterface $configuration, array $params, $data = [])
{
$this->params = $params;
$this->configuration = $configuration;
if (!isset($data['dataSet']) && !isset($data['tax_product_class'])) {
$this->data = $data;
return;
}
if (isset($data['dataSet'])) {
$this->taxClass = $fixtureFactory->createByCode('taxClass', ['dataSet' => $data['dataSet']]);
$this->data = $this->taxClass->getClassName();
if (!$this->taxClass->hasData('id')) {
$this->taxClass->persist();
}
}
if (isset($data['tax_product_class']) && $data['tax_product_class'] instanceof FixtureTaxClass) {
$this->taxClass = $data['tax_product_class'];
$this->data = $this->taxClass->getClassName();
}
if ($this->taxClass->hasData('id')) {
$this->taxClassId = $this->taxClass->getId();
} else {
$this->setTaxClassId($this->data);
}
}
示例12: __inject
/**
* Filling objects of the class
*
* @param CatalogProductIndex $catalogProductIndexNewPage
* @param CatalogProductEdit $catalogProductEditPage
* @param FixtureFactory $fixtureFactory
* @return void
*/
public function __inject(CatalogProductIndex $catalogProductIndexNewPage, CatalogProductEdit $catalogProductEditPage, FixtureFactory $fixtureFactory)
{
$this->product = $fixtureFactory->createByCode('downloadableProduct', ['dataset' => 'default']);
$this->product->persist();
$this->catalogProductIndex = $catalogProductIndexNewPage;
$this->catalogProductEdit = $catalogProductEditPage;
}
示例13: __construct
/**
* @constructor
* @param RepositoryFactory $repositoryFactory
* @param FixtureFactory $fixtureFactory
* @param array $params
* @param array $data [optional]
*/
public function __construct(RepositoryFactory $repositoryFactory, FixtureFactory $fixtureFactory, array $params, array $data = [])
{
$this->params = $params;
if (isset($data['dataset']) && isset($this->params['repository'])) {
$datasets = $repositoryFactory->get($this->params['repository'])->get($data['dataset']);
foreach ($datasets as $dataset) {
list($fixtureCode, $dataset) = explode('::', $dataset);
$this->products[] = $fixtureFactory->createByCode($fixtureCode, ['dataset' => $dataset]);
}
}
if (isset($data['products'])) {
foreach ($data['products'] as $product) {
$this->products[] = $product;
}
}
foreach ($this->products as $product) {
if (!$product->hasData('id')) {
$product->persist();
}
$this->data[] = ['entity_id' => $product->getId(), 'name' => $product->getName(), 'sku' => $product->getSku()];
}
if (isset($data['data'])) {
$this->data = array_replace_recursive($this->data, $data['data']);
}
}
示例14: __prepare
/**
* Prepare magento customer for test and delete all tax rules.
*
* @param FixtureFactory $fixtureFactory
* @return array
*/
public function __prepare(FixtureFactory $fixtureFactory)
{
$this->objectManager->create('Mage\\Tax\\Test\\TestStep\\DeleteAllTaxRulesStep')->run();
$magentoCustomer = $fixtureFactory->create('Mage\\Customer\\Test\\Fixture\\Customer', ['dataSet' => 'default']);
$magentoCustomer->persist();
return ['customer' => $magentoCustomer];
}
示例15: __prepare
/**
* Prepare environment for test.
*
* @param FixtureFactory $fixtureFactory
* @return void
*/
public function __prepare(FixtureFactory $fixtureFactory)
{
// Delete existing tax rules.
$this->objectManager->create('Mage\\Tax\\Test\\TestStep\\DeleteAllTaxRulesStep')->run();
// Create US tax rule
$taxRule = $fixtureFactory->createByCode('taxRule', ['dataSet' => 'us_tax_rule']);
$taxRule->persist();
}