Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into MAGETWO-58017-gi…
Browse files Browse the repository at this point in the history
…thub-error-creating-configurable-products
  • Loading branch information
melnikovi committed Oct 7, 2016
2 parents edfb0ab + 2d8fb52 commit 75e550e
Show file tree
Hide file tree
Showing 38 changed files with 912 additions and 18 deletions.
5 changes: 4 additions & 1 deletion app/code/Magento/CatalogInventory/Helper/Stock.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ public function addIsInStockFilterToCollection($collection)
\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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -32,4 +39,16 @@ public function isStoreVisible($name)
{
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);
}
}
Original file line number Diff line number Diff line change
@@ -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.';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ class AssertCmsPagePreview extends AbstractConstraint
* @param FrontCmsPage $frontCmsPage
* @param CmsPage $cms
* @param BrowserInterface $browser
* @param string $displayContent
* @return void
*/
public function processAssert(
CmsPageIndex $cmsIndex,
FrontCmsIndex $frontCmsIndex,
FrontCmsPage $frontCmsPage,
CmsPage $cms,
BrowserInterface $browser
BrowserInterface $browser,
$displayContent = null
) {
$cmsIndex->open();
$filter = ['title' => $cms->getTitle()];
Expand All @@ -46,7 +48,7 @@ public function processAssert(

$fixtureContent = $cms->getContent();
\PHPUnit_Framework_Assert::assertContains(
$fixtureContent['content'],
$displayContent != null ? $displayContent : $fixtureContent['content'],
$frontCmsPage->getCmsPageBlock()->getPageContent(),
'Wrong content is displayed.'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=&apos;Magento\Framework\View\Element\Text&apos; text=&apos;bla bla bla&apos; cache_key=&apos;BACKEND_ACL_RESOURCES&apos; 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>
74 changes: 67 additions & 7 deletions dev/tests/functional/tests/app/Magento/Cms/Test/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,92 @@ public function getLastName()
$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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Loading

0 comments on commit 75e550e

Please sign in to comment.