Skip to content

Commit af5ee20

Browse files
authored
Merge pull request #782 from magento-qmt/Stabilization
[Mavericks] Extend functional tests coverage Tasks: - MTA-3969: Add variatioh for Checkouta with Braintreep Credit Cardp with specificy allowed credit card types - MTA-3970: Add variatiob for Checkouti with Braintreer Credit Cardt with specifich allowed countries - MTA-3971: Add variatiod for Checkouta with Braintreey Credit Card with specific allowed credit card types per country - MTA-3972: Add variatiol for Registerede Checkout withn Braintree Credita Card from Storefront with Advanced Fraud Protection - MTA-3996: Create util for troubleshooting analysis with functional test execution - MTA-3968: Add variation for Registered Checkout with Braintree Credit Card from Storefront with virtual quote and CVV Verification = No
2 parents ca2ade1 + 61fcafd commit af5ee20

38 files changed

+1773
-25
lines changed

dev/tests/functional/.htaccess.sample

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
##############################################
2-
## Allow access to command.php and website.php
3-
<FilesMatch "command.php|website.php|export.php|pathChecker.php|deleteMagentoGeneratedCode.php">
2+
## Allow access to command.php, website.php, export.php, pathChecker.php, deleteMagentoGeneratedCode.php and log.php
3+
<FilesMatch "command.php|website.php|export.php|pathChecker.php|deleteMagentoGeneratedCode.php|log.php">
44
order allow,deny
55
allow from all
66
</FilesMatch>

dev/tests/functional/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require": {
3-
"magento/mtf": "1.0.0-rc52",
3+
"magento/mtf": "1.0.0-rc53",
44
"php": "~5.6.5|7.0.2|~7.0.6",
55
"phpunit/phpunit": "~4.8.0|~5.5.0",
66
"phpunit/phpunit-selenium": ">=1.2"

dev/tests/functional/etc/di.xml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<preference for="Magento\Mtf\Console\CommandListInterface" type="Magento\Mtf\Console\CommandList" />
910
<preference for="Magento\Mtf\Util\Command\File\ExportInterface" type="\Magento\Mtf\Util\Command\File\Export" />
1011
<preference for="Magento\Mtf\Util\Command\File\Export\ReaderInterface" type="\Magento\Mtf\Util\Command\File\Export\Reader" />
1112

@@ -19,6 +20,84 @@
1920

2021
<type name="Magento\Mtf\Util\Protocol\CurlTransport\WebapiDecorator" shared="true" />
2122

23+
<type name="Magento\Mtf\Console\CommandList">
24+
<arguments>
25+
<argument name="commands" xsi:type="array">
26+
<item name="check-magento-storefront" xsi:type="object">Magento\Mtf\Troubleshooting\StorefrontAnalyzer</item>
27+
<item name="check-phpunit-config-file" xsi:type="object">Magento\Mtf\Troubleshooting\PhpUnitAnalyzer</item>
28+
<item name="check-magento-admin" xsi:type="object">Magento\Mtf\Troubleshooting\AdminAnalyzer</item>
29+
<item name="apply-magento-configuration" xsi:type="object">Magento\Mtf\Troubleshooting\Configuration</item>
30+
<item name="check-selenium-session-connection" xsi:type="object">Magento\Mtf\Troubleshooting\SeleniumSessionAnalyzer</item>
31+
<item name="generate-static-classes" xsi:type="object">Magento\Mtf\Troubleshooting\StaticClassesGenerator</item>
32+
<item name="check-config-valid" xsi:type="object">Magento\Mtf\Troubleshooting\ConfigAnalyzer</item>
33+
<item name="check-htaccess" xsi:type="object">Magento\Mtf\Troubleshooting\HtaccessAnalyzer</item>
34+
<item name="check-all" xsi:type="object">Magento\Mtf\Troubleshooting\GlobalAnalyzer</item>
35+
</argument>
36+
</arguments>
37+
</type>
38+
39+
<type name="Magento\Mtf\Troubleshooting\GlobalAnalyzer">
40+
<arguments>
41+
<argument name="commandList" xsi:type="array">
42+
<item name="0" xsi:type="object">Magento\Mtf\Troubleshooting\PhpUnitAnalyzer</item>
43+
<item name="1" xsi:type="object">Magento\Mtf\Troubleshooting\StorefrontAnalyzer</item>
44+
<item name="2" xsi:type="object">Magento\Mtf\Troubleshooting\ConfigAnalyzer</item>
45+
<item name="3" xsi:type="object">Magento\Mtf\Troubleshooting\AdminAnalyzer</item>
46+
<item name="4" xsi:type="object">Magento\Mtf\Troubleshooting\Configuration</item>
47+
<item name="5" xsi:type="object">Magento\Mtf\Troubleshooting\HtaccessAnalyzer</item>
48+
<item name="6" xsi:type="object">Magento\Mtf\Troubleshooting\StaticClassesGenerator</item>
49+
<item name="7" xsi:type="object">Magento\Mtf\Troubleshooting\SeleniumSessionAnalyzer</item>
50+
</argument>
51+
</arguments>
52+
</type>
53+
54+
<type name="Magento\Mtf\Troubleshooting\ConfigAnalyzer">
55+
<arguments>
56+
<argument name="configXml" xsi:type="object">Magento\Mtf\Util\Troubleshooting\GlobalConfig</argument>
57+
<argument name="configXmlDist" xsi:type="object">Magento\Mtf\Util\Troubleshooting\GlobalConfigDist</argument>
58+
</arguments>
59+
</type>
60+
61+
<virtualType name="Magento\Mtf\Util\Troubleshooting\Config" type="Magento\Mtf\Config\Reader\Filesystem">
62+
<arguments>
63+
<argument name="fileResolver" xsi:type="object">Magento\Mtf\Config\FileResolver\Primary</argument>
64+
<argument name="converter" xsi:type="object">Magento\Mtf\Config\Converter</argument>
65+
<argument name="schemaLocator" xsi:type="object">Magento\Mtf\Config\SchemaLocator\Config</argument>
66+
<argument name="idAttributes" xsi:type="array">
67+
<item name="/config" xsi:type="string">scope</item>
68+
<item name="/config/server/item" xsi:type="string">name</item>
69+
</argument>
70+
<argument name="fileName" xsi:type="string">config.xml</argument>
71+
<argument name="defaultScope" xsi:type="string">etc</argument>
72+
</arguments>
73+
</virtualType>
74+
75+
<virtualType name="Magento\Mtf\Util\Troubleshooting\GlobalConfig" type="Magento\Mtf\Config\Data">
76+
<arguments>
77+
<argument name="reader" xsi:type="object">Magento\Mtf\Util\Troubleshooting\Config</argument>
78+
</arguments>
79+
</virtualType>
80+
81+
<virtualType name="Magento\Mtf\Util\Troubleshooting\ConfigDist" type="Magento\Mtf\Config\Reader\Filesystem">
82+
<arguments>
83+
<argument name="fileResolver" xsi:type="object">Magento\Mtf\Config\FileResolver\ScopeConfig</argument>
84+
<argument name="converter" xsi:type="object">Magento\Mtf\Config\Converter</argument>
85+
<argument name="schemaLocator" xsi:type="object">Magento\Mtf\Config\SchemaLocator\Config</argument>
86+
<argument name="idAttributes" xsi:type="array">
87+
<item name="/config" xsi:type="string">scope</item>
88+
<item name="/config/server/item" xsi:type="string">name</item>
89+
</argument>
90+
<argument name="fileName" xsi:type="string">config.xml.dist</argument>
91+
<argument name="defaultScope" xsi:type="string">etc</argument>
92+
</arguments>
93+
</virtualType>
94+
95+
<virtualType name="Magento\Mtf\Util\Troubleshooting\GlobalConfigDist" type="Magento\Mtf\Config\Data">
96+
<arguments>
97+
<argument name="reader" xsi:type="object">Magento\Mtf\Util\Troubleshooting\ConfigDist</argument>
98+
</arguments>
99+
</virtualType>
100+
22101
<type name="Magento\Mtf\Util\Command\File\Export\Reader">
23102
<arguments>
24103
<argument name="template" xsi:type="string">\w*?\.csv</argument>

dev/tests/functional/lib/Magento/Mtf/App/State/State1.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,51 @@
66

77
namespace Magento\Mtf\App\State;
88

9+
use Magento\Mtf\ObjectManager;
10+
use Magento\Mtf\Util\Protocol\CurlInterface;
11+
use Magento\Mtf\Util\Protocol\CurlTransport;
12+
913
/**
1014
* Example Application State class.
1115
*/
1216
class State1 extends AbstractState
1317
{
18+
/**
19+
* Object Manager.
20+
*
21+
* @var ObjectManager
22+
*/
23+
protected $objectManager;
24+
1425
/**
1526
* Data for configuration state.
1627
*
1728
* @var string
1829
*/
1930
protected $config ='admin_session_lifetime_1_hour, wysiwyg_disabled, admin_account_sharing_enable, log_to_file';
2031

32+
/**
33+
* HTTP CURL Adapter.
34+
*
35+
* @var CurlTransport
36+
*/
37+
private $curlTransport;
38+
39+
/**
40+
* @param ObjectManager $objectManager
41+
* @param CurlTransport $curlTransport
42+
* @param array $arguments
43+
*/
44+
public function __construct(
45+
ObjectManager $objectManager,
46+
CurlTransport $curlTransport,
47+
array $arguments
48+
) {
49+
parent::__construct($objectManager, $arguments);
50+
$this->objectManager = $objectManager;
51+
$this->curlTransport = $curlTransport;
52+
}
53+
2154
/**
2255
* Apply set up configuration profile.
2356
*
@@ -26,7 +59,9 @@ class State1 extends AbstractState
2659
public function apply()
2760
{
2861
parent::apply();
29-
if (file_exists(dirname(dirname(dirname(MTF_BP))) . '/app/etc/config.php')) {
62+
$this->curlTransport->write($_ENV['app_frontend_url'], [], CurlInterface::GET);
63+
$response = $this->curlTransport->read();
64+
if (strpos($response, 'Home Page') !== false) {
3065
$this->objectManager->create(
3166
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
3267
['configData' => $this->config]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Mtf\Config\FileResolver;
8+
9+
use Magento\Mtf\Util\Iterator\File;
10+
11+
/**
12+
* Provides MTF configuration file from specified scope.
13+
*/
14+
class ScopeConfig extends Primary
15+
{
16+
/**
17+
* Retrieve the configuration file with given name that relate to MTF global configuration.
18+
*
19+
* @param string $filename
20+
* @param string $scope
21+
* @return File|array
22+
*/
23+
public function get($filename, $scope)
24+
{
25+
return new File([MTF_BP . DIRECTORY_SEPARATOR . $scope . DIRECTORY_SEPARATOR . $filename]);
26+
}
27+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Mtf\Troubleshooting;
8+
9+
use Magento\Mtf\ObjectManagerInterface;
10+
use Magento\Mtf\Troubleshooting\Helper\UrlAnalyzer;
11+
use Magento\Mtf\Util\Protocol\CurlTransport;
12+
use Magento\Mtf\Util\Protocol\CurlTransport\BackendDecorator;
13+
use Symfony\Component\Console\Input\InputInterface;
14+
use Symfony\Component\Console\Output\OutputInterface;
15+
16+
/**
17+
* Analyze Magento Admin.
18+
*/
19+
class AdminAnalyzer extends \Symfony\Component\Console\Command\Command
20+
{
21+
/**
22+
* Console output of formatted messages.
23+
*
24+
* @var \Magento\Mtf\Console\Output
25+
*/
26+
private $output;
27+
28+
/**
29+
* Object manager instance.
30+
*
31+
* @var ObjectManagerInterface
32+
*/
33+
private $objectManager;
34+
35+
/**
36+
* Url analyzer helper.
37+
*
38+
* @var UrlAnalyzer
39+
*/
40+
private $urlAnalyzer;
41+
42+
/**
43+
* @param ObjectManagerInterface $objectManager
44+
* @param UrlAnalyzer $urlAnalyzer
45+
*/
46+
public function __construct(
47+
ObjectManagerInterface $objectManager,
48+
UrlAnalyzer $urlAnalyzer
49+
) {
50+
parent::__construct();
51+
$this->objectManager = $objectManager;
52+
$this->urlAnalyzer = $urlAnalyzer;
53+
}
54+
55+
/**
56+
* Configure command.
57+
*
58+
* @return void
59+
*/
60+
protected function configure()
61+
{
62+
parent::configure();
63+
$this->setName('troubleshooting:check-magento-admin')
64+
->setDescription('Check that app_backend_url is correct and admin can log in to Admin.');
65+
}
66+
67+
/**
68+
* Execute command.
69+
*
70+
* @param InputInterface $input
71+
* @param OutputInterface $output
72+
* @return void
73+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
74+
*/
75+
protected function execute(InputInterface $input, OutputInterface $output)
76+
{
77+
\PHPUnit_Util_Configuration::getInstance(MTF_PHPUNIT_FILE)->handlePHPConfiguration();
78+
$this->output = $this->objectManager->create(
79+
\Magento\Mtf\Console\Output::class,
80+
['output' => $output]
81+
);
82+
$this->output->writeln("Verifying Magento Admin...");
83+
$adminUrlAnalyzerMessages = $this->runAdminUrlAnalyzer();
84+
if (isset($adminUrlAnalyzerMessages['error']) === false) {
85+
$this->output->outputMessages($this->urlAnalyzer->checkDomain($_ENV['app_backend_url']));
86+
} else {
87+
$this->output->outputMessages($adminUrlAnalyzerMessages);
88+
}
89+
$this->output->writeln("Admin verification finished.");
90+
}
91+
92+
/**
93+
* Execute Admin url analyzer check.
94+
*
95+
* @return null|array
96+
*/
97+
public function runAdminUrlAnalyzer()
98+
{
99+
if (!isset($_ENV['app_backend_url'])) {
100+
$messages['error'][] = 'app_backend_url parameter is absent in the phpunit.xml file. '
101+
. 'Please, copy parameter from phpunit.xml.dist.';
102+
return $messages;
103+
}
104+
$this->output->outputMessages($this->urlAnalyzer->fixLastSlash('app_backend_url'));
105+
$url1 = $_ENV['app_backend_url'];
106+
if (strpos($url1, '/index.php') !== false) {
107+
$url2 = str_replace('/index.php', '', $url1);
108+
} else {
109+
$pattern = '/(\/\w+\/)$/';
110+
$replacement = '/index.php$1';
111+
$url2 = str_replace($url1, preg_replace($pattern, $replacement, $url1), $url1);
112+
}
113+
$urls = [$url1, $url2];
114+
$isUrlValid = false;
115+
foreach ($urls as $url) {
116+
$_ENV['app_backend_url'] = $url;
117+
try {
118+
$config = \Magento\Mtf\ObjectManagerFactory::getObjectManager()->create(
119+
\Magento\Mtf\Config\DataInterface::class
120+
);
121+
$curl = new BackendDecorator(new CurlTransport(), $config);
122+
$response = $curl->read();
123+
if (strpos($response, '404') !== false) {
124+
break;
125+
}
126+
$curl->close();
127+
$isUrlValid = true;
128+
break;
129+
} catch (\Exception $e) {
130+
continue;
131+
}
132+
}
133+
if ($isUrlValid == false) {
134+
$messages['error'][] = 'Check correctness of app_backend_url in phpunit.xml.';
135+
return $messages;
136+
} elseif ($url1 != $_ENV['app_backend_url']) {
137+
return $this->urlAnalyzer->resolveIndexPhpProblem($_ENV['app_backend_url']);
138+
}
139+
}
140+
}

0 commit comments

Comments
 (0)