Skip to content

Commit

Permalink
Merge remote-tracking branch 'qmt/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Olexii Korshenko committed Dec 16, 2014
2 parents 5ede698 + adebbb7 commit 219f716
Show file tree
Hide file tree
Showing 911 changed files with 5,945 additions and 5,657 deletions.
32 changes: 24 additions & 8 deletions dev/build/core_dev/functional/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,26 +198,42 @@
<replacefilter token="{{url}}" value="${env.http_host}${env.build.key}/instance-${instanceIndex}"/>
</replace>

<condition property="env.bamboo_tests_configuration" value="basic">
<not><isset property="env.bamboo_tests_configuration"/></not>
</condition>

<replace file="${dir.build_directory}/instance-${instanceIndex}/dev/tests/functional/config/server.yml.dist">
<replacefilter token="{{selenium_host}}" value="${env.selenium_host}"/>
<replacefilter token="{{selenium_port}}" value="${env.selenium_port}"/>
<replacefilter token="{{selenium_timeout}}" value="${env.selenium_timeout}"/>
<replacefilter token="{{selenium_browser}}" value="${env.selenium_browser}"/>
</replace>

<condition property="env.bamboo_tests_configuration" value="basic">
<not><isset property="env.bamboo_tests_configuration"/></not>
</condition>
<condition property="env.bamboo_module_whitelist" value="">
<not><isset property="env.bamboo_module_whitelist"/></not>
</condition>
<!-- Property which defines whether Magento console installation is performed -->
<condition property="env.bamboo_is_magento_installed" value="1">
<not><isset property="env.bamboo_is_magento_installed"/></not>
</condition>

<replace file="${dir.build_directory}/instance-${instanceIndex}/dev/tests/functional/phpunit.xml">
<replacefilter token="{{admin_url}}" value="${env.http_host}${env.build.key}/instance-${instanceIndex}/backend/"/>
<replacefilter token="{{url}}" value="${env.http_host}${env.build.key}/instance-${instanceIndex}"/>
<replacefilter token="{{admin_url}}" value="${env.http_host}${env.build.key}/instance-${instanceIndex}/backend/" />
<replacefilter token="{{url}}" value="${env.http_host}${env.build.key}/instance-${instanceIndex}" />
<replacefilter token="{{tests_configuration}}" value="${env.bamboo_tests_configuration}" />
<replacefilter token="{{module_whitelist}}" value="${env.bamboo_module_whitelist}" />
</replace>

<replace file="${dir.build_directory}/instance-${instanceIndex}/dev/tests/functional/config/install_data.yml.dist">
<replacefilter token="{{db_host}}" value="${env.db_host}"/>
<replacefilter token="{{db_user}}" value="${env.db_user}"/>
<replacefilter token="{{db_password}}" value="${env.db_password}"/>
<replacefilter token="{{db_name}}" value="${env.db_name_prefix}${instanceIndex}"/>
<replacefilter token="{{url}}" value="${env.http_host}${env.build.key}/instance-${instanceIndex}"/>
</replace>

<script language="javascript"><![CDATA[
var currentInstance = project.getProperty('instanceIndex');
if (currentInstance > 0) {
if (currentInstance > 0 && project.getProperty('env.bamboo_is_magento_installed') == 1) {
self.project.executeTarget('_import_mysql_dump');
self.project.executeTarget('_copy_config_php');
self.project.executeTarget('_update_db');
Expand Down Expand Up @@ -269,7 +285,7 @@

<script language="javascript"><![CDATA[
var currentInstance = project.getProperty('instanceIndex');
if (currentInstance == 0) {
if (currentInstance == 0 && project.getProperty('env.bamboo_is_magento_installed') == 1) {
self.project.executeTarget( '_install_standalone_application' );
}
]]></script>
Expand Down
8 changes: 8 additions & 0 deletions dev/build/core_dev/functional/config/install_data.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
db_credentials:
dbHost: {{db_host}}
dbUser: {{db_user}}
dbPassword: {{db_password}}
dbName: {{db_name}}
url:
base_url: {{url}}
backend_frontname: backend
2 changes: 2 additions & 0 deletions dev/build/core_dev/functional/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@
<env name="server_config_path" value="config/server.yml.dist"/>
<env name="isolation_config_path" value="config/isolation.yml.dist"/>
<env name="handlers_config_path" value="config/handler.yml.dist"/>
<env name="install_config_path" value="config/install_data.yml.dist" />
<env name="configuration:Mtf/TestSuite/InjectableTests" value="{{tests_configuration}}"/>
<env name="log_directory" value="var/log"/>
<env name="events_preset" value="base"/>
<env name="module_whitelist" value="{{module_whitelist}}" />
<!--{{parallel_instances}}-->
</php>

Expand Down
3 changes: 1 addition & 2 deletions dev/tests/functional/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"magento/mtf": "1.0.0-rc9",
"magento/mtf": "1.0.0-rc10",
"php": ">=5.4.0",
"phpunit/phpunit": "4.1.0",
"phpunit/phpunit-selenium": ">=1.2",
Expand All @@ -21,7 +21,6 @@
"Mtf\\": ["lib/Mtf/", "generated/Mtf/", "testsuites/Mtf/"],
"Magento\\": ["generated/Magento/", "tests/app/Magento/"],
"Test\\": "generated/Test/"

}
}
}
10 changes: 5 additions & 5 deletions dev/tests/functional/composer.json.dist
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"require": {
"magento/mtf": "dev-master",
"magento/mtf": "dev-develop",
"php": ">=5.4.0",
"phpunit/phpunit": "4.1.0",
"phpunit/phpunit-selenium": ">=1.2",
"netwing/selenium-server-standalone": ">=2.35"
},
"autoload": {
"psr-0": {
"Mtf\\": "lib",
"Magento\\": "",
"": ["testsuites", "generated", "lib", "tests/app"]
"psr-4": {
"Mtf\\": ["lib/Mtf/", "generated/Mtf/", "testsuites/Mtf/"],
"Magento\\": ["generated/Magento/", "tests/app/Magento/"],
"Test\\": "generated/Test/"
}
}
}
9 changes: 9 additions & 0 deletions dev/tests/functional/config/install_data.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
db_credentials:
dbHost: '127.0.0.1'
dbUser: 'root'
dbPassword: '123123q'
dbName: 'default'
url:
base_url: 'http://127.0.0.1/magento2/'
backend_frontname: 'backend'
6 changes: 4 additions & 2 deletions dev/tests/functional/lib/Mtf/App/State/State1.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ public function __construct(Config $config)
public function apply()
{
parent::apply();
$this->config->switchData('app_state1_configuration');
$this->config->persist();
if (file_exists(dirname(dirname(dirname(MTF_BP))) . '/app/etc/config.php')) {
$this->config->switchData('app_state1_configuration');
$this->config->persist();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class ConditionsElement extends AbstractElement
*
* @var string
*/
protected $ruleParamInput = '.element [name^="rule[conditions]"]';
protected $ruleParamInput = '.element [name^="rule"]';

/**
* Set value to conditions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
<?php
/**
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
*/

namespace Mtf\Client\Driver\Selenium\Element;

use Mtf\Client\Element\Locator;
use Mtf\Client\Driver\Selenium\Element;

/**
* Typified element class for global search element.
*/
class GlobalsearchElement extends Element
{
/**
* Search icon selector.
*
* @var string
*/
protected $searchIcon = '[for="search-global"]';

/**
* Locator for initialized suggest container.
*
* @var string
*/
protected $initializedSuggest = './/*[contains(@class,"search-global-field") and .//*[@class="mage-suggest"]]';

/**
* Selector for search input element.
*
* @var string
*/
protected $searchInput = '#search-global';

/**
* Result dropdown selector.
*
* @var string
*/
protected $searchResult = '.autocomplete-results';

/**
* Item selector of search result.
*
* @var string
*/
protected $resultItem = 'li';

/**
* "Backspace" key code.
*/
const BACKSPACE = "\xEE\x80\x83";

/**
* Set value.
*
* @param string $value
* @return void
*/
public function setValue($value)
{
$this->_eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]);

$this->waitInitElement();

if (!$this->find($this->searchInput)->isVisible()) {
$this->find($this->searchIcon)->click();
}
$this->selectWindow();
$this->clear();
$this->find($this->searchInput)->_getWrappedElement()->value($value);
$this->selectWindow();

$this->waitResult();
}

/**
* Clear value of element.
*
* @return void
*/
protected function clear()
{
$element = $this->find($this->searchInput);
while ('' != $element->getValue()) {
$element->keys([self::BACKSPACE]);
}
}

/**
* Select to last window.
*
* @return void
*/
protected function selectWindow()
{
$windowHandles = $this->_driver->windowHandles();
$this->_driver->window(end($windowHandles));
}

/**
* Wait init search suggest container.
*
* @return void
* @throws \Exception
*/
protected function waitInitElement()
{
$browser = clone $this;
$selector = $this->initializedSuggest;

$browser->waitUntil(
function () use ($browser, $selector) {
return $browser->find($selector, Locator::SELECTOR_XPATH)->isVisible() ? true : null;
}
);
}

/**
* Wait for search result is visible.
*
* @return void
*/
public function waitResult()
{
$browser = clone $this;
$selector = $this->searchResult;

$browser->waitUntil(
function () use ($browser, $selector) {
if ($browser->find($selector)->isVisible()) {
return true;
} else {
$browser->selectWindow();
return null;
}
}
);
}

/**
* Get value.
*
* @throws \BadMethodCallException
*/
public function getValue()
{
throw new \BadMethodCallException('Not applicable for this class of elements (GlobalSearch)');
}

/**
* Checking exist value in search result.
*
* @param string $value
* @return bool
*/
public function isExistValueInSearchResult($value)
{
$searchResult = $this->find($this->searchResult);
if (!$searchResult->isVisible()) {
return false;
}
$searchResults = $this->getSearchResults();
return in_array($value, $searchResults);
}

/**
* Get search results.
*
* @return array
*/
protected function getSearchResults()
{
/** @var Element $searchResult */
$searchResult = $this->find($this->searchResult);
$resultItems = $searchResult->find($this->resultItem)->getElements();
$resultArray = [];

/** @var Element $resultItem */
foreach ($resultItems as $resultItem) {
$resultItemLink = $resultItem->find('a');
$resultText = $resultItemLink->isVisible()
? trim($resultItemLink->getText())
: trim($resultItem->getText());
$resultArray[] = $resultText;
}

return $resultArray;
}
}
Loading

0 comments on commit 219f716

Please sign in to comment.