Skip to content

Commit 166bab6

Browse files
Merge branch 'develop' of github.com:magento/magento2ce into pr3
# Conflicts: # dev/tests/functional/tests/app/Magento/Captcha/Test/Block/Form/LoginWithCaptcha.php # dev/tests/functional/tests/app/Magento/Captcha/Test/Page/CustomerAccountLogin.xml # dev/tests/functional/tests/app/Magento/Captcha/Test/Repository/ConfigData.xml
2 parents 7cb9bfd + a005167 commit 166bab6

File tree

36 files changed

+1929
-12
lines changed

36 files changed

+1929
-12
lines changed

dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli/Indexer.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ class Indexer extends Cli
1818
*/
1919
const PARAM_INDEXER_REINDEX = 'indexer:reindex';
2020

21+
/**
22+
* Parameter for set mode command.
23+
*/
24+
const PARAM_SET_MODE = 'indexer:set-mode';
25+
2126
/**
2227
* Run reindex.
2328
*
@@ -32,4 +37,21 @@ public function reindex(array $indexes = [])
3237
}
3338
parent::execute(Indexer::PARAM_INDEXER_REINDEX . ' ' . $params);
3439
}
40+
41+
/**
42+
* Run set mode. Example of indexers array:
43+
* [
44+
* [0] => ['indexer' => 'category_flat_data', 'mode' => 'schedule'],
45+
* [1] => ['indexer' => 'catalogrule_product', 'mode' => 'realtime']
46+
* ]
47+
*
48+
* @param array $indexers
49+
* @return void
50+
*/
51+
public function setMode(array $indexers)
52+
{
53+
foreach ($indexers as $indexer) {
54+
parent::execute(Indexer::PARAM_SET_MODE . ' ' . $indexer['mode'] . ' ' . $indexer['indexer']);
55+
}
56+
}
3557
}

dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertBackendPageIsAvailable.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Magento\Backend\Test\Constraint;
88

9-
use Magento\Backend\Test\Fixture\GlobalSearch;
109
use Magento\Backend\Test\Page\Adminhtml\Dashboard;
1110
use Magento\Mtf\Constraint\AbstractConstraint;
1211

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Captcha\Test\Block\Adminhtml;
8+
9+
use Magento\Mtf\Client\Locator;
10+
use Magento\Backend\Test\Block\Admin\Login;
11+
12+
/**
13+
* Login form for backend user.
14+
*/
15+
class LoginWithCaptcha extends Login
16+
{
17+
/**
18+
* Captcha image selector.
19+
*
20+
* @var string
21+
*/
22+
private $captchaImage = '#backend_login';
23+
24+
/**
25+
* Captcha reload button selector.
26+
*
27+
* @var string
28+
*/
29+
private $captchaReload = '#captcha-reload';
30+
31+
/**
32+
* Return captcha element visibility.
33+
*
34+
* @return bool
35+
*/
36+
public function isVisibleCaptcha()
37+
{
38+
return $this->_rootElement->find($this->captchaImage, Locator::SELECTOR_CSS)->isVisible();
39+
}
40+
41+
/**
42+
* Return captcha reload button element visibility.
43+
*
44+
* @return bool
45+
*/
46+
public function isVisibleCaptchaReloadButton()
47+
{
48+
return $this->_rootElement->find($this->captchaReload, Locator::SELECTOR_CSS)->isVisible();
49+
}
50+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" ?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<mapping strict="1">
9+
<wrapper>login</wrapper>
10+
<fields>
11+
<username>
12+
<selector>#username</selector>
13+
</username>
14+
<password>
15+
<selector>#login</selector>
16+
</password>
17+
<captcha>
18+
<selector>#captcha</selector>
19+
</captcha>
20+
</fields>
21+
</mapping>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Captcha\Test\Constraint;
8+
9+
use Magento\Captcha\Test\Page\Captcha\AdminAuthLoginWithCaptcha;
10+
use Magento\Mtf\Constraint\AbstractConstraint;
11+
12+
/**
13+
* Assert captcha on backend login page.
14+
*/
15+
class AssertCaptchaFieldOnBackend extends AbstractConstraint
16+
{
17+
/**
18+
* Assert captcha and reload button are visible on backend login page.
19+
*
20+
* @param AdminAuthLoginWithCaptcha $adminAuthLogin
21+
* @return void
22+
*/
23+
public function processAssert(AdminAuthLoginWithCaptcha $adminAuthLogin)
24+
{
25+
\PHPUnit_Framework_Assert::assertTrue(
26+
$adminAuthLogin->getLoginBlockWithCaptcha()->isVisibleCaptcha(),
27+
'Captcha image is not present on backend login page.'
28+
);
29+
30+
\PHPUnit_Framework_Assert::assertTrue(
31+
$adminAuthLogin->getLoginBlockWithCaptcha()->isVisibleCaptchaReloadButton(),
32+
'Captcha reload button is not present on backend login page.'
33+
);
34+
}
35+
36+
/**
37+
* Returns a string representation of the object.
38+
*
39+
* @return string
40+
*/
41+
public function toString()
42+
{
43+
return 'Captcha and reload button are presents on backend login page.';
44+
}
45+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Captcha\Test\Constraint;
8+
9+
use Magento\Customer\Test\Page\CustomerAccountLogin;
10+
use Magento\Mtf\Constraint\AbstractConstraint;
11+
12+
/**
13+
* Assert captcha on storefront login page.
14+
*/
15+
class AssertCaptchaFieldOnStorefront extends AbstractConstraint
16+
{
17+
/**
18+
* Assert captcha and reload button are visible on storefront login page.
19+
*
20+
* @param CustomerAccountLogin $loginPage
21+
* @return void
22+
*/
23+
public function processAssert(CustomerAccountLogin $loginPage)
24+
{
25+
\PHPUnit_Framework_Assert::assertTrue(
26+
$loginPage->getLoginBlockWithCaptcha()->isVisibleCaptcha(),
27+
'Captcha image is not present on storefront login page.'
28+
);
29+
30+
\PHPUnit_Framework_Assert::assertTrue(
31+
$loginPage->getLoginBlockWithCaptcha()->isVisibleCaptchaReloadButton(),
32+
'Captcha reload button is not present on storefront login page.'
33+
);
34+
}
35+
36+
/**
37+
* Returns a string representation of the object.
38+
*
39+
* @return string
40+
*/
41+
public function toString()
42+
{
43+
return 'Captcha and reload button are presents on storefront login page.';
44+
}
45+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd">
9+
<fixture name="user">
10+
<field name="captcha" is_required="0" />
11+
</fixture>
12+
</config>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd">
9+
<page name="AdminAuthLoginWithCaptcha" area="Captcha" mca="admin/auth/login" module="Magento_Captcha">
10+
<block name="loginBlockWithCaptcha" class="Magento\Captcha\Test\Block\Adminhtml\LoginWithCaptcha" locator="#login-form" strategy="css selector"/>
11+
</page>
12+
</config>
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Captcha\Test\TestCase;
8+
9+
use Magento\Mtf\TestCase\Injectable;
10+
use Magento\Mtf\TestStep\TestStepFactory;
11+
use Magento\User\Test\Fixture\User;
12+
use Magento\Captcha\Test\Constraint\AssertCaptchaFieldOnBackend;
13+
use Magento\Captcha\Test\Page\Captcha\AdminAuthLoginWithCaptcha;
14+
use Magento\Backend\Test\Page\Adminhtml\SystemConfigEdit;
15+
16+
/**
17+
* Check CAPTCHA on Admin Login Page.
18+
*
19+
* Preconditions:
20+
* 1. Enable CAPTCHA for admin.
21+
*
22+
* Test Flow:
23+
* 1. Open backend login form.
24+
* 2. Log in using captcha.
25+
* 3. Perform asserts.
26+
*
27+
* @group Captcha
28+
* @ZephyrId MAGETWO-43639
29+
*/
30+
class CaptchaOnAdminLoginTest extends Injectable
31+
{
32+
/**
33+
* Step factory.
34+
*
35+
* @var TestStepFactory
36+
*/
37+
private $stepFactory;
38+
39+
/**
40+
* Assert Captcha.
41+
*
42+
* @var AssertCaptchaFieldOnBackend
43+
*/
44+
private $assertCaptcha;
45+
46+
/**
47+
* Admin login page.
48+
*
49+
* @var AdminAuthLoginWithCaptcha
50+
*/
51+
protected $adminAuthWithCaptcha;
52+
53+
/**
54+
* System configuration page.
55+
*
56+
* @var SystemConfigEdit
57+
*/
58+
private $systemConfigEditPage;
59+
60+
/**
61+
* Configuration setting.
62+
*
63+
* @var string
64+
*/
65+
private $configData;
66+
67+
/**
68+
* Injection data.
69+
*
70+
* @param AdminAuthLoginWithCaptcha $adminAuthWithCaptcha
71+
* @param TestStepFactory $stepFactory
72+
* @param AssertCaptchaFieldOnBackend $assertCaptcha
73+
* @param SystemConfigEdit $systemConfigEditPage
74+
* @return void
75+
*/
76+
public function __inject(
77+
AdminAuthLoginWithCaptcha $adminAuthWithCaptcha,
78+
TestStepFactory $stepFactory,
79+
AssertCaptchaFieldOnBackend $assertCaptcha,
80+
SystemConfigEdit $systemConfigEditPage
81+
) {
82+
$this->stepFactory = $stepFactory;
83+
$this->adminAuthWithCaptcha = $adminAuthWithCaptcha;
84+
$this->assertCaptcha = $assertCaptcha;
85+
$this->systemConfigEditPage = $systemConfigEditPage;
86+
}
87+
88+
/**
89+
* Login user on backend.
90+
*
91+
* @param User $customAdmin
92+
* @param string $configData
93+
* @return void
94+
*/
95+
public function test(
96+
User $customAdmin,
97+
$configData
98+
) {
99+
$this->configData = $configData;
100+
$customAdmin->persist();
101+
102+
// Preconditions
103+
$this->stepFactory->create(
104+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
105+
['configData' => $this->configData]
106+
)->run();
107+
108+
$this->adminAuthWithCaptcha->open();
109+
$this->adminAuthWithCaptcha->getLoginBlockWithCaptcha()->fill($customAdmin);
110+
$this->assertCaptcha->processAssert($this->adminAuthWithCaptcha);
111+
$this->adminAuthWithCaptcha->getLoginBlockWithCaptcha()->submit();
112+
}
113+
114+
/**
115+
* Set default configuration.
116+
*
117+
* @return void
118+
*/
119+
public function tearDown()
120+
{
121+
$this->systemConfigEditPage->open();
122+
$this->systemConfigEditPage->getForm()
123+
->getGroup('admin', 'captcha')->setValue('admin', 'captcha', 'enable', 'No');
124+
$this->systemConfigEditPage->getPageActions()->save();
125+
}
126+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/variations.xsd">
9+
<testCase name="Magento\Captcha\Test\TestCase\CaptchaOnAdminLoginTest" summary="Check CAPTCHA on Admin Login Page" ticketId="MAGETWO-43639">
10+
<variation name="CaptchaOnAdminLoginTestVariation1">
11+
<data name="customAdmin/dataset" xsi:type="string">custom_admin_with_default_role</data>
12+
<data name="customAdmin/data/captcha" xsi:type="string">111</data>
13+
<data name="pageTitle" xsi:type="string">Dashboard</data>
14+
<data name="configData" xsi:type="string">captcha_backend_login</data>
15+
<constraint name="Magento\Backend\Test\Constraint\AssertBackendPageIsAvailable"/>
16+
</variation>
17+
</testCase>
18+
</config>

0 commit comments

Comments
 (0)