From b985a7e57df1162bf9d60f9ee7ddfe36cf911cdc Mon Sep 17 00:00:00 2001 From: Vitalii Zabaznov Date: Tue, 12 Jan 2016 15:06:56 +0200 Subject: [PATCH 01/12] MAGETWO-46886: Datepickers on email reminder page save date in store timezone - fix logic and tests --- .../Framework/Stdlib/DateTime/Timezone.php | 28 +++++++++++++++++++ .../Stdlib/DateTime/TimezoneInterface.php | 7 +++++ 2 files changed, 35 insertions(+) diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php index ba1bc695a6f32..2cc8e993c2d73 100644 --- a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php +++ b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php @@ -5,6 +5,8 @@ */ namespace Magento\Framework\Stdlib\DateTime; +use \Magento\Framework\Exception\LocalizedException; + /** * Timezone library */ @@ -275,4 +277,30 @@ public function formatDateTime( ); return $formatter->format($date); } + + /** + * Convert date from config timezone to Utc. + * If pass \DateTime object as argument be sure that timezone is the same with config timezone + * + * @param string|\DateTimeInterface $date + * @param string $format + * @throws LocalizedException + * @return string + */ + public function convertConfigTimeToUtc($date, $format = 'Y-m-d H:i:s') + { + if (!($date instanceof \DateTime)) { + $date = new \DateTime($date, new \DateTimeZone($this->getConfigTimezone())); + } else { + if ($date->getTimezone()->getName() !== $this->getConfigTimezone()) { + throw new LocalizedException( + __('DateTime object timezone must be the same as config - %1', $this->getConfigTimezone()) + ); + } + } + + $date->setTimezone(new \DateTimeZone('UTC')); + + return $date->format($format); + } } diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/TimezoneInterface.php b/lib/internal/Magento/Framework/Stdlib/DateTime/TimezoneInterface.php index 0ec49eedb748b..d08ac3fa282cb 100644 --- a/lib/internal/Magento/Framework/Stdlib/DateTime/TimezoneInterface.php +++ b/lib/internal/Magento/Framework/Stdlib/DateTime/TimezoneInterface.php @@ -134,4 +134,11 @@ public function formatDateTime( $timezone = null, $pattern = null ); + + /** + * @param string|\DateTimeInterface $date + * @param string $format + * @return string + */ + public function convertConfigTimeToUtc($date, $format = 'Y-m-d H:i:s'); } From 0c82bbbb945345faf67791be505dbe2ae4089f12 Mon Sep 17 00:00:00 2001 From: Kateryna Muntianu Date: Fri, 15 Jan 2016 14:59:35 +0200 Subject: [PATCH 02/12] MAGETWO-47760: Extend functional test coverage for Categories - Updated Category/ParentId fixture so that it's possible to forward parent category hierarchy - Extended verification of category settings on Storefront - Fixed and optimized test data. Extended coverage - Improved performance by removing unnecessary products and category creation - Fixed creating enabled cms block - Removed AssertCategoryIsNotIncludeInMenu as it's not used and covered by AssertCategoryPage --- .../Magento/Backend/Test/Block/Template.php | 8 + .../Adminhtml/Category/Edit/CategoryForm.xml | 41 +++- .../Test/Block/Category/MetaInformation.php | 33 +++ .../Test/Constraint/AssertCategoryForm.php | 4 + .../Constraint/AssertCategoryIsNotActive.php | 48 +++- .../AssertCategoryIsNotIncludeInMenu.php | 68 ------ .../Test/Constraint/AssertCategoryPage.php | 221 +++++++++++------- .../Magento/Catalog/Test/Fixture/Category.xml | 13 +- .../Test/Fixture/Category/ParentId.php | 3 +- .../Catalog/Test/Handler/Category/Curl.php | 1 + .../Catalog/Test/Handler/Category/Webapi.php | 2 + .../Page/Category/CatalogCategoryView.xml | 2 + .../Category/CreateCategoryEntityTest.xml | 108 ++++----- .../Category/DeleteCategoryEntityTest.xml | 6 +- .../Category/UpdateCategoryEntityTest.php | 32 ++- .../Category/UpdateCategoryEntityTest.xml | 32 ++- .../Magento/Cms/Test/Repository/CmsBlock.xml | 2 +- .../Ui/Test/Block/Adminhtml/FormSections.php | 4 +- 18 files changed, 381 insertions(+), 247 deletions(-) create mode 100644 dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Category/MetaInformation.php delete mode 100644 dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotIncludeInMenu.php diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Template.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Template.php index d50cdd9bbef3a..1c79bd728bfd1 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Template.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Template.php @@ -14,6 +14,13 @@ */ class Template extends Block { + /** + * Magento new loader. + * + * @var string + */ + protected $spinner = '[data-role="spinner"]'; + /** * Magento loader. * @@ -35,6 +42,7 @@ class Template extends Block */ public function waitLoader() { + $this->waitForElementNotVisible($this->spinner); $this->waitForElementNotVisible($this->loader); $this->waitForElementNotVisible($this->loaderOld); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.xml index 496f9e1a36b18..bd592ab930752 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.xml @@ -101,9 +101,46 @@ //div[contains(@class,'admin__collapsible-block-wrapper')][descendant::div[@id='catalog_category_products']] xpath - + + \Magento\Ui\Test\Block\Adminhtml\Section + //div[contains(@class,'admin__collapsible-block-wrapper')][descendant::select[@name='page_layout']] + xpath + + + checkbox + input[name='custom_use_parent_settings'] + + + select + select[name='page_layout'] + + + textarea + textarea[name='custom_layout_update'] + + + checkbox + input[name='custom_apply_to_products'] + + + + \Magento\Ui\Test\Block\Adminhtml\Section //div[contains(@class,'admin__collapsible-block-wrapper')][descendant::input[@name='custom_design_to']] xpath - + + + text + input[name='custom_design_from'] + + + text + input[name='custom_design_to'] + + + select + select[name='custom_design'] + + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Category/MetaInformation.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Category/MetaInformation.php new file mode 100644 index 0000000000000..9ef54bda7e6a9 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Category/MetaInformation.php @@ -0,0 +1,33 @@ +browser->getHtmlSource()); + return (string)$pageContent->head->title; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryForm.php index 2f17bd3a740a1..fe498dcb9c021 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryForm.php @@ -67,6 +67,10 @@ protected function prepareFixtureData(array $data) $data['url_key'] = strtolower($data['url_key']); } + if (isset($data['id'])) { + unset($data['id']); + } + return array_diff_key($data, array_flip($this->skippedFixtureFields)); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotActive.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotActive.php index ca07fb741585d..1e9a6246d9895 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotActive.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotActive.php @@ -6,42 +6,68 @@ namespace Magento\Catalog\Test\Constraint; +use Magento\Mtf\Constraint\AbstractConstraint; use Magento\Catalog\Test\Fixture\Category; -use Magento\Cms\Test\Page\CmsIndex; +use Magento\Catalog\Test\Page\Category\CatalogCategoryView; use Magento\Mtf\Client\BrowserInterface; -use Magento\Mtf\Constraint\AbstractConstraint; /** * Class AssertCategoryIsNotActive - * Assert that the category cannot be accessed from the navigation bar in the frontend + * Assert that the category cannot be accessed using the direct URL and from the navigation bar in the frontend */ class AssertCategoryIsNotActive extends AbstractConstraint { const NOT_FOUND_MESSAGE = 'Whoops, our bad...'; /** - * Assert that the category cannot be accessed from the navigation bar in the frontend + * Assert that the category cannot be accessed using the direct URL and from the navigation bar in the frontend * - * @param CmsIndex $cmsIndex * @param Category $category + * @param CatalogCategoryView $categoryView * @param BrowserInterface $browser * @return void */ - public function processAssert(CmsIndex $cmsIndex, Category $category, BrowserInterface $browser) - { - $cmsIndex->open(); + public function processAssert( + Category $category, + CatalogCategoryView $categoryView, + BrowserInterface $browser + ) { + $browser->open($this->getCategoryUrl($category)); \PHPUnit_Framework_Assert::assertFalse( - $cmsIndex->getTopmenu()->isCategoryVisible($category->getName()), + $categoryView->getTopmenu()->isCategoryVisible($category->getName()), 'Category can be accessed from the navigation bar in the frontend.' ); - $browser->open($_ENV['app_frontend_url'] . $category->getUrlKey() . '.html'); \PHPUnit_Framework_Assert::assertEquals( self::NOT_FOUND_MESSAGE, - $cmsIndex->getTitleBlock()->getTitle(), + $categoryView->getTitleBlock()->getTitle(), 'Wrong page is displayed.' ); } + /** + * Get category url to open. + * + * @param Category $category + * @return string + */ + protected function getCategoryUrl(Category $category) + { + $categoryUrlKey = []; + while ($category) { + $categoryUrlKey[] = $category->hasData('url_key') + ? strtolower($category->getUrlKey()) + : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-'); + + $category = $category->getParentId()['category']; + if (1 == $category->getParentId()) { + $category = null; + } + } + + return $_ENV['app_frontend_url'] . implode('/', array_reverse($categoryUrlKey)) . '.html'; + } + + /** * Category not find in top menu * diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotIncludeInMenu.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotIncludeInMenu.php deleted file mode 100644 index d580889a348aa..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotIncludeInMenu.php +++ /dev/null @@ -1,68 +0,0 @@ -open(); - \PHPUnit_Framework_Assert::assertFalse( - $cmsIndex->getTopmenu()->isCategoryVisible($category->getName()), - 'Category can be accessed from the navigation bar in the frontend.' - ); - - $browser->open($_ENV['app_frontend_url'] . $category->getUrlKey() . '.html'); - \PHPUnit_Framework_Assert::assertEquals( - $category->getName(), - $categoryView->getTitleBlock()->getTitle(), - 'Wrong page is displayed.' - ); - if (isset($category->getDataFieldConfig('category_products')['source'])) { - $products = $category->getDataFieldConfig('category_products')['source']->getProducts(); - foreach ($products as $productFixture) { - \PHPUnit_Framework_Assert::assertTrue( - $categoryView->getListProductBlock()->getProductItem($productFixture)->isVisible(), - "Products '{$productFixture->getName()}' not find." - ); - } - } - } - - /** - * Category is no longer available on the top menu bar, but can be viewed by URL with all assigned products - * - * @return string - */ - public function toString() - { - return 'Category is not on the top menu bar, but can be viewed by URL.'; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php index 992fdc6c76702..f3fdb055d2169 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php @@ -11,10 +11,10 @@ use Magento\Catalog\Test\Page\Category\CatalogCategoryView; use Magento\Mtf\Client\BrowserInterface; use Magento\Mtf\Constraint\AbstractConstraint; -use Magento\Mtf\Fixture\FixtureFactory; /** * Assert that displayed category data on category page equals to passed from fixture. + * NOTE: Design settings, Meta Keywords and Meta Description are not verified. */ class AssertCategoryPage extends AbstractConstraint { @@ -42,55 +42,53 @@ class AssertCategoryPage extends AbstractConstraint */ protected $browser; + /** + * Category to test. + * + * @var Category + */ + protected $category; + /** * Assert that displayed category data on category page equals to passed from fixture. * * @param Category $category - * @param Category $initialCategory - * @param FixtureFactory $fixtureFactory * @param CatalogCategoryView $categoryView * @param BrowserInterface $browser * @return void */ public function processAssert( Category $category, - Category $initialCategory, - FixtureFactory $fixtureFactory, CatalogCategoryView $categoryView, BrowserInterface $browser ) { $this->browser = $browser; + $this->category = $category; $this->categoryViewPage = $categoryView; - $categoryData = $this->prepareData($fixtureFactory, $category, $initialCategory); $this->browser->open($this->getCategoryUrl($category)); - $this->assertGeneralInformation($category, $categoryData); - $this->assertDisplaySetting($category, $categoryData); + $categoryData = $this->prepareFixtureData($category->getData()); + $diff = $this->verifyGeneralInformation($categoryData); + $diff = array_merge($diff, $this->verifyContent($categoryData)); + $diff = array_merge($diff, $this->verifyDisplaySettings($categoryData)); + $diff = array_merge($diff, $this->verifySearchEngineOptimization($categoryData)); + \PHPUnit_Framework_Assert::assertEmpty( + $diff, + "Category settings on Storefront page are different.\n" . implode(' ', $diff) + ); } /** - * Prepare comparison data. + * Prepares fixture data for comparison. * - * @param FixtureFactory $fixtureFactory - * @param Category $category - * @param Category $initialCategory + * @param array $data * @return array */ - protected function prepareData(FixtureFactory $fixtureFactory, Category $category, Category $initialCategory) + protected function prepareFixtureData(array $data) { - $product = $fixtureFactory->createByCode( - 'catalogProductSimple', - [ - 'dataset' => 'default', - 'data' => [ - 'category_ids' => [ - 'category' => $initialCategory, - ], - ] - ] - ); - $product->persist(); - - return array_merge($initialCategory->getData(), $category->getData()); + if (isset($data['id'])) { + unset($data['id']); + } + return $data; } /** @@ -107,7 +105,7 @@ protected function getCategoryUrl(Category $category) ? strtolower($category->getUrlKey()) : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-'); - $category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory(); + $category = $category->getParentId()['category']; if (1 == $category->getParentId()) { $category = null; } @@ -117,83 +115,103 @@ protected function getCategoryUrl(Category $category) } /** - * Assert category general information. + * Verify category general information: + * # Include in menu + * # Name * - * @param Category $category * @param array $categoryData - * @return void + * @return array */ - protected function assertGeneralInformation(Category $category, array $categoryData) + protected function verifyGeneralInformation(array $categoryData) { - $categoryUrl = $this->getCategoryUrl($category); - \PHPUnit_Framework_Assert::assertEquals( - $categoryUrl, - $this->browser->getUrl(), - 'Wrong page URL.' - . "\nExpected: " . $categoryUrl - . "\nActual: " . $this->browser->getUrl() - ); + $errorMessage = []; + + if (isset($categoryData['include_in_menu']) && $categoryData['include_in_menu'] == 'Yes') { + if (!$this->categoryViewPage->getTopmenu()->isCategoryVisible($categoryData['name'])) { + $errorMessage[] = 'Category is not visible in the navigation pane.'; + } + } + if (isset($categoryData['include_in_menu']) && $categoryData['include_in_menu'] == 'No') { + if ($this->categoryViewPage->getTopmenu()->isCategoryVisible($categoryData['name'])) { + $errorMessage[] = 'Category is visible in the navigation pane.'; + } + } if (isset($categoryData['name'])) { $title = $this->categoryViewPage->getTitleBlock()->getTitle(); - \PHPUnit_Framework_Assert::assertEquals( - $categoryData['name'], - $title, - 'Wrong page title.' - . "\nExpected: " . $categoryData['name'] - . "\nActual: " . $title - ); + if ($categoryData['name'] != $title) { + $errorMessage[] = 'Wrong category name.' + . "\nExpected: " . $categoryData['name'] + . "\nActual: " . $title; + } } - if (isset($categoryData['description'])) { - $description = $this->categoryViewPage->getViewBlock()->getDescription(); - \PHPUnit_Framework_Assert::assertEquals( - $categoryData['description'], - $description, - 'Wrong category description.' - . "\nExpected: " . $categoryData['description'] - . "\nActual: " . $description - ); - } + return $errorMessage; } /** - * Assert category display settings. + * Verify category Content data: + * # Description + * # CMS Block content * - * @param Category $category * @param array $categoryData - * @return void + * @return array */ - protected function assertDisplaySetting(Category $category, array $categoryData) + protected function verifyContent(array $categoryData) { + $errorMessage = []; + + if (isset($categoryData['description'])) { + $description = $this->categoryViewPage->getViewBlock()->getDescription(); + if ($categoryData['description'] != $description) { + $errorMessage[] = 'Wrong category description.' + . "\nExpected: " . $categoryData['description'] + . "\nActual: " . $description; + } + } + if ( isset($categoryData['landing_page']) && isset($categoryData['display_mode']) && in_array($categoryData['display_mode'], $this->visibleCmsBlockMode) ) { /** @var LandingPage $sourceLandingPage */ - $sourceLandingPage = $category->getDataFieldConfig('landing_page')['source']; + $sourceLandingPage = $this->category->getDataFieldConfig('landing_page')['source']; $fixtureContent = $sourceLandingPage->getCmsBlock()->getContent(); $pageContent = $this->categoryViewPage->getViewBlock()->getContent(); - \PHPUnit_Framework_Assert::assertEquals( - $fixtureContent, - $pageContent, - 'Wrong category landing page content.' - . "\nExpected: " . $fixtureContent - . "\nActual: " . $pageContent - ); + if ($fixtureContent != $pageContent) { + $errorMessage[] = 'Wrong category landing page content.' + . "\nExpected: " . $fixtureContent + . "\nActual: " . $pageContent; + } } + + return $errorMessage; + } + + /** + * Verify category Display Settings data: + * # default_sort_by + * # available_sort_by + * + * @param array $categoryData + * @return array + */ + protected function verifyDisplaySettings(array $categoryData) + { + $errorMessage = []; + + //TODO: verify display_mode + if (isset($categoryData['default_sort_by'])) { $sortBy = strtolower($categoryData['default_sort_by']); $sortType = $this->categoryViewPage->getTopToolbar()->getSelectSortType(); - \PHPUnit_Framework_Assert::assertEquals( - $sortBy, - $sortType, - 'Wrong sorting type.' - . "\nExpected: " . $sortBy - . "\nActual: " . $sortType - ); + if ($sortBy != $sortType) { + $errorMessage[] = 'Wrong sorting type.' + . "\nExpected: " . $sortBy + . "\nActual: " . $sortType; + } } if (isset($categoryData['available_sort_by'])) { @@ -204,17 +222,50 @@ function (&$value) { } ); if ($availableSortType) { - $availableSortType = array_values($availableSortType); - $availableSortTypeOnPage = $this->categoryViewPage->getTopToolbar()->getSortType(); - \PHPUnit_Framework_Assert::assertEquals( - $availableSortType, - $availableSortTypeOnPage, - 'Wrong available sorting type.' - . "\nExpected: " . implode(PHP_EOL, $availableSortType) - . "\nActual: " . implode(PHP_EOL, $availableSortTypeOnPage) - ); + $expected = array_values($availableSortType); + $actual = $this->categoryViewPage->getTopToolbar()->getSortType(); + if ($expected != $actual) { + $errorMessage[] = 'Wrong available sorting type.' + . "\nExpected: " . implode(PHP_EOL, $expected) + . "\nActual: " . implode(PHP_EOL, $actual); + } } } + + // TODO: verify Layered Navigation Price Step + + return $errorMessage; + } + + /** + * Verify category Search Engine Optimization data: + * # URL + * # Meta Title + * + * @param array $categoryData + * @return array + */ + protected function verifySearchEngineOptimization(array $categoryData) + { + $errorMessage = []; + + $categoryUrl = $this->getCategoryUrl($this->category); + if ($categoryUrl != $this->browser->getUrl()) { + $errorMessage[] = 'Wrong page URL.' + . "\nExpected: " . $categoryUrl + . "\nActual: " . $this->browser->getUrl(); + }; + + if (isset($categoryData['meta_title'])) { + $actual = $this->categoryViewPage->getMetaInformation()->getTitle(); + if ($categoryData['meta_title'] != $actual) { + $errorMessage[] = 'Wrong page title.' + . "\nExpected: " . $categoryData['meta_title'] + . "\nActual: " . $actual; + }; + } + + return $errorMessage; } /** diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category.xml index 032766276e5f9..07955270401b4 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category.xml @@ -20,6 +20,7 @@ + @@ -37,11 +38,19 @@ + + + - - + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/ParentId.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/ParentId.php index 17a37eef163e4..b67de526f57d2 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/ParentId.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/ParentId.php @@ -36,7 +36,8 @@ public function __construct(FixtureFactory $fixtureFactory, array $params, $data if (!$this->parentCategory->hasData('id')) { $this->parentCategory->persist(); } - $this->data = $this->parentCategory->getId(); + $this->data['id'] = $this->parentCategory->getId(); + $this->data['category'] = $this->parentCategory; } else { $this->data = $data; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php index 20902e57962e5..962de84aeb237 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php @@ -164,6 +164,7 @@ public function prepareData(FixtureInterface $fixture) $this->prepareCategoryProducts(); $this->fields['general'] = $this->replaceMappingData($this->fields['general']); + $this->fields['general']['parent_id'] = $this->fields['general']['parent_id']['id']; return $this->fields; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Webapi.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Webapi.php index ec9646db1bf81..eda57580f2bcf 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Webapi.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Webapi.php @@ -116,6 +116,8 @@ public function prepareData(FixtureInterface $fixture) ]; } + $data['parent_id'] = $data['parent_id']['id']; + return ['category' => $data]; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml index 730724269f29e..bf15c2d331acf 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml @@ -7,6 +7,8 @@ --> + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml index 24caf82178b02..4ec9224af53f9 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml @@ -7,79 +7,95 @@ --> - - Create root category with required fields + + Create root category with required fields only addRootCategory Yes RootCategory%isolation% - RootCategory Required - No - Position - Name - Price - + Create root category with all fields addRootCategory Yes Yes RootCategory%isolation% RootCategory All Fields + default Static block and products - Yes + No No - Position - Name - Price + Name + Price No - Name + Price No 50 - RootCategory Page Title + Custom Meta Title %isolation% + custom meta keywords %isolation% + Custom meta description %isolation% + 2 columns with right bar + LAYOUT UPDATE XML + Yes + 01/10/2014 + 12/31/2024 + Magento Luma - - Create subcategory with required fields + addSubcategory default_category Yes + Yes Subcategory%isolation% - Subcategory Required - Yes - Subcategory%isolation% + test_type:acceptance_test - - Create not anchor subcategory with required fields + + Create not anchor subcategory specifying all fields addSubcategory default_category Yes Yes Subcategory%isolation% Subcategory For Anchor Subcategory + default + Static block and products No - Yes - Yes - Yes + No + Name + Price + No + Price + No + 5 Subcategory%isolation% + Custom Meta Title %isolation% + custom meta keywords %isolation% + Custom meta description %isolation% catalogProductSimple::default,catalogProductSimple::default + 2 columns with right bar + LAYOUT UPDATE XML + Yes + 01/10/2014 + 12/31/2024 + Magento Luma - + Create anchor subcategory with all fields addSubcategory default_category Yes Yes - Subcategory%isolation% + AnchorSubcategory%isolation% Anchor Subcategory All Fields default Static block and products @@ -89,56 +105,40 @@ Name Price No - Price + Name No - 50 - Subcategory%isolation% - Subcategory Page Title - catalogProductSimple::default,catalogProductSimple::default + 5.5 + AnchorSubcategory%isolation% + Anchor Subcategory Page Title + catalogProductSimple::default, configurableProduct::default - + Create not active subcategory addSubcategory default_category - Yes + No Yes - Subcategory%isolation% - Not active category - Yes - Yes - Yes - Subcategory%isolation% + InactiveSubcategory%isolation% + - + Create not included in menu subcategory addSubcategory default_category Yes No Subcategory%isolation% - Not included in menu - Subcategory%isolation% - - - - - addSubcategory - default_category - Yes - Yes - Subcategory%isolation% - test_type:acceptance_test - + test_type:acceptance_test, test_type:extended_acceptance_test addSubcategory default_category @@ -149,7 +149,7 @@ - + test_type:extended_acceptance_test Create category with three nesting addSubcategory diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/DeleteCategoryEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/DeleteCategoryEntityTest.xml index 7b256b47e0cd7..5e7941edeb238 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/DeleteCategoryEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/DeleteCategoryEntityTest.xml @@ -7,19 +7,19 @@ --> - + root_category - + root_subcategory - + default_category diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.php index 7b43b0189048d..8598db9f96804 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.php @@ -10,6 +10,7 @@ use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryEdit; use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryIndex; use Magento\Mtf\TestCase\Injectable; +use Magento\Mtf\Fixture\FixtureFactory; /** * Test Creation for UpdateCategoryEntity @@ -50,19 +51,29 @@ class UpdateCategoryEntityTest extends Injectable */ protected $catalogCategoryEdit; + /** + * Fixture Factory. + * + * @var FixtureFactory + */ + protected $fixtureFactory; + /** * Inject page end prepare default category * * @param Category $initialCategory * @param CatalogCategoryIndex $catalogCategoryIndex * @param CatalogCategoryEdit $catalogCategoryEdit + * @param FixtureFactory $fixtureFactory * @return array */ public function __inject( Category $initialCategory, CatalogCategoryIndex $catalogCategoryIndex, - CatalogCategoryEdit $catalogCategoryEdit + CatalogCategoryEdit $catalogCategoryEdit, + FixtureFactory $fixtureFactory ) { + $this->fixtureFactory = $fixtureFactory; $this->catalogCategoryIndex = $catalogCategoryIndex; $this->catalogCategoryEdit = $catalogCategoryEdit; $initialCategory->persist(); @@ -82,5 +93,24 @@ public function test(Category $category, Category $initialCategory) $this->catalogCategoryIndex->getTreeCategories()->selectCategory($initialCategory); $this->catalogCategoryEdit->getEditForm()->fill($category); $this->catalogCategoryEdit->getFormPageActions()->save(); + return ['category' => $this->prepareData($category, $initialCategory)]; + } + + /** + * Prepare comparison data. + * + * @param Category $category + * @param Category $initialCategory + * @return Category + */ + protected function prepareData(Category $category, Category $initialCategory) + { + $updatedCategory = $this->fixtureFactory->createByCode( + 'category', + [ + 'data' => array_merge($initialCategory->getData(), $category->getData()) + ] + ); + return $updatedCategory; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.xml index af091f73864d6..9c953ff93a232 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.xml @@ -7,46 +7,42 @@ --> - + default_category - Yes - Yes Name%isolation% - Yes - No - Name + No + Category Description Updated UrlKey%isolation% + Category Title Updated - + default_category - Yes - Yes - Name%isolation% - Category Description + Yes + No + Name No - Position + Name Price - Yes - UrlKey%isolation% - Category Title + catalogProductSimple::default - + - + default_category No Name%isolation% + - + custom No Category %isolation% diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Repository/CmsBlock.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/Repository/CmsBlock.xml index 3c025006873c9..78f830f162bcc 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Repository/CmsBlock.xml +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Repository/CmsBlock.xml @@ -15,7 +15,7 @@ all_store_views - Enabled + Yes description_%isolation% diff --git a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/FormSections.php b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/FormSections.php index 51470d0552462..e9eed9c5a52aa 100644 --- a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/FormSections.php +++ b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/FormSections.php @@ -76,9 +76,11 @@ protected function getSectionTitleElement($sectionName) */ public function openSection($sectionName) { - $this->browser->find($this->header)->hover(); if ($this->isCollapsible($sectionName)) { $this->getSectionTitleElement($sectionName)->click(); + } else { + //Scroll to the top of the page so that the page actions header does not overlap any controls + $this->browser->find($this->header)->hover(); } return $this; } From 31e6a3ca553849b2f5d9dd0df2a6248395362b72 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov Date: Fri, 15 Jan 2016 16:24:27 +0200 Subject: [PATCH 03/12] MAGETWO-47285: Admin Panel, Categories: Reset of product assignments occurs after filter is applied --- app/code/Magento/Ui/view/base/web/js/grid/columns/onoff.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/onoff.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/onoff.js index f2ccc859d2e58..4b553467517ba 100755 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/onoff.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/onoff.js @@ -48,24 +48,28 @@ define([ if (positionCacheValid && this.selected().length === 0) { // Check selected data selectedFromCache = JSON.parse(selectedFromCache); + for (i = 0; i < selectedFromCache.length; i++) { this.selected.push(selectedFromCache[i]); } registry.set('position_cache_valid', true); registry.set('selected_cache', JSON.stringify(this.selected())); + return; } if (positionCacheValid && this.selected().length > 0) { registry.set('position_cache_valid', true); registry.set('selected_cache', JSON.stringify(this.selected())); + return; } if (this.selectedData.length === 0) { registry.set('position_cache_valid', true); registry.set('selected_cache', JSON.stringify([])); + return; } From 83f176b96cb971ec2f599b73fa9cf03952e74179 Mon Sep 17 00:00:00 2001 From: Kateryna Muntianu Date: Mon, 18 Jan 2016 11:15:21 +0200 Subject: [PATCH 04/12] MAGETWO-47760: Extend functional test coverage for Categories - Added new plan to run only Categories tests --- .../Catalog/Test/Handler/Category/Webapi.php | 2 -- .../InjectableTests/domain_mx_category.xml | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_mx_category.xml diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Webapi.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Webapi.php index eda57580f2bcf..ec9646db1bf81 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Webapi.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Webapi.php @@ -116,8 +116,6 @@ public function prepareData(FixtureInterface $fixture) ]; } - $data['parent_id'] = $data['parent_id']['id']; - return ['category' => $data]; } diff --git a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_mx_category.xml b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_mx_category.xml new file mode 100644 index 0000000000000..4f2a724b14994 --- /dev/null +++ b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_mx_category.xml @@ -0,0 +1,15 @@ + + + + + + + + + From 1431494fd27344ddfddc262cf97a17951aed0e70 Mon Sep 17 00:00:00 2001 From: Kateryna Muntianu Date: Mon, 18 Jan 2016 13:51:05 +0200 Subject: [PATCH 05/12] MAGETWO-47760: Extend functional test coverage for Categories - Fixed test not working when a large number of categories is created --- .../Catalog/Test/Block/Adminhtml/Category/Tree.php | 9 +++++++++ .../Test/Constraint/AssertCategoryBreadcrumbs.php | 4 ++-- .../Test/Constraint/AssertCategoryIsNotActive.php | 2 +- .../Catalog/Test/Constraint/AssertCategoryPage.php | 2 +- .../Catalog/Test/Fixture/Category/ParentId.php | 1 + .../Magento/Catalog/Test/Handler/Category/Curl.php | 14 +++++++++++++- .../Magento/Catalog/Test/Repository/Category.xml | 8 ++++++-- 7 files changed, 33 insertions(+), 7 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Tree.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Tree.php index 35662e78d52a2..4217ce5ceb67a 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Tree.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Tree.php @@ -53,6 +53,13 @@ class Tree extends Block */ protected $treeElement = '.tree-holder'; + /** + * Page header selector. + * + * @var string + */ + protected $header = 'header'; + /** * Get backend abstract block. * @@ -73,6 +80,7 @@ protected function getTemplateBlock() */ public function addSubcategory() { + $this->browser->find($this->header)->hover(); $this->_rootElement->find($this->addSubcategory, Locator::SELECTOR_CSS)->click(); $this->getTemplateBlock()->waitLoader(); } @@ -84,6 +92,7 @@ public function addSubcategory() */ public function addRootCategory() { + $this->browser->find($this->header)->hover(); $this->_rootElement->find($this->addRootCategory, Locator::SELECTOR_CSS)->click(); $this->getTemplateBlock()->waitLoader(); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryBreadcrumbs.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryBreadcrumbs.php index f85d76989b0c5..86591e39e9e03 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryBreadcrumbs.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryBreadcrumbs.php @@ -71,7 +71,7 @@ protected function openCategory(Category $category) : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-'); $category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory(); - if ($category !== null && 1 == $category->getParentId()) { + if ($category !== null && 1 == $category->getParentId()['id']) { $category = null; } } @@ -94,7 +94,7 @@ protected function getBreadcrumbs(Category $category) $breadcrumbs[] = $category->getName(); $category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory(); - if ($category !== null && 1 == $category->getParentId()) { + if ($category !== null && 1 == $category->getParentId()['id']) { $category = null; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotActive.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotActive.php index 1e9a6246d9895..d51f0da23d4a2 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotActive.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotActive.php @@ -59,7 +59,7 @@ protected function getCategoryUrl(Category $category) : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-'); $category = $category->getParentId()['category']; - if (1 == $category->getParentId()) { + if (1 == $category->getParentId()['id']) { $category = null; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php index f3fdb055d2169..5227f78845dbd 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php @@ -106,7 +106,7 @@ protected function getCategoryUrl(Category $category) : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-'); $category = $category->getParentId()['category']; - if (1 == $category->getParentId()) { + if (1 == $category->getParentId()['id']) { $category = null; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/ParentId.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/ParentId.php index b67de526f57d2..00daebf34d516 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/ParentId.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/ParentId.php @@ -12,6 +12,7 @@ /** * Prepare parent category. + * Sets parent_id data as [['id' => 'N' ], ['category' => Category ]] */ class ParentId extends DataSource { diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php index a8006ac5589bb..c841a270ab9a1 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php @@ -159,15 +159,27 @@ public function prepareData(FixtureInterface $fixture) $this->fixture = $fixture; $this->fields = ['general' => $fixture->getData()]; + $this->prepareParentId(); $this->prepareGeneralInformation(); $this->prepareDisplaySetting(); $this->prepareCategoryProducts(); $this->fields['general'] = $this->replaceMappingData($this->fields['general']); - $this->fields['general']['parent_id'] = $this->fields['general']['parent_id']['id']; return $this->fields; } + /** + * Prepare parent_id received from a fixture. + * + * @return void + */ + protected function prepareParentId() + { + $this->fields['general']['parent_id'] = isset($this->fields['general']['parent_id']['id']) + ? $this->fields['general']['parent_id']['id'] + : $this->fields['general']['parent_id']; + } + /** * Prepare data for "General Information" tab. * diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml index 7bdedc624f606..fd0c6e4b97e6e 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml @@ -19,7 +19,9 @@ Default Category - 1 + + 1 + Yes 2 @@ -47,7 +49,9 @@ RootCategory%isolation% - 1 + + 1 + Yes Yes From 4eaa9a8845aeb65ae7d026ea836e1424f2352c67 Mon Sep 17 00:00:00 2001 From: Kateryna Muntianu Date: Mon, 18 Jan 2016 17:17:21 +0200 Subject: [PATCH 06/12] MAGETWO-47760: Extend functional test coverage for Categories - Reverted changes for parent_id - Removed domain_mx_category --- .../Constraint/AssertCategoryBreadcrumbs.php | 4 +-- .../Test/Constraint/AssertCategoryForm.php | 4 +-- .../Constraint/AssertCategoryIsNotActive.php | 4 +-- .../Test/Constraint/AssertCategoryPage.php | 4 +-- .../Test/Fixture/Category/ParentId.php | 7 +++--- .../Catalog/Test/Handler/Category/Curl.php | 13 ---------- .../Page/Category/CatalogCategoryView.xml | 2 +- .../Catalog/Test/Repository/Category.xml | 8 ++---- .../Category/UpdateCategoryEntityTest.php | 25 ++++++++++++------- .../Test/Block}/MetaInformation.php | 4 +-- .../InjectableTests/domain_mx_category.xml | 15 ----------- 11 files changed, 32 insertions(+), 58 deletions(-) rename dev/tests/functional/tests/app/Magento/{Catalog/Test/Block/Category => Cms/Test/Block}/MetaInformation.php (85%) delete mode 100644 dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_mx_category.xml diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryBreadcrumbs.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryBreadcrumbs.php index 86591e39e9e03..f85d76989b0c5 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryBreadcrumbs.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryBreadcrumbs.php @@ -71,7 +71,7 @@ protected function openCategory(Category $category) : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-'); $category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory(); - if ($category !== null && 1 == $category->getParentId()['id']) { + if ($category !== null && 1 == $category->getParentId()) { $category = null; } } @@ -94,7 +94,7 @@ protected function getBreadcrumbs(Category $category) $breadcrumbs[] = $category->getName(); $category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory(); - if ($category !== null && 1 == $category->getParentId()['id']) { + if ($category !== null && 1 == $category->getParentId()) { $category = null; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryForm.php index fe498dcb9c021..1cfd6340cc089 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryForm.php @@ -67,9 +67,7 @@ protected function prepareFixtureData(array $data) $data['url_key'] = strtolower($data['url_key']); } - if (isset($data['id'])) { - unset($data['id']); - } + unset($data['id']); return array_diff_key($data, array_flip($this->skippedFixtureFields)); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotActive.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotActive.php index d51f0da23d4a2..046897e7f3934 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotActive.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryIsNotActive.php @@ -58,8 +58,8 @@ protected function getCategoryUrl(Category $category) ? strtolower($category->getUrlKey()) : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-'); - $category = $category->getParentId()['category']; - if (1 == $category->getParentId()['id']) { + $category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory(); + if (1 == $category->getParentId()) { $category = null; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php index 5227f78845dbd..45b3ec57b91e9 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php @@ -105,8 +105,8 @@ protected function getCategoryUrl(Category $category) ? strtolower($category->getUrlKey()) : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-'); - $category = $category->getParentId()['category']; - if (1 == $category->getParentId()['id']) { + $category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory(); + if ($category !== null && 1 == $category->getParentId()) { $category = null; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/ParentId.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/ParentId.php index 00daebf34d516..cad40d5e71fc7 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/ParentId.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/ParentId.php @@ -12,7 +12,6 @@ /** * Prepare parent category. - * Sets parent_id data as [['id' => 'N' ], ['category' => Category ]] */ class ParentId extends DataSource { @@ -37,8 +36,10 @@ public function __construct(FixtureFactory $fixtureFactory, array $params, $data if (!$this->parentCategory->hasData('id')) { $this->parentCategory->persist(); } - $this->data['id'] = $this->parentCategory->getId(); - $this->data['category'] = $this->parentCategory; + $this->data = $this->parentCategory->getId(); + } else if (isset($data['source']) && $data['source'] instanceof Category) { + $this->parentCategory = $data['source']; + $this->data = $data['source']->getId(); } else { $this->data = $data; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php index c841a270ab9a1..0c1a632937cca 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php @@ -159,7 +159,6 @@ public function prepareData(FixtureInterface $fixture) $this->fixture = $fixture; $this->fields = ['general' => $fixture->getData()]; - $this->prepareParentId(); $this->prepareGeneralInformation(); $this->prepareDisplaySetting(); $this->prepareCategoryProducts(); @@ -168,18 +167,6 @@ public function prepareData(FixtureInterface $fixture) return $this->fields; } - /** - * Prepare parent_id received from a fixture. - * - * @return void - */ - protected function prepareParentId() - { - $this->fields['general']['parent_id'] = isset($this->fields['general']['parent_id']['id']) - ? $this->fields['general']['parent_id']['id'] - : $this->fields['general']['parent_id']; - } - /** * Prepare data for "General Information" tab. * diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml index bf15c2d331acf..56862b7bda805 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml @@ -7,7 +7,7 @@ --> - + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml index fd0c6e4b97e6e..7bdedc624f606 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml @@ -19,9 +19,7 @@ Default Category - - 1 - + 1 Yes 2 @@ -49,9 +47,7 @@ RootCategory%isolation% - - 1 - + 1 Yes Yes diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.php index 8598db9f96804..080d2471811d1 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.php @@ -93,7 +93,8 @@ public function test(Category $category, Category $initialCategory) $this->catalogCategoryIndex->getTreeCategories()->selectCategory($initialCategory); $this->catalogCategoryEdit->getEditForm()->fill($category); $this->catalogCategoryEdit->getFormPageActions()->save(); - return ['category' => $this->prepareData($category, $initialCategory)]; + + return ['category' => $this->prepareCategory($category, $initialCategory)]; } /** @@ -103,14 +104,20 @@ public function test(Category $category, Category $initialCategory) * @param Category $initialCategory * @return Category */ - protected function prepareData(Category $category, Category $initialCategory) + protected function prepareCategory(Category $category, Category $initialCategory) { - $updatedCategory = $this->fixtureFactory->createByCode( - 'category', - [ - 'data' => array_merge($initialCategory->getData(), $category->getData()) - ] - ); - return $updatedCategory; + $parentCategory = $category->hasData('parent_id') + ? $category->getDataFieldConfig('parent_id')['source']->getParentCategory() + : $initialCategory->getDataFieldConfig('parent_id')['source']->getParentCategory(); + + $data = [ + 'data' => array_merge( + $initialCategory->getData(), + $category->getData(), + ['parent_id' => ['source' => $parentCategory]] + ) + ]; + + return $this->fixtureFactory->createByCode('category', $data); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Category/MetaInformation.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/MetaInformation.php similarity index 85% rename from dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Category/MetaInformation.php rename to dev/tests/functional/tests/app/Magento/Cms/Test/Block/MetaInformation.php index 9ef54bda7e6a9..218bc268326c9 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Category/MetaInformation.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/MetaInformation.php @@ -4,12 +4,12 @@ * See COPYING.txt for license details. */ -namespace Magento\Catalog\Test\Block\Category; +namespace Magento\Cms\Test\Block; use Magento\Mtf\Block\Block; /** - * MetaInformation block on the category page. + * MetaInformation block on the Storefront page. */ class MetaInformation extends Block { diff --git a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_mx_category.xml b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_mx_category.xml deleted file mode 100644 index 4f2a724b14994..0000000000000 --- a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/domain_mx_category.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - From ee642d4a3cf7a6be529f5c34086d3baec0cfaaef Mon Sep 17 00:00:00 2001 From: Kateryna Muntianu Date: Mon, 18 Jan 2016 18:29:44 +0200 Subject: [PATCH 07/12] MAGETWO-47760: Extend functional test coverage for Categories --- .../Magento/Catalog/Test/Constraint/AssertCategoryForm.php | 5 ++--- .../Test/TestCase/Category/UpdateCategoryEntityTest.php | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryForm.php index 1cfd6340cc089..20fd06286245c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryForm.php @@ -26,7 +26,8 @@ class AssertCategoryForm extends AbstractAssertForm * @var array */ protected $skippedFixtureFields = [ - 'parent_id' + 'parent_id', + 'id' ]; /** @@ -67,8 +68,6 @@ protected function prepareFixtureData(array $data) $data['url_key'] = strtolower($data['url_key']); } - unset($data['id']); - return array_diff_key($data, array_flip($this->skippedFixtureFields)); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.php index 080d2471811d1..1577a9692355c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.php @@ -98,7 +98,7 @@ public function test(Category $category, Category $initialCategory) } /** - * Prepare comparison data. + * Prepare Category fixture with the updated data. * * @param Category $category * @param Category $initialCategory From 2dc7f7f22e1e26fddf9ad9654b8f30aadd29c122 Mon Sep 17 00:00:00 2001 From: Vitalii Zabaznov Date: Tue, 19 Jan 2016 12:15:05 +0200 Subject: [PATCH 08/12] MAGETWO-46886: Datepickers on email reminder page save date in store timezone - fix phrase usage and setting dynamic field --- .../Magento/Framework/Stdlib/DateTime/Timezone.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php index 2cc8e993c2d73..e3c4ab8d35dac 100644 --- a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php +++ b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php @@ -6,6 +6,7 @@ namespace Magento\Framework\Stdlib\DateTime; use \Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Phrase; /** * Timezone library @@ -47,6 +48,11 @@ class Timezone implements TimezoneInterface */ protected $_scopeConfig; + /** + * @var \Magento\Framework\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver * @param \Magento\Framework\Locale\ResolverInterface $localeResolver @@ -294,7 +300,7 @@ public function convertConfigTimeToUtc($date, $format = 'Y-m-d H:i:s') } else { if ($date->getTimezone()->getName() !== $this->getConfigTimezone()) { throw new LocalizedException( - __('DateTime object timezone must be the same as config - %1', $this->getConfigTimezone()) + new Phrase('DateTime object timezone must be the same as config - %1', $this->getConfigTimezone()) ); } } From 03f436f8f7981cf9ce88a2831cac91b917e0847c Mon Sep 17 00:00:00 2001 From: Kateryna Muntianu Date: Thu, 21 Jan 2016 12:39:56 +0200 Subject: [PATCH 09/12] MAGETWO-48042: Process pull request --- .../Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml index 56862b7bda805..1af5a4a50b1e4 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml @@ -8,7 +8,7 @@ - + From 319feb7b2d47e3db0b5c573a5301a01d09a343d2 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov Date: Thu, 21 Jan 2016 15:43:08 +0200 Subject: [PATCH 10/12] MAGETWO-47746: Cannot open categories if admin user does not have access to default website --- .../Catalog/Controller/Adminhtml/Category/Edit.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php index 8801681596585..591c95840b4bb 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php @@ -59,7 +59,16 @@ public function execute() if ($storeId) { $categoryId = (int)$this->storeManager->getStore($storeId)->getRootCategoryId(); } else { - $categoryId = (int)$this->storeManager->getDefaultStoreView()->getRootCategoryId(); + $defaultStoreView = $this->storeManager->getDefaultStoreView(); + if ($defaultStoreView) { + $categoryId = (int)$this->storeManager->getDefaultStoreView()->getRootCategoryId(); + } else { + $stores = $this->storeManager->getStores(); + if (count($stores)) { + $store = reset($stores); + $categoryId = (int)$this->storeManager->getStore($store->getId())->getRootCategoryId(); + } + } } $this->getRequest()->setParam('id', $categoryId); } From 2cb64b5a438dd315bbd34aa8f88614c5c3896eb2 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov Date: Thu, 21 Jan 2016 15:48:38 +0200 Subject: [PATCH 11/12] MAGETWO-47746: Cannot open categories if admin user does not have access to default website --- app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php index 591c95840b4bb..60d5ae5c1c4bd 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php @@ -61,7 +61,7 @@ public function execute() } else { $defaultStoreView = $this->storeManager->getDefaultStoreView(); if ($defaultStoreView) { - $categoryId = (int)$this->storeManager->getDefaultStoreView()->getRootCategoryId(); + $categoryId = (int)$defaultStoreView->getRootCategoryId(); } else { $stores = $this->storeManager->getStores(); if (count($stores)) { From 349fd4b94bdf056168666ef2e99b199f66eb1e6a Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov Date: Thu, 21 Jan 2016 15:57:54 +0200 Subject: [PATCH 12/12] MAGETWO-47746: Cannot open categories if admin user does not have access to default website --- app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php index 60d5ae5c1c4bd..c3e5f20071394 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php @@ -66,7 +66,7 @@ public function execute() $stores = $this->storeManager->getStores(); if (count($stores)) { $store = reset($stores); - $categoryId = (int)$this->storeManager->getStore($store->getId())->getRootCategoryId(); + $categoryId = (int)$store->getRootCategoryId(); } } }