diff --git a/app/code/Magento/Backend/etc/config.xml b/app/code/Magento/Backend/etc/config.xml index 459dd377e36bac315d1d56f6e8dd4e499986c149..760bba1fc12f4c1c3096ad6f422bf645ed174d06 100644 --- a/app/code/Magento/Backend/etc/config.xml +++ b/app/code/Magento/Backend/etc/config.xml @@ -11,6 +11,9 @@ <template> <minify_html>0</minify_html> </template> + <static> + <sign>1</sign> + </static> </dev> <system> <media_storage_configuration> diff --git a/app/code/Magento/CatalogInventory/Helper/Stock.php b/app/code/Magento/CatalogInventory/Helper/Stock.php index 6169efca64bd08e06181bddbf37f06e6e0648dd1..4c177c09d4b79a62f2a5b07c7b208c37d1c05ec3 100644 --- a/app/code/Magento/CatalogInventory/Helper/Stock.php +++ b/app/code/Magento/CatalogInventory/Helper/Stock.php @@ -154,7 +154,10 @@ class Stock \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); $resource = $this->getStockStatusResource(); - $resource->addStockDataToCollection($collection, !$isShowOutOfStock); + $resource->addStockDataToCollection( + $collection, + !$isShowOutOfStock && $collection->getFlag('require_stock_items') + ); $collection->setFlag($stockFlag, true); } } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/StoreForm.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/StoreForm.php index 3aa435226553555a927cf7695060e5392a72a65c..9f20ae953c2117bae7e5c9765bc36d5d4e43d873 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/StoreForm.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Store/Edit/Form/StoreForm.php @@ -22,6 +22,13 @@ class StoreForm extends Form */ protected $store = '//option[contains(.,"%s")]'; + /** + * Store dropdown selector + * + * @var string + */ + protected $storeGroupId = '//select[@id="store_group_id"]'; + /** * Check that Store visible in Store dropdown * @@ -32,4 +39,16 @@ class StoreForm extends Form { return $this->_rootElement->find(sprintf($this->store, $name), Locator::SELECTOR_XPATH)->isVisible(); } + + /** + * Select store view by name from dropdown + * + * @param string $name + * @return bool + */ + public function selectStore($name) + { + return $this->_rootElement->find($this->storeGroupId, Locator::SELECTOR_XPATH, 'optgroupselect') + ->setValue($name); + } } diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertCmsPageOnFrontend.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertCmsPageOnFrontend.php new file mode 100644 index 0000000000000000000000000000000000000000..401042c031259f4c9e473e8ed7c0fbabb063b5fc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertCmsPageOnFrontend.php @@ -0,0 +1,52 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Cms\Test\Constraint; + +use Magento\Cms\Test\Fixture\CmsPage; +use Magento\Cms\Test\Page\CmsPage as FrontCmsPage; +use Magento\Mtf\Client\BrowserInterface; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Assert that created CMS page with expected contents displayed on Frontend. + */ +class AssertCmsPageOnFrontend extends AbstractConstraint +{ + /** + * Assert that created CMS page with expected contents displayed on Frontend. + * + * @param CmsPage $cms + * @param FrontCmsPage $frontCmsPage, + * @param BrowserInterface $browser + * @param string $displayContent + * @return void + */ + public function processAssert( + CmsPage $cms, + FrontCmsPage $frontCmsPage, + BrowserInterface $browser, + $displayContent = null + ) { + $browser->open($_ENV['app_frontend_url'] . $cms->getIdentifier()); + $fixtureContent = $cms->getContent(); + \PHPUnit_Framework_Assert::assertContains( + $displayContent != null ? $displayContent : $fixtureContent['content'], + $frontCmsPage->getCmsPageBlock()->getPageContent(), + 'Wrong content is displayed.' + ); + } + + /** + * CMS Page content equals to data from fixture. + * + * @return string + */ + public function toString() + { + return 'CMS Page content equals to data from fixture.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertCmsPagePreview.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertCmsPagePreview.php index 51e9b428892cc53a2db873550f0e0c76d6d997d0..6db35e88efe49e92043b4d85127c74510fb18926 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertCmsPagePreview.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertCmsPagePreview.php @@ -30,6 +30,7 @@ class AssertCmsPagePreview extends AbstractConstraint * @param FrontCmsPage $frontCmsPage * @param CmsPage $cms * @param BrowserInterface $browser + * @param string $displayContent * @return void */ public function processAssert( @@ -37,7 +38,8 @@ class AssertCmsPagePreview extends AbstractConstraint FrontCmsIndex $frontCmsIndex, FrontCmsPage $frontCmsPage, CmsPage $cms, - BrowserInterface $browser + BrowserInterface $browser, + $displayContent = null ) { $cmsIndex->open(); $filter = ['title' => $cms->getTitle()]; @@ -46,7 +48,7 @@ class AssertCmsPagePreview extends AbstractConstraint $fixtureContent = $cms->getContent(); \PHPUnit_Framework_Assert::assertContains( - $fixtureContent['content'], + $displayContent != null ? $displayContent : $fixtureContent['content'], $frontCmsPage->getCmsPageBlock()->getPageContent(), 'Wrong content is displayed.' ); diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.xml index 67b4421182848ebb9b2633c4d9212e6679cccf51..f8b6c8c3d9e06da90b122ba39d0c3f01eebc1978 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/CreateCmsPageEntityTest.xml @@ -54,5 +54,18 @@ <constraint name="Magento\Cms\Test\Constraint\AssertCmsPageSuccessSaveMessage" /> <constraint name="Magento\Cms\Test\Constraint\AssertCmsPageDisabledOnFrontend" /> </variation> + <variation name="CreateCmsPageEntityTestVariation5" summary="Block Cache Exploit" ticketId="MAGETWO-48017"> + <data name="tag" xsi:type="string">severity:S2</data> + <data name="fixtureType" xsi:type="string">cmsPage</data> + <data name="data/title" xsi:type="string">NewCmsPage%isolation%</data> + <data name="data/identifier" xsi:type="string">identifier-%isolation%</data> + <data name="data/store_id" xsi:type="string">Main Website/Main Website Store/Default Store View</data> + <data name="data/is_active" xsi:type="string">Yes</data> + <data name="data/content/content" xsi:type="string">\\{{block class='Magento\Framework\View\Element\Text' text='bla bla bla' cache_key='BACKEND_ACL_RESOURCES' cache_lifetime=999\}}</data> + <data name="displayContent" xsi:type="string">bla bla bla</data> + <constraint name="Magento\Cms\Test\Constraint\AssertCmsPageSuccessSaveMessage" /> + <constraint name="Magento\Cms\Test\Constraint\AssertCmsPagePreview" /> + <constraint name="Magento\Cms\Test\Constraint\AssertCmsPageOnFrontend" /> + </variation> </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/etc/di.xml index f4b96844b27383679f0f2a65f63e5445b4e9b6e7..0d3e1b4ea97103d1fb941843f3c419b62f20d49b 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/etc/di.xml @@ -6,24 +6,84 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> - <type name="Magento\Cms\Test\Constraint\AssertCmsBlockSuccessSaveMessage"> + <type name="Magento\Cms\Test\Constraint\AssertCmsBlockDeleteMessage"> <arguments> - <argument name="severity" xsi:type="string">high</argument> + <argument name="severity" xsi:type="string">S1</argument> </arguments> </type> - <type name="Magento\Cms\Test\Constraint\AssertCmsBlockOnCategoryPage"> + <type name="Magento\Cms\Test\Constraint\AssertCmsBlockInGrid"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Cms\Test\Constraint\AssertCmsBlockNotInGrid"> <arguments> - <argument name="severity" xsi:type="string">high</argument> + <argument name="severity" xsi:type="string">S3</argument> </arguments> </type> <type name="Magento\Cms\Test\Constraint\AssertCmsBlockNotOnCategoryPage"> <arguments> - <argument name="severity" xsi:type="string">high</argument> + <argument name="severity" xsi:type="string">S3</argument> </arguments> </type> - <type name="Magento\Cms\Test\Constraint\AssertCmsBlockDeleteMessage"> + <type name="Magento\Cms\Test\Constraint\AssertCmsBlockOnCategoryPage"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Cms\Test\Constraint\AssertCmsBlockSuccessSaveMessage"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Cms\Test\Constraint\AssertCmsPageDeleteMessage"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Cms\Test\Constraint\AssertCmsPageDisabledOnFrontend"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Cms\Test\Constraint\AssertCmsPageDuplicateErrorMessage"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Cms\Test\Constraint\AssertCmsPageForm"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Cms\Test\Constraint\AssertCmsPageInGrid"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Cms\Test\Constraint\AssertCmsPageNotInGrid"> + <arguments> + <argument name="severity" xsi:type="string">S3</argument> + </arguments> + </type> + <type name="Magento\Cms\Test\Constraint\AssertCmsPageOnFrontend"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Cms\Test\Constraint\AssertCmsPagePreview"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Cms\Test\Constraint\AssertCmsPageSuccessSaveMessage"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Cms\Test\Constraint\AssertUrlRewriteCmsPageRedirect"> <arguments> - <argument name="severity" xsi:type="string">high</argument> + <argument name="severity" xsi:type="string">S1</argument> </arguments> </type> </config> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.php index 9f05188e2ebb483ea16edc9ccb8eab15f309c781..e1e8f2ddebb709e17d8a977668f420d803247558 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.php @@ -110,4 +110,92 @@ class CustomerForm extends Form $mapping['lastname']['strategy'] )->getValue(); } + + /** + * Set 'Change Email' checkbox value. + * + * @param boolean $value + * @return void + */ + public function setChangeEmail($value) + { + $mapping = $this->dataMapping(); + $this->_rootElement->find( + $mapping['change_email']['selector'], + $mapping['change_email']['strategy'], + 'checkbox' + )->setValue($value ? "Yes" : "No"); + } + + /** + * Set 'Change Password' checkbox value. + * + * @param boolean $value + * @return void + */ + public function setChangePassword($value) + { + $mapping = $this->dataMapping(); + $this->_rootElement->find( + $mapping['change_password']['selector'], + $mapping['change_password']['strategy'], + 'checkbox' + )->setValue($value ? "Yes" : "No"); + } + + /** + * Check if Current Password field is visible. + * + * @return boolean + */ + public function isCurrentPasswordVisible() + { + $mapping = $this->dataMapping(); + return $this->_rootElement->find( + $mapping['current_password']['selector'], + $mapping['current_password']['strategy'] + )->isVisible(); + } + + /** + * Check if Password field is visible. + * + * @return boolean + */ + public function isPasswordVisible() + { + $mapping = $this->dataMapping(); + return $this->_rootElement->find( + $mapping['password']['selector'], + $mapping['password']['strategy'] + )->isVisible(); + } + + /** + * Check if Confirmation field is visible. + * + * @return boolean + */ + public function isConfirmPasswordVisible() + { + $mapping = $this->dataMapping(); + return $this->_rootElement->find( + $mapping['confirmation']['selector'], + $mapping['confirmation']['strategy'] + )->isVisible(); + } + + /** + * Check if Email field is visible. + * + * @return boolean + */ + public function isEmailVisible() + { + $mapping = $this->dataMapping(); + return $this->_rootElement->find( + $mapping['email']['selector'], + $mapping['email']['strategy'] + )->isVisible(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.xml index 9bbc247787e62322e5178bf486dce1ee80097356..20610b0672722a5b53cf8028593b2f457412b673 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.xml @@ -9,6 +9,12 @@ <fields> <firstname /> <lastname /> + <change_email> + <input>checkbox</input> + </change_email> + <change_password> + <input>checkbox</input> + </change_password> <email /> <current_password /> <password /> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountEdit.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountEdit.xml index 66a7e57279113b3fe8318498279398daccf9f296..362e66aa19d43ddb361bb4eb790d766d3d10d9a3 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountEdit.xml @@ -9,5 +9,6 @@ <page name="CustomerAccountEdit" mca="customer/account/edit" module="Magento_Customer"> <block name="accountInfoForm" class="Magento\Customer\Test\Block\Form\CustomerForm" locator="#form-validate" strategy="css selector"/> <block name="messages" class="Magento\Backend\Test\Block\Messages" locator=".page.messages" strategy="css selector"/> + <block name="accountMenuBlock" class="Magento\Customer\Test\Block\Account\Links" locator=".nav.items" strategy="css selector"/> </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Security/Test/Constraint/AssertCustomerEmailChanged.php b/dev/tests/functional/tests/app/Magento/Security/Test/Constraint/AssertCustomerEmailChanged.php new file mode 100644 index 0000000000000000000000000000000000000000..68384aacbc70cc4759f99ab9cb0d1cb42ac2ca9d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Security/Test/Constraint/AssertCustomerEmailChanged.php @@ -0,0 +1,64 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Security\Test\Constraint; + +use Magento\Customer\Test\Fixture\Customer; +use Magento\Customer\Test\Page\CustomerAccountIndex; +use Magento\Mtf\Constraint\AbstractConstraint; +use Magento\Mtf\Fixture\FixtureFactory; + +/** + * Check that login again to frontend with new email was successful. + */ +class AssertCustomerEmailChanged extends AbstractConstraint +{ + /** + * Assert that login again to frontend with new email was successful. + * + * @param FixtureFactory $fixtureFactory + * @param CustomerAccountIndex $customerAccountIndex + * @param Customer $initialCustomer + * @param Customer $customer + * @return void + */ + public function processAssert( + FixtureFactory $fixtureFactory, + CustomerAccountIndex $customerAccountIndex, + Customer $initialCustomer, + Customer $customer + ) { + $customer = $fixtureFactory->createByCode( + 'customer', + [ + 'data' => [ + 'email' => $customer->getEmail(), + 'password' => $initialCustomer->getPassword() + ], + ] + ); + + $this->objectManager->create( + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, + ['customer' => $customer] + )->run(); + + \PHPUnit_Framework_Assert::assertTrue( + $customerAccountIndex->getAccountMenuBlock()->isVisible(), + 'Customer Account Dashboard is not visible.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Customer email was changed.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Security/Test/Constraint/AssertDefaultAccountInformation.php b/dev/tests/functional/tests/app/Magento/Security/Test/Constraint/AssertDefaultAccountInformation.php new file mode 100644 index 0000000000000000000000000000000000000000..642db5925157414db3220aceae8049af209ed2d6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Security/Test/Constraint/AssertDefaultAccountInformation.php @@ -0,0 +1,58 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Security\Test\Constraint; + +use Magento\Customer\Test\Page\CustomerAccountEdit; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Assert fields visibility in customer account information tab. + */ +class AssertDefaultAccountInformation extends AbstractConstraint +{ + /** + * Assert fields visibility in customer account information tab. + * + * @param CustomerAccountEdit $customerAccountEdit + * @return void + */ + public function processAssert( + CustomerAccountEdit $customerAccountEdit + ) { + $infoForm = $customerAccountEdit->getAccountInfoForm(); + + \PHPUnit_Framework_Assert::assertFalse( + $infoForm->isEmailVisible(), + 'Email text field should not be visible.' + ); + + \PHPUnit_Framework_Assert::assertFalse( + $infoForm->isCurrentPasswordVisible(), + 'Current Password text field should not be visible.' + ); + + \PHPUnit_Framework_Assert::assertFalse( + $infoForm->isPasswordVisible(), + 'New Password text field should not be visible.' + ); + + \PHPUnit_Framework_Assert::assertFalse( + $infoForm->isConfirmPasswordVisible(), + 'Password Confirmation text field should not be visible.' + ); + } + + /** + * String representation of success assert. + * + * @return string + */ + public function toString() + { + return 'Default customer account information tab is correct.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/SecureChangingCustomerEmailTest.php b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/SecureChangingCustomerEmailTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9f1acd69d92a2e3ba02e52ad4e563932924f2305 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/SecureChangingCustomerEmailTest.php @@ -0,0 +1,88 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Security\Test\TestCase; + +use Magento\Mtf\TestCase\Injectable; +use Magento\Customer\Test\Fixture\Customer; +use Magento\Customer\Test\Page\CustomerAccountEdit; + +/** + * Test Flow: + * + * Preconditions: + * 1. Customer is created + * + * Steps: + * 1. Login to fronted as customer from preconditions + * 2. Navigate to Account Information tab + * 3. Check "Change Email" checkbox + * 4. Fill form according to data set and save + * 5. Perform all assertions + * + * @group Security + * @ZephyrId MAGETWO-49041 + */ +class SecureChangingCustomerEmailTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const SEVERITY = 'S1'; + /* end tags */ + + /** + * CustomerAccountEdit page. + * + * @var CustomerAccountEdit + */ + protected $customerAccountEdit; + + /** + * Preparing page for test. + * + * @param CustomerAccountEdit $customerAccountEdit + * @return void + */ + public function __inject( + CustomerAccountEdit $customerAccountEdit + ) { + $this->customerAccountEdit = $customerAccountEdit; + } + + /** + * Change customer password in Account Information tab. + * + * @param Customer $initialCustomer + * @param Customer $customer + * @return void + */ + public function test(Customer $initialCustomer, Customer $customer) + { + // Preconditions + $initialCustomer->persist(); + + // Steps + $this->objectManager->create( + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, + ['customer' => $initialCustomer] + )->run(); + + $this->customerAccountEdit->getAccountMenuBlock()->openMenuItem('Account Information'); + $this->customerAccountEdit->getAccountInfoForm()->SetChangeEmail(true); + $this->customerAccountEdit->getAccountInfoForm()->fill($customer); + $this->customerAccountEdit->getAccountInfoForm()->submit(); + } + + /** + * Logout customer from frontend account. + * + * @return void + */ + public function tearDown() + { + $this->objectManager->create(\Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep::class)->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/SecureChangingCustomerEmailTest.xml b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/SecureChangingCustomerEmailTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..dc3ad06e842fd17d9eebb7fd4fdbb2a0815e9d4f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/SecureChangingCustomerEmailTest.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Security\Test\TestCase\SecureChangingCustomerEmailTest" summary="Secure Changing Customer Email" ticketId="MAGETWO-49041"> + <variation name="SecureChangingEmailV1" summary="Change Email checkbox is checked, enter new email, correct password"> + <data name="tag" xsi:type="string">severity:S1</data> + <data name="initialCustomer/dataset" xsi:type="string">default</data> + <data name="customer/data/email" xsi:type="string">JaneDoe_%isolation%@example.com</data> + <data name="customer/data/current_password" xsi:type="string">123123^q</data> + <constraint name="Magento\Customer\Test\Constraint\AssertCustomerInfoSuccessSavedMessage" /> + <constraint name="Magento\Security\Test\Constraint\AssertCustomerEmailChanged" /> + </variation> + <variation name="SecureChangingEmailV2" summary="Change Email checkbox is checked, enter new email, wrong password"> + <data name="tag" xsi:type="string">severity:S2</data> + <data name="initialCustomer/dataset" xsi:type="string">default</data> + <data name="customer/data/email" xsi:type="string">JaneDoe_%isolation%@example.com</data> + <data name="customer/data/current_password" xsi:type="string">123123123</data> + <constraint name="Magento\Customer\Test\Constraint\AssertChangePasswordFailMessage" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/SecureChangingCustomerPasswordTest.php b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/SecureChangingCustomerPasswordTest.php new file mode 100644 index 0000000000000000000000000000000000000000..225ef6b397aa4b3c9cf70d2d0ef32adccb73edf6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/SecureChangingCustomerPasswordTest.php @@ -0,0 +1,91 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Security\Test\TestCase; + +use Magento\Mtf\TestCase\Injectable; +use Magento\Customer\Test\Fixture\Customer; +use Magento\Customer\Test\Page\CustomerAccountEdit; + +/** + * Test Flow: + * + * Preconditions: + * 1. Customer is created + * + * Steps: + * 1. Login to fronted as customer from preconditions + * 2. Navigate to Account Information tab + * 3. Check "Change Password" checkbox + * 4. Fill form according to data set and save + * 5. Perform all assertions + * + * @group Security + * @ZephyrId MAGETWO-49043 + */ +class SecureChangingCustomerPasswordTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const SEVERITY = 'S1'; + /* end tags */ + + /** + * CustomerAccountEdit page. + * + * @var CustomerAccountEdit + */ + protected $customerAccountEdit; + + /** + * Preparing page for test. + * + * @param CustomerAccountEdit $customerAccountEdit + * @return void + */ + public function __inject( + CustomerAccountEdit $customerAccountEdit + ) { + $this->customerAccountEdit = $customerAccountEdit; + } + + /** + * Change customer password in Account Information tab. + * + * @param Customer $initialCustomer + * @param Customer $customer + * @param boolean $check + * @return void + */ + public function test(Customer $initialCustomer, Customer $customer, $check) + { + // Preconditions + $initialCustomer->persist(); + + // Steps + $this->objectManager->create( + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, + ['customer' => $initialCustomer] + )->run(); + + $this->customerAccountEdit->getAccountMenuBlock()->openMenuItem('Account Information'); + if ($check) { + $this->customerAccountEdit->getAccountInfoForm()->SetChangePassword(true); + $this->customerAccountEdit->getAccountInfoForm()->fill($customer); + $this->customerAccountEdit->getAccountInfoForm()->submit(); + } + } + + /** + * Logout customer from frontend account. + * + * @return void + */ + public function tearDown() + { + $this->objectManager->create(\Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep::class)->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/SecureChangingCustomerPasswordTest.xml b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/SecureChangingCustomerPasswordTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..9fc2f50435a98a13ea42f800efd51b503e11d218 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/SecureChangingCustomerPasswordTest.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Security\Test\TestCase\SecureChangingCustomerPasswordTest" summary="Secure Changing Customer Password" ticketId="MAGETWO-49043"> + <variation name="SecureChangingPasswordV1" summary="Change Password checkbox is checked, enter correct password"> + <data name="tag" xsi:type="string">severity:S1</data> + <data name="initialCustomer/dataset" xsi:type="string">default</data> + <data name="customer/data/current_password" xsi:type="string">123123^q</data> + <data name="customer/data/password" xsi:type="string">123123Qa</data> + <data name="customer/data/password_confirmation" xsi:type="string">123123Qa</data> + <data name="check" xsi:type="string">1</data> + <constraint name="Magento\Customer\Test\Constraint\AssertCustomerInfoSuccessSavedMessage" /> + <constraint name="Magento\Customer\Test\Constraint\AssertCustomerPasswordChanged" /> + </variation> + <variation name="SecureChangingPasswordV2" summary="Change Password checkbox is checked, enter wrong password"> + <data name="tag" xsi:type="string">severity:S2</data> + <data name="initialCustomer/dataset" xsi:type="string">default</data> + <data name="customer/data/current_password" xsi:type="string">123123123</data> + <data name="customer/data/password" xsi:type="string">123123Qa</data> + <data name="customer/data/password_confirmation" xsi:type="string">123123Qa</data> + <data name="check" xsi:type="string">1</data> + <constraint name="Magento\Customer\Test\Constraint\AssertChangePasswordFailMessage" /> + </variation> + <variation name="SecureChangingPasswordV3" summary="Change Password checkbox is unchecked"> + <data name="tag" xsi:type="string">severity:S3</data> + <data name="initialCustomer/dataset" xsi:type="string">default</data> + <data name="check" xsi:type="string">0</data> + <constraint name="Magento\Security\Test\Constraint\AssertDefaultAccountInformation" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store/GroupId.php b/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store/GroupId.php index 93bf1a9001cbfcc4825afee549e3873d1d623ae9..a5fa6d4a83cbe63cbcf6d6b15e5935787d5d2694 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store/GroupId.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Fixture/Store/GroupId.php @@ -43,6 +43,15 @@ class GroupId extends DataSource $this->storeGroup = $data['fixture']; $this->data = $this->storeGroup->getWebsiteId() . "/" . $this->storeGroup->getName(); } + + if (isset($data['storeGroup']) && $data['storeGroup'] instanceof StoreGroup) { + $this->storeGroup = $data['storeGroup']; + $this->data = $data['storeGroup']->getWebsiteId() . "/" . $data['storeGroup']->getName(); + } + + if (isset($data['value'])) { + $this->data = $data['value']; + } } /** diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.xml b/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.xml index 12ca9f5e03a20568423ee565030c785e9eec5bba..37faba3d75524304919c65cf391ee4211ef9fdae 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.xml @@ -52,5 +52,14 @@ <field name="code" xsi:type="string">store_%isolation%</field> <field name="is_active" xsi:type="string">Enabled</field> </dataset> + + <dataset name="custom_group_custom_store"> + <field name="group_id" xsi:type="array"> + <item name="dataset" xsi:type="string">custom</item> + </field> + <field name="name" xsi:type="string">Custom_Store_%isolation%</field> + <field name="code" xsi:type="string">code_%isolation%</field> + <field name="is_active" xsi:type="string">Enabled</field> + </dataset> </repository> </config> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest.php index 804111c497cca364fc749a477ee85e356c686d53..56ec632ffd09f6c063d21eb747d114219fe9b022 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest.php @@ -34,6 +34,7 @@ class CreateStoreEntityTest extends Injectable /* tags */ const MVP = 'yes'; const TEST_TYPE = 'acceptance_test, extended_acceptance_test'; + const SEVERITY = 'S0'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest.xml b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest.xml index d0fb3738910cd171f190ee4a5f1c8acc157d298f..26d9aa9beba0acc098558d8fd1f6aacb9083cb5d 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreEntityTest.xml @@ -8,28 +8,27 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Store\Test\TestCase\CreateStoreEntityTest" summary="Create Store View" ticketId="MAGETWO-27647"> <variation name="CreateStoreEntityTestVariation1"> + <data name="tag" xsi:type="string">severity:S1</data> <data name="store/data/group_id/dataset" xsi:type="string">default</data> <data name="store/data/name" xsi:type="string">store_name_%isolation%</data> <data name="store/data/code" xsi:type="string">storecode_%isolation%</data> <data name="store/data/is_active" xsi:type="string">Enabled</data> <constraint name="Magento\Store\Test\Constraint\AssertStoreSuccessSaveMessage" /> - <constraint name="Magento\Store\Test\Constraint\AssertStoreInGrid" /> - <constraint name="Magento\Store\Test\Constraint\AssertStoreForm" /> <constraint name="Magento\Store\Test\Constraint\AssertStoreBackend" /> <constraint name="Magento\Store\Test\Constraint\AssertStoreFrontend" /> </variation> <variation name="CreateStoreEntityTestVariation2"> + <data name="tag" xsi:type="string">severity:S3</data> <data name="store/data/group_id/dataset" xsi:type="string">default</data> <data name="store/data/name" xsi:type="string">store_name_%isolation%</data> <data name="store/data/code" xsi:type="string">storecode_%isolation%</data> <data name="store/data/is_active" xsi:type="string">Disabled</data> <constraint name="Magento\Store\Test\Constraint\AssertStoreSuccessSaveMessage" /> - <constraint name="Magento\Store\Test\Constraint\AssertStoreInGrid" /> - <constraint name="Magento\Store\Test\Constraint\AssertStoreForm" /> <constraint name="Magento\Store\Test\Constraint\AssertStoreBackend" /> <constraint name="Magento\Store\Test\Constraint\AssertStoreNotOnFrontend" /> </variation> <variation name="CreateStoreEntityTestVariation3"> + <data name="tag" xsi:type="string">severity:S1</data> <data name="store/data/group_id/dataset" xsi:type="string">custom</data> <data name="store/data/name" xsi:type="string">store_name_%isolation%</data> <data name="store/data/code" xsi:type="string">storecode_%isolation%</data> @@ -41,7 +40,7 @@ <constraint name="Magento\Store\Test\Constraint\AssertStoreFrontend" /> </variation> <variation name="CreateStoreEntityTestVariation4" summary="Create New Localized Store View" ticketId="MAGETWO-12405"> - <data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test</data> + <data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, severity:S0</data> <data name="store/data/group_id/dataset" xsi:type="string">default</data> <data name="store/data/name" xsi:type="string">DE_%isolation%</data> <data name="store/data/code" xsi:type="string">de_%isolation%</data> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreGroupEntityTest.php index 5d638d781d173ab22923ad2772fd31a984dd944e..76589026b70a031ecea639bb4303b5d38bff9bc0 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreGroupEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreGroupEntityTest.php @@ -29,6 +29,7 @@ class CreateStoreGroupEntityTest extends Injectable { /* tags */ const MVP = 'yes'; + const SEVERITY = 'S1'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreGroupEntityTest.xml b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreGroupEntityTest.xml index d3644ff6ddc59c2efab74f853c48c26ca1780aa8..39adbb9c418403469cfd5f82697619c5d89218be 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreGroupEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateStoreGroupEntityTest.xml @@ -8,15 +8,16 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Store\Test\TestCase\CreateStoreGroupEntityTest" summary="Create Store Group" ticketId="MAGETWO-27345"> <variation name="CreateStoreGroupEntityTestVariation1"> + <data name="tag" xsi:type="string">severity:S1</data> <data name="storeGroup/data/website_id/dataset" xsi:type="string">main_website</data> <data name="storeGroup/data/name" xsi:type="string">store_name_%isolation%</data> <data name="storeGroup/data/root_category_id/dataset" xsi:type="string">default_category</data> <constraint name="Magento\Store\Test\Constraint\AssertStoreGroupSuccessSaveMessage" /> - <constraint name="Magento\Store\Test\Constraint\AssertStoreGroupInGrid" /> <constraint name="Magento\Store\Test\Constraint\AssertStoreGroupForm" /> <constraint name="Magento\Store\Test\Constraint\AssertStoreGroupOnStoreViewForm" /> </variation> <variation name="CreateStoreGroupEntityTestVariation2"> + <data name="tag" xsi:type="string">severity:S1</data> <data name="storeGroup/data/website_id/dataset" xsi:type="string">custom_website</data> <data name="storeGroup/data/name" xsi:type="string">store_name_%isolation%</data> <data name="storeGroup/data/root_category_id/dataset" xsi:type="string">root_category</data> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.php index 766e030b3f61880551fd4b82ffc217ce0aa5179a..3e0b3670f49453c884aa22ce82dbf19eed56cf61 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.php @@ -29,6 +29,7 @@ class CreateWebsiteEntityTest extends Injectable { /* tags */ const MVP = 'yes'; + const SEVERITY = 'S1'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.xml b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.xml index e5ec1371587a6ee52955b5b34a6bdc93be5dfbc6..810a4b9ac88f2840c5b160d36a64540f568a626d 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Store\Test\TestCase\CreateWebsiteEntityTest" summary="Create Website" ticketId="MAGETWO-27665"> <variation name="CreateWebsiteEntityTestVariation1"> + <data name="tag" xsi:type="string">severity:S1</data> <data name="website/data/name" xsi:type="string">website_%isolation%</data> <data name="website/data/code" xsi:type="string">code_%isolation%</data> <constraint name="Magento\Store\Test\Constraint\AssertWebsiteSuccessSaveMessage" /> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.php index cbe261fe750a8c7c8fd61244edd5387aea6152cb..baee46f8697034061b748f4d45b5fe62e72b1f5e 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.php @@ -36,6 +36,7 @@ class DeleteStoreEntityTest extends Injectable { /* tags */ const MVP = 'yes'; + const SEVERITY = 'S2'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.xml b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.xml index 05132aeefda4cd55afea8f9515023cfd9819b3a0..b888ba1f778370d11e19ded0f8c40cfd543541ea 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Store\Test\TestCase\DeleteStoreEntityTest" summary="Delete Store View" ticketId="MAGETWO-27942"> <variation name="DeleteStoreEntityTestVariation1"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="store/dataset" xsi:type="string">custom</data> <data name="createBackup" xsi:type="string">Yes</data> <constraint name="Magento\Store\Test\Constraint\AssertStoreSuccessDeleteAndBackupMessages" /> @@ -16,10 +17,10 @@ <constraint name="Magento\Store\Test\Constraint\AssertStoreNotOnFrontend" /> </variation> <variation name="DeleteStoreEntityTestVariation2"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="store/dataset" xsi:type="string">custom</data> <data name="createBackup" xsi:type="string">No</data> <constraint name="Magento\Store\Test\Constraint\AssertStoreSuccessDeleteMessage" /> - <constraint name="Magento\Store\Test\Constraint\AssertStoreNotInGrid" /> <constraint name="Magento\Store\Test\Constraint\AssertStoreNotOnFrontend" /> </variation> </testCase> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.php index e7ba27b44c1a845bd513a55bf22d042b3100d1cc..5890298650c5c8ddac676d7198f40ba20dc0a26e 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.php @@ -38,6 +38,7 @@ class DeleteStoreGroupEntityTest extends Injectable { /* tags */ const MVP = 'yes'; + const SEVERITY = 'S3'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.xml b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.xml index bbedbfc8d103786cdef08c5a4dbdc1f94d9af8e9..16c0aeb358bb0fe5e7f0e18216300161c6dfbbf1 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Store\Test\TestCase\DeleteStoreGroupEntityTest" summary="Delete Store Group" ticketId="MAGETWO-27596"> <variation name="DeleteStoreGroupEntityTestVariation1"> + <data name="tag" xsi:type="string">severity:S3</data> <data name="storeGroup/dataset" xsi:type="string">custom</data> <data name="createBackup" xsi:type="string">Yes</data> <constraint name="Magento\Store\Test\Constraint\AssertStoreGroupSuccessDeleteAndBackupMessages" /> @@ -15,6 +16,7 @@ <constraint name="Magento\Backup\Test\Constraint\AssertBackupInGrid" /> </variation> <variation name="DeleteStoreGroupEntityTestVariation2"> + <data name="tag" xsi:type="string">severity:S3</data> <data name="storeGroup/dataset" xsi:type="string">custom</data> <data name="createBackup" xsi:type="string">No</data> <constraint name="Magento\Store\Test\Constraint\AssertStoreGroupSuccessDeleteMessage" /> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest.php index 5d4af70cb03e3154364e03611be4347104d09db0..94e14b4a42317edaa2b1f151a3858c770a74fc68 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest.php @@ -38,6 +38,7 @@ class DeleteWebsiteEntityTest extends Injectable { /* tags */ const MVP = 'yes'; + const SEVERITY = 'S3'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest.xml b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest.xml index 93c63d42d4de51df71e8fee8eeb62e2286c7bcfc..21327a0ced20bd407f331d8a15c07e42199dfa0d 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteWebsiteEntityTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Store\Test\TestCase\DeleteWebsiteEntityTest" summary="Delete Website" ticketId="MAGETWO-27723"> <variation name="DeleteWebsiteEntityTestVariation1"> + <data name="tag" xsi:type="string">severity:S3</data> <data name="website/dataset" xsi:type="string">custom_website</data> <data name="createBackup" xsi:type="string">Yes</data> <constraint name="Magento\Store\Test\Constraint\AssertWebsiteSuccessDeleteAndBackupMessages" /> @@ -15,6 +16,7 @@ <constraint name="Magento\Backup\Test\Constraint\AssertBackupInGrid" /> </variation> <variation name="DeleteWebsiteEntityTestVariation2"> + <data name="tag" xsi:type="string">severity:S3</data> <data name="website/dataset" xsi:type="string">custom_website</data> <data name="createBackup" xsi:type="string">No</data> <constraint name="Magento\Store\Test\Constraint\AssertWebsiteSuccessDeleteMessage" /> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/MoveStoreToOtherGroupSameWebsiteTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/MoveStoreToOtherGroupSameWebsiteTest.php new file mode 100644 index 0000000000000000000000000000000000000000..9a335e1cbd0e362cda015be6ae1e309fe1f179f6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/MoveStoreToOtherGroupSameWebsiteTest.php @@ -0,0 +1,107 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Store\Test\TestCase; + +use Magento\Backend\Test\Page\Adminhtml\EditStore; +use Magento\Backend\Test\Page\Adminhtml\StoreIndex; +use Magento\Store\Test\Fixture\Store; +use Magento\Mtf\TestCase\Injectable; +use Magento\Mtf\Fixture\FixtureFactory; + +/** + * Test Move Store view to another store within same website (Store Management) + * + * Test Flow: + * + * Preconditions: + * 1.Create store STA with store view SVA + * 2.Create store STB with store view SVB + * 3.STA and STB belong to the same website + * + * Steps: + * 1. Open Backend + * 2. Go to Stores -> All Stores + * 3. Open store view SVB from grid + * 4. Change store group setting from STB to STA + * 5. Save store entity + * 6. Perform all assertions + * + * @group Store_Management + * @ZephyrId MAGETWO-54026 + */ +class MoveStoreToOtherGroupSameWebsiteTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const SEVERITY = 'S1'; + /* end tags */ + + /** + * Page StoreIndex + * + * @var StoreIndex + */ + protected $storeIndex; + + /** + * Page EditStore + * + * @var EditStore + */ + protected $editStore; + + /** + * Preparing pages for test + * + * @param StoreIndex $storeIndex + * @param EditStore $editStore + * @return void + */ + public function __inject(StoreIndex $storeIndex, EditStore $editStore) + { + $this->storeIndex = $storeIndex; + $this->editStore = $editStore; + } + + /** + * Move store view to another store group within a website + * + * @param FixtureFactory $fixtureFactory + * @param Store $storeInitialA + * @param Store $storeInitialB + * @return array + */ + public function test(FixtureFactory $fixtureFactory, Store $storeInitialA, Store $storeInitialB) + { + // Prepare data for constraints + $store = $fixtureFactory->createByCode( + 'store', + [ + 'data' => [ + 'name' => $storeInitialB->getName(), + 'code' => $storeInitialB->getCode(), + 'is_active' => $storeInitialB->getIsActive(), + 'group_id' => [ + 'storeGroup' => $storeInitialA->getDataFieldConfig('group_id')['source']->getStoreGroup() + ], + ], + ] + ); + + // Preconditions + $storeInitialA->persist(); + $storeInitialB->persist(); + + // Steps + $this->storeIndex->open(); + $this->storeIndex->getStoreGrid()->searchAndOpenStore($storeInitialB); + $this->editStore->getStoreForm()->selectStore($storeInitialA->getGroupId()); + $this->editStore->getFormPageActions()->save(); + + return ['store' => $store]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/MoveStoreToOtherGroupSameWebsiteTest.xml b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/MoveStoreToOtherGroupSameWebsiteTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..d6353d8379532e5b3a77dda4696e214d15663c90 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/MoveStoreToOtherGroupSameWebsiteTest.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Store\Test\TestCase\MoveStoreToOtherGroupSameWebsiteTest" summary="Move Store View" ticketId="MAGETWO-54026"> + <variation name="MoveStoreTestVariation1"> + <data name="storeInitialA/dataset" xsi:type="string">custom_group_custom_store</data> + <data name="storeInitialB/dataset" xsi:type="string">custom_group_custom_store</data> + <constraint name="Magento\Store\Test\Constraint\AssertStoreSuccessSaveMessage" /> + <constraint name="Magento\Store\Test\Constraint\AssertStoreInGrid" /> + <constraint name="Magento\Store\Test\Constraint\AssertStoreForm" /> + <constraint name="Magento\Store\Test\Constraint\AssertStoreBackend" /> + <constraint name="Magento\Store\Test\Constraint\AssertStoreFrontend" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.php index 38250d958bc10273d3918789b6b00559bdf0c567..43a219cba62e6404ae9c690050ff582ad712bd39 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.php @@ -33,6 +33,7 @@ class UpdateStoreEntityTest extends Injectable { /* tags */ const MVP = 'yes'; + const SEVERITY = 'S2'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.xml b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.xml index 92028c303a5292e7130ced0ae2541aa79111fc29..c32df2c53396b37a89b3419891d2c2bc9e3873ac 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreEntityTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Store\Test\TestCase\UpdateStoreEntityTest" summary="Update Store View" ticketId="MAGETWO-27786"> <variation name="UpdateStoreEntityTestVariation1"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="storeInitial/dataset" xsi:type="string">custom</data> <data name="store/data/group_id/dataset" xsi:type="string">default</data> <data name="store/data/name" xsi:type="string">storename_updated%isolation%</data> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.php index 7e9143a5c91df4775bc2222a4281171ffb6681b7..f81d0989e24813cf20e1be734beecc5b5b2c5f32 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.php @@ -34,6 +34,7 @@ class UpdateStoreGroupEntityTest extends Injectable { /* tags */ const MVP = 'yes'; + const SEVERITY = 'S2'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.xml b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.xml index ce1a67575c67588ff4b9af854b579f5d21859f4b..07309135f607a4bc49584e9aa11819358336a984 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateStoreGroupEntityTest.xml @@ -8,16 +8,17 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Store\Test\TestCase\UpdateStoreGroupEntityTest" summary="Update Store Group" ticketId="MAGETWO-27568"> <variation name="UpdateStoreGroupEntityTestVariation1"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="storeGroupOrigin/dataset" xsi:type="string">custom</data> <data name="storeGroup/data/website_id/dataset" xsi:type="string">main_website</data> <data name="storeGroup/data/name" xsi:type="string">store_name_updated_%isolation%</data> <data name="storeGroup/data/root_category_id/dataset" xsi:type="string">default_category</data> <constraint name="Magento\Store\Test\Constraint\AssertStoreGroupSuccessSaveMessage" /> - <constraint name="Magento\Store\Test\Constraint\AssertStoreGroupInGrid" /> <constraint name="Magento\Store\Test\Constraint\AssertStoreGroupForm" /> <constraint name="Magento\Store\Test\Constraint\AssertStoreGroupOnStoreViewForm" /> </variation> <variation name="UpdateStoreGroupEntityTestVariation2"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="storeGroupOrigin/dataset" xsi:type="string">custom</data> <data name="storeGroup/data/website_id/dataset" xsi:type="string">custom_website</data> <data name="storeGroup/data/name" xsi:type="string">store_name_updated_%isolation%</data> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.php b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.php index b187f05856670a1807b904a8b87bfca78ee51357..28fcfd79131faef12d35ad54457deb152b5858ec 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.php @@ -35,6 +35,7 @@ class UpdateWebsiteEntityTest extends Injectable { /* tags */ const MVP = 'yes'; + const SEVERITY = 'S2'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.xml b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.xml index 94f0a891e61ccb6f62563d65a3a0f2c86ed9d1f3..c1b3af6749727a658d8bf3635322bd5da6402567 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Store\Test\TestCase\UpdateWebsiteEntityTest" summary="Update Website" ticketId="MAGETWO-27690"> <variation name="UpdateWebsiteEntityTestVariation1"> + <data name="tag" xsi:type="string">severity:S2</data> <data name="websiteOrigin/dataset" xsi:type="string">custom_website</data> <data name="website/data/name" xsi:type="string">website_upd%isolation%</data> <data name="website/data/code" xsi:type="string">code_upd%isolation%</data> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Store/Test/etc/di.xml new file mode 100644 index 0000000000000000000000000000000000000000..737f33ebebe1f9ec23a4140cc43e74538d6c48a3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Store/Test/etc/di.xml @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> + <type name="Magento\Store\Test\Constraint\AssertStoreBackend"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertStoreForm"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertStoreFrontend"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertStoreGroupForm"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertStoreGroupInGrid"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertStoreGroupNotInGrid"> + <arguments> + <argument name="severity" xsi:type="string">S3</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertStoreGroupOnStoreViewForm"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertStoreGroupSuccessDeleteAndBackupMessages"> + <arguments> + <argument name="severity" xsi:type="string">S3</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertStoreGroupSuccessDeleteMessage"> + <arguments> + <argument name="severity" xsi:type="string">S3</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertStoreGroupSuccessSaveMessage"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertStoreInGrid"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertStoreNotInGrid"> + <arguments> + <argument name="severity" xsi:type="string">S3</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertStoreNotOnFrontend"> + <arguments> + <argument name="severity" xsi:type="string">S3</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertStoreSuccessDeleteAndBackupMessages"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertStoreSuccessDeleteMessage"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertStoreSuccessSaveMessage"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertWebsiteForm"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertWebsiteInGrid"> + <arguments> + <argument name="severity" xsi:type="string">S2</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertWebsiteNotInGrid"> + <arguments> + <argument name="severity" xsi:type="string">S3</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertWebsiteOnStoreForm"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertWebsiteSuccessDeleteAndBackupMessages"> + <arguments> + <argument name="severity" xsi:type="string">S3</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertWebsiteSuccessDeleteMessage"> + <arguments> + <argument name="severity" xsi:type="string">S3</argument> + </arguments> + </type> + <type name="Magento\Store\Test\Constraint\AssertWebsiteSuccessSaveMessage"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> +</config> diff --git a/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/VersionTest.php b/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/VersionTest.php index 30f398b4f6000bdd2824ed19b8c625a6e4e21566..187c043945d059992d6dc59a8713fc413b1a9752 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/VersionTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/VersionTest.php @@ -5,7 +5,8 @@ */ namespace Magento\Framework\App\Test\Unit\View\Deployment; -use \Magento\Framework\App\View\Deployment\Version; +use Magento\Framework\App\View\Deployment\Version; +use Magento\Framework\Exception\FileSystemException; /** * Class VersionTest @@ -18,29 +19,39 @@ class VersionTest extends \PHPUnit_Framework_TestCase private $object; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject */ - private $appState; + private $appStateMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\View\Deployment\Version\StorageInterface|\PHPUnit_Framework_MockObject_MockObject */ - private $versionStorage; + private $versionStorageMock; + + /** + * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $loggerMock; protected function setUp() { - $this->appState = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); - $this->versionStorage = $this->getMock(\Magento\Framework\App\View\Deployment\Version\StorageInterface::class); - $this->object = new Version($this->appState, $this->versionStorage); + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->appStateMock = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); + $this->versionStorageMock = $this->getMock( + \Magento\Framework\App\View\Deployment\Version\StorageInterface::class + ); + $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->object = new Version($this->appStateMock, $this->versionStorageMock); + $objectManager->setBackwardCompatibleProperty($this->object, 'logger', $this->loggerMock); } public function testGetValueDeveloperMode() { - $this->appState + $this->appStateMock ->expects($this->once()) ->method('getMode') ->will($this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER)); - $this->versionStorage->expects($this->never())->method($this->anything()); + $this->versionStorageMock->expects($this->never())->method($this->anything()); $this->assertInternalType('integer', $this->object->getValue()); $this->object->getValue(); // Ensure computation occurs only once and result is cached in memory } @@ -51,12 +62,12 @@ class VersionTest extends \PHPUnit_Framework_TestCase */ public function testGetValueFromStorage($appMode) { - $this->appState + $this->appStateMock ->expects($this->once()) ->method('getMode') ->will($this->returnValue($appMode)); - $this->versionStorage->expects($this->once())->method('load')->will($this->returnValue('123')); - $this->versionStorage->expects($this->never())->method('save'); + $this->versionStorageMock->expects($this->once())->method('load')->will($this->returnValue('123')); + $this->versionStorageMock->expects($this->never())->method('save'); $this->assertEquals('123', $this->object->getValue()); $this->object->getValue(); // Ensure caching in memory } @@ -70,20 +81,106 @@ class VersionTest extends \PHPUnit_Framework_TestCase ]; } - public function testGetValueDefaultModeSaving() - { + /** + * $param bool $isUnexpectedValueExceptionThrown + * $param bool $isFileSystemExceptionThrown + * @dataProvider getValueDefaultModeDataProvider + */ + public function testGetValueDefaultMode( + $isUnexpectedValueExceptionThrown, + $isFileSystemExceptionThrown = null + ) { $versionType = 'integer'; - $this->appState + $this->appStateMock ->expects($this->once()) ->method('getMode') - ->will($this->returnValue(\Magento\Framework\App\State::MODE_DEFAULT)); - $storageException = new \UnexpectedValueException('Does not exist in the storage'); - $this->versionStorage - ->expects($this->once()) - ->method('load') - ->will($this->throwException($storageException)); - $this->versionStorage->expects($this->once())->method('save')->with($this->isType($versionType)); + ->willReturn(\Magento\Framework\App\State::MODE_DEFAULT); + if ($isUnexpectedValueExceptionThrown) { + $storageException = new \UnexpectedValueException('Does not exist in the storage'); + $this->versionStorageMock + ->expects($this->once()) + ->method('load') + ->will($this->throwException($storageException)); + $this->versionStorageMock->expects($this->once()) + ->method('save') + ->with($this->isType($versionType)); + if ($isFileSystemExceptionThrown) { + $fileSystemException = new FileSystemException( + new \Magento\Framework\Phrase('Can not load static content version') + ); + $this->versionStorageMock + ->expects($this->once()) + ->method('save') + ->will($this->throwException($fileSystemException)); + $this->loggerMock->expects($this->once()) + ->method('critical') + ->with('Can not save static content version.'); + } else { + $this->loggerMock->expects($this->never()) + ->method('critical'); + } + } else { + $this->versionStorageMock + ->expects($this->once()) + ->method('load') + ->willReturn(1475779229); + $this->loggerMock->expects($this->never()) + ->method('critical'); + } $this->assertInternalType($versionType, $this->object->getValue()); - $this->object->getValue(); // Ensure caching in memory + $this->object->getValue(); + } + + /** + * @return array + */ + public function getValueDefaultModeDataProvider() + { + return [ + [false], + [true, false], + [true, true] + ]; + } + + /** + * @param bool $isUnexpectedValueExceptionThrown + * @dataProvider getValueProductionModeDataProvider + */ + public function testGetValueProductionMode( + $isUnexpectedValueExceptionThrown + ) { + $this->appStateMock + ->expects($this->once()) + ->method('getMode') + ->willReturn(\Magento\Framework\App\State::MODE_PRODUCTION); + if ($isUnexpectedValueExceptionThrown) { + $storageException = new \UnexpectedValueException('Does not exist in the storage'); + $this->versionStorageMock + ->expects($this->once()) + ->method('load') + ->will($this->throwException($storageException)); + $this->loggerMock->expects($this->once()) + ->method('critical') + ->with('Can not load static content version.'); + } else { + $this->versionStorageMock + ->expects($this->once()) + ->method('load') + ->willReturn(1475779229); + } + $this->assertInternalType('integer', $this->object->getValue()); + $this->object->getValue(); + } + + /** + * @return array + */ + public function getValueProductionModeDataProvider() + { + return [ + [false], + [true], + ]; } } diff --git a/lib/internal/Magento/Framework/App/View/Deployment/Version.php b/lib/internal/Magento/Framework/App/View/Deployment/Version.php index 8e927e47921a0c428493de2bb6e13b17407483ad..7f6dc7fa9285ccc3987d84091bc9edb76d09f794 100644 --- a/lib/internal/Magento/Framework/App/View/Deployment/Version.php +++ b/lib/internal/Magento/Framework/App/View/Deployment/Version.php @@ -6,6 +6,9 @@ namespace Magento\Framework\App\View\Deployment; +use Psr\Log\LoggerInterface; +use Magento\Framework\Exception\FileSystemException; + /** * Deployment version of static files */ @@ -26,6 +29,11 @@ class Version */ private $cachedValue; + /** + * @var LoggerInterface + */ + private $logger; + /** * @param \Magento\Framework\App\State $appState * @param Version\StorageInterface $versionStorage @@ -59,23 +67,49 @@ class Version */ protected function readValue($appMode) { - switch ($appMode) { - case \Magento\Framework\App\State::MODE_DEFAULT: - try { - $result = $this->versionStorage->load(); - } catch (\UnexpectedValueException $e) { - $result = (new \DateTime())->getTimestamp(); - $this->versionStorage->save($result); + if ($appMode == \Magento\Framework\App\State::MODE_DEVELOPER) { + $result = $this->generateVersion(); + } else { + try { + $result = $this->versionStorage->load(); + } catch (\UnexpectedValueException $e) { + $result = $this->generateVersion(); + if ($appMode == \Magento\Framework\App\State::MODE_DEFAULT) { + try { + $this->versionStorage->save($result); + } catch (FileSystemException $e) { + $this->getLogger()->critical('Can not save static content version.'); + } + } else { + $this->getLogger()->critical('Can not load static content version.'); } - break; + } + } + return $result; + } - case \Magento\Framework\App\State::MODE_DEVELOPER: - $result = (new \DateTime())->getTimestamp(); - break; + /** + * Generate version of static content + * + * @return int + */ + private function generateVersion() + { + return time(); + } - default: - $result = $this->versionStorage->load(); + /** + * Get logger + * + * @return LoggerInterface + * @deprecated + */ + private function getLogger() + { + if ($this->logger == null) { + $this->logger = \Magento\Framework\App\ObjectManager::getInstance() + ->get(LoggerInterface::class); } - return $result; + return $this->logger; } }