Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertCategoryOnCustomWebsite.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
11 use Magento\Mtf\Client\BrowserInterface;
12 use Magento\Mtf\Constraint\AbstractConstraint;
13 use Magento\Mtf\Fixture\FixtureFactory;
14 
18 class AssertCategoryOnCustomWebsite extends AbstractConstraint
19 {
29  public function processAssert(
30  FixtureFactory $fixtureFactory,
31  BrowserInterface $browser,
32  CatalogCategoryView $categoryView,
33  Category $category
34  ) {
35  $storeGroup = $fixtureFactory->createByCode(
36  'storeGroup',
37  [
38  'dataset' => 'custom_new_group',
39  'data' => [
40  'root_category_id' => [
41  'category' => $category->getDataFieldConfig('parent_id')['source']->getParentCategory()
42  ]
43  ]
44  ]
45  );
46  $storeGroup->persist();
47  $store = $fixtureFactory->createByCode(
48  'store',
49  [
50  'dataset' => 'custom_store',
51  'data' => [
52  'group_id' => [
53  'storeGroup' => $storeGroup
54  ]
55  ]
56  ]
57  );
58  $store->persist();
59 
60  $websiteCode = $storeGroup->getDataFieldConfig('website_id')['source']->getWebsite()->getData('code');
61  $browser->open($_ENV['app_frontend_url'] . 'websites/' . $websiteCode . '/' . $category->getName() . '.html');
62  \PHPUnit\Framework\Assert::assertEquals(
63  $category->getName(),
64  $categoryView->getTitleBlock()->getTitle(),
65  'Wrong category name is displayed on custom website store.'
66  );
67  }
68 
74  public function toString()
75  {
76  return 'Category name is correct on custom website store.';
77  }
78 }
processAssert(FixtureFactory $fixtureFactory, BrowserInterface $browser, CatalogCategoryView $categoryView, Category $category)
if(!isset($_GET['website_code'])) $websiteCode
Definition: website.php:11