Skip to content

Commit

Permalink
Merge pull request #881 from magento-epam/pr2
Browse files Browse the repository at this point in the history
[Epam] Extend functional test sprint 2

- MTO-111: [Test] Update Category if Use Category Flat (Cron is ON, "Update on Save" Mode)
- MTO-113: [Test] Captcha on admin login
- MTO-146: [Test] Create offline Order from "Edit Customer" Admin page
- MTO-124: [Constraint] Update Simple Product with enabled Catalog Product Flat
- MTO-142: [Test] Captcha on front login
  • Loading branch information
okolesnyk authored Mar 1, 2017
2 parents 84d382b + f4c5ba1 commit 2efb39f
Show file tree
Hide file tree
Showing 41 changed files with 2,096 additions and 16 deletions.
22 changes: 22 additions & 0 deletions dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class Indexer extends Cli
*/
const PARAM_INDEXER_REINDEX = 'indexer:reindex';

/**
* Parameter for set mode command.
*/
const PARAM_SET_MODE = 'indexer:set-mode';

/**
* Run reindex.
*
Expand All @@ -32,4 +37,21 @@ public function reindex(array $indexes = [])
}
parent::execute(Indexer::PARAM_INDEXER_REINDEX . ' ' . $params);
}

/**
* Run set mode. Example of indexers array:
* [
* [0] => ['indexer' => 'category_flat_data', 'mode' => 'schedule'],
* [1] => ['indexer' => 'catalogrule_product', 'mode' => 'realtime']
* ]
*
* @param array $indexers
* @return void
*/
public function setMode(array $indexers)
{
foreach ($indexers as $indexer) {
parent::execute(Indexer::PARAM_SET_MODE . ' ' . $indexer['mode'] . ' ' . $indexer['indexer']);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace Magento\Backend\Test\Constraint;

use Magento\Backend\Test\Fixture\GlobalSearch;
use Magento\Backend\Test\Page\Adminhtml\Dashboard;
use Magento\Mtf\Constraint\AbstractConstraint;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Captcha\Test\Block\Adminhtml;

use Magento\Mtf\Client\Locator;
use Magento\Backend\Test\Block\Admin\Login;

/**
* Login form for backend user.
*/
class LoginWithCaptcha extends Login
{
/**
* Captcha image selector.
*
* @var string
*/
private $captchaImage = '#backend_login';

/**
* Captcha reload button selector.
*
* @var string
*/
private $captchaReload = '#captcha-reload';

/**
* Return captcha element visibility.
*
* @return bool
*/
public function isVisibleCaptcha()
{
return $this->_rootElement->find($this->captchaImage, Locator::SELECTOR_CSS)->isVisible();
}

/**
* Return captcha reload button element visibility.
*
* @return bool
*/
public function isVisibleCaptchaReloadButton()
{
return $this->_rootElement->find($this->captchaReload, Locator::SELECTOR_CSS)->isVisible();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" ?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<mapping strict="1">
<wrapper>login</wrapper>
<fields>
<username>
<selector>#username</selector>
</username>
<password>
<selector>#login</selector>
</password>
<captcha>
<selector>#captcha</selector>
</captcha>
</fields>
</mapping>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Captcha\Test\Block\Form;

use Magento\Mtf\Client\Locator;
use Magento\Customer\Test\Block\Form\Login;
use Magento\Mtf\Client\ElementInterface;

/**
* Form for storefront login with captcha.
*/
class LoginWithCaptcha extends Login
{
/**
* Captcha image selector.
*
* @var string
*/
private $captchaImage = '.captcha-img';

/**
* Captcha reload button selector.
*
* @var string
*/
private $captchaReload = '.captcha-reload';

/**
* Get captcha element visibility.
*
* @return bool
*/
public function isVisibleCaptcha()
{
return $this->_rootElement->find($this->captchaImage, Locator::SELECTOR_CSS)->isVisible();
}

/**
* Get captcha reload button element visibility.
*
* @return bool
*/
public function isVisibleCaptchaReloadButton()
{
return $this->_rootElement->find($this->captchaReload, Locator::SELECTOR_CSS)->isVisible();
}

/**
* Click on reload captcha button.
*
* @return void
*/
public function clickReloadCaptchaButton()
{
$this->_rootElement->find($this->captchaReload, Locator::SELECTOR_CSS)->click();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" ?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<mapping strict="1">
<wrapper>login</wrapper>
<fields>
<email>
<selector>[name='login[username]']</selector>
</email>
<password />
<captcha>
<selector>[name='captcha[user_login]']</selector>
</captcha>
</fields>
</mapping>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Captcha\Test\Constraint;

use Magento\Captcha\Test\Page\Captcha\AdminAuthLoginWithCaptcha;
use Magento\Mtf\Constraint\AbstractConstraint;

/**
* Assert captcha on backend login page.
*/
class AssertCaptchaFieldOnBackend extends AbstractConstraint
{
/**
* Assert captcha and reload button are visible on backend login page.
*
* @param AdminAuthLoginWithCaptcha $adminAuthLogin
* @return void
*/
public function processAssert(AdminAuthLoginWithCaptcha $adminAuthLogin)
{
\PHPUnit_Framework_Assert::assertTrue(
$adminAuthLogin->getLoginBlockWithCaptcha()->isVisibleCaptcha(),
'Captcha image is not present on backend login page.'
);

\PHPUnit_Framework_Assert::assertTrue(
$adminAuthLogin->getLoginBlockWithCaptcha()->isVisibleCaptchaReloadButton(),
'Captcha reload button is not present on backend login page.'
);
}

/**
* Returns a string representation of the object.
*
* @return string
*/
public function toString()
{
return 'Captcha and reload button are presents on backend login page.';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Captcha\Test\Constraint;

use Magento\Customer\Test\Page\CustomerAccountLogin;
use Magento\Mtf\Constraint\AbstractConstraint;

/**
* Assert captcha on storefront login page.
*/
class AssertCaptchaFieldOnStorefront extends AbstractConstraint
{
/**
* Assert captcha and reload button are visible on storefront login page.
*
* @param CustomerAccountLogin $loginPage
* @return void
*/
public function processAssert(CustomerAccountLogin $loginPage)
{
\PHPUnit_Framework_Assert::assertTrue(
$loginPage->getLoginBlockWithCaptcha()->isVisibleCaptcha(),
'Captcha image is not present on storefront login page.'
);

\PHPUnit_Framework_Assert::assertTrue(
$loginPage->getLoginBlockWithCaptcha()->isVisibleCaptchaReloadButton(),
'Captcha reload button is not present on storefront login page.'
);
}

/**
* Returns a string representation of the object.
*
* @return string
*/
public function toString()
{
return 'Captcha and reload button are presents on storefront login page.';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. 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/fixture.xsd">
<fixture name="customer">
<field name="captcha" is_required="0" />
</fixture>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. 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/fixture.xsd">
<fixture name="user">
<field name="captcha" is_required="0" />
</fixture>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. 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/pages.xsd">
<page name="AdminAuthLoginWithCaptcha" area="Captcha" mca="admin/auth/login" module="Magento_Captcha">
<block name="loginBlockWithCaptcha" class="Magento\Captcha\Test\Block\Adminhtml\LoginWithCaptcha" locator="#login-form" strategy="css selector"/>
</page>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. 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/pages.xsd">
<page name="CustomerAccountLogin">
<block name="loginBlockWithCaptcha" class="Magento\Captcha\Test\Block\Form\LoginWithCaptcha" locator="#login-form" strategy="css selector"/>
</page>
</config>
Loading

0 comments on commit 2efb39f

Please sign in to comment.