Skip to content

Commit

Permalink
Merge pull request #65 from magento-qmt/develop
Browse files Browse the repository at this point in the history
[Mavericks] Convert all fixtures/repositories for functional tests into *.xml files
  • Loading branch information
Dmytro Aponasenko committed Jan 28, 2015
2 parents 8f09664 + f3ac9b5 commit 9e8434e
Show file tree
Hide file tree
Showing 400 changed files with 14,453 additions and 17,870 deletions.
2 changes: 1 addition & 1 deletion dev/tests/functional/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"magento/mtf": "1.0.0-rc14",
"magento/mtf": "1.0.0-rc15",
"php": ">=5.4.0",
"phpunit/phpunit": "4.1.0",
"phpunit/phpunit-selenium": ">=1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,12 @@ public function setValue($value)
protected function addConditionsCombination($condition, ElementInterface $context)
{
$condition = $this->parseCondition($condition);

$this->driver->selectWindow();
$newCondition = $context->find($this->newCondition, Locator::SELECTOR_XPATH);
$newCondition->find($this->addNew, Locator::SELECTOR_XPATH)->click();

$this->driver->selectWindow();
$typeNewCondition = $newCondition->find($this->typeNew, Locator::SELECTOR_XPATH, 'select');
$typeNewCondition->setValue($condition['type']);

Expand Down Expand Up @@ -235,16 +239,23 @@ protected function addSingleCondition($condition, ElementInterface $context)
{
$condition = $this->parseCondition($condition);

$this->driver->selectWindow();
$newCondition = $context->find($this->newCondition, Locator::SELECTOR_XPATH);
$newCondition->find($this->addNew, Locator::SELECTOR_XPATH)->click();

$typeNew = $this->typeNew;
$newCondition->waitUntil(
function () use ($newCondition, $typeNew) {
$element = $newCondition->find($typeNew, Locator::SELECTOR_XPATH, 'select');
return $element->isVisible() ? true : null;
if ($element->isVisible()) {
return true;
}
$this->driver->selectWindow();
return null;
}
);
$newCondition->find($this->typeNew, Locator::SELECTOR_XPATH, 'select')->setValue($condition['type']);

$createdCondition = $context->find($this->created, Locator::SELECTOR_XPATH);
$this->waitForCondition($createdCondition);
$this->fillCondition($condition['rules'], $createdCondition);
Expand All @@ -264,6 +275,8 @@ protected function fillCondition(array $rules, ElementInterface $element)
foreach ($rules as $rule) {
/** @var ElementInterface $param */
$param = $this->findNextParam($element);

$this->driver->selectWindow();
$param->find('a')->click();

if (preg_match('`%(.*?)%`', $rule, $chooserGrid)) {
Expand Down Expand Up @@ -392,7 +405,11 @@ protected function waitForCondition(ElementInterface $element)
{
$this->waitUntil(
function () use ($element) {
return $element->getAttribute('class') == 'rule-param-wait' ? null : true;
if ($element->getAttribute('class') == 'rule-param-wait') {
$this->driver->selectWindow();
return null;
}
return true;
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function create(array $sharedInstances = [])
$argInterpreter = $this->createArgumentInterpreter(new BooleanUtils());
$argumentMapper = new \Magento\Mtf\ObjectManager\Config\Mapper\Dom($argInterpreter);

$sharedInstances['Magento\Mtf\Data\Argument\InterpreterInterface'] = $argInterpreter;
$sharedInstances['Magento\Mtf\ObjectManager\Config\Mapper\Dom'] = $argumentMapper;
$objectManager = new $this->locatorClassName($factory, $diConfig, $sharedInstances);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

/**
* Class FieldsProvider
*
*/
class FieldsProvider implements FieldsProviderInterface
{
Expand All @@ -25,6 +24,13 @@ class FieldsProvider implements FieldsProviderInterface
*/
protected $resource;

/**
* Magento connection.
*
* @var \Magento\Framework\DB\Adapter\AdapterInterface
*/
protected $connection;

/**
* @constructor
* @param \Magento\Framework\ObjectManagerInterface $objectManager
Expand All @@ -35,6 +41,22 @@ public function __construct(ObjectManagerInterface $objectManager)
$this->resource = $objectManager->create('Magento\Framework\App\Resource');
}

/**
* Check connection to DB.
*
* @return bool
*/
public function checkConnection()
{
$this->connection = $this->getConnection('core_write');
if (!$this->connection || $this->connection instanceof \Zend_Db_Adapter_Exception) {
echo ('Connection to Magento 2 database is absent. Fixture data has not been fetched.' . PHP_EOL);
return false;
}

return true;
}

/**
* Collect fields for the entity based on its type
*
Expand Down Expand Up @@ -105,8 +127,7 @@ protected function flatCollectFields(array $fixture)
$entityType = $fixture['entity_type'];

/** @var $connection \Magento\Framework\DB\Adapter\AdapterInterface */
$connection = $this->resource->getConnection('core_write');
$fields = $connection->describeTable($entityType);
$fields = $this->connection->describeTable($entityType);

$attributes = [];
foreach ($fields as $code => $field) {
Expand All @@ -132,11 +153,9 @@ protected function compositeCollectFields(array $fixture)
{
$entityTypes = $fixture['entities'];

/** @var $connection \Magento\Framework\DB\Adapter\AdapterInterface */
$connection = $this->resource->getConnection('core_write');
$fields = [];
foreach ($entityTypes as $entityType) {
$fields = array_merge($fields, $connection->describeTable($entityType));
$fields = array_merge($fields, $this->connection->describeTable($entityType));
}

$attributes = [];
Expand All @@ -152,4 +171,21 @@ protected function compositeCollectFields(array $fixture)

return $attributes;
}

/**
* Retrieve connection to resource specified by $resourceName.
*
* @param string $resourceName
* @return \Exception|false|\Magento\Framework\DB\Adapter\AdapterInterface|\Zend_Exception
*/
protected function getConnection($resourceName)
{
try {
$connection = $this->resource->getConnection($resourceName);
return $connection;
} catch (\Zend_Exception $e) {
echo $e->getMessage() . PHP_EOL;
return $e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,37 @@ class CollectionProvider implements CollectionProviderInterface
*/
protected $objectManager;

/**
* Magetno resource instance.
*
* @var \Magento\Framework\App\Resource
*/
protected $resource;

/**
* @constructor
* @param \Magento\Framework\ObjectManagerInterface $objectManager
*/
public function __construct(ObjectManagerInterface $objectManager)
{
$this->objectManager = $objectManager;
$this->resource = $objectManager->create('Magento\Framework\App\Resource');
}

/**
* Check connection to DB.
*
* @return bool
*/
public function checkConnection()
{
$connection = $this->getConnection('read');
if (!$connection || $connection instanceof \Zend_Db_Adapter_Exception) {
echo ('Connection to Magento 2 database is absent. Repository data has not been fetched.' . PHP_EOL);
return false;
}

return true;
}

/**
Expand Down Expand Up @@ -107,4 +131,21 @@ protected function eavCollection(array $fixture)

return $collection->getItems();
}

/**
* Retrieve connection to resource specified by $resourceName.
*
* @param string $resourceName
* @return \Exception|false|\Magento\Framework\DB\Adapter\AdapterInterface|\Zend_Exception
*/
protected function getConnection($resourceName)
{
try {
$connection = $this->resource->getConnection($resourceName);
return $connection;
} catch (\Zend_Exception $e) {
echo $e->getMessage() . PHP_EOL;
return $e;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
* @spi
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
* @spi
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
* @spi
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
Expand Down
3 changes: 2 additions & 1 deletion dev/tests/functional/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@
<env name="handlers_config_path" value="config/handler.yml.dist" />
<env name="install_config_path" value="config/install_data.yml.dist" />
<env name="testsuite_rule" value="basic" />
<env name="testsuite_rule_path" value="Mtf/TestSuite/InjectableTests" />
<env name="testsuite_rule_path" value="Magento/Mtf/TestSuite/InjectableTests" />
<env name="log_directory" value="var/log" />
<env name="events_preset" value="base" />
<env name="module_whitelist" value="Magento_Install" />
<env name="report_file_name" value="test-cases-report.xml"/>
<env name="basedir" value="var/log" />
</php>

</phpunit>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
* @spi
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private function getFixtureFieldsByTabs(InjectableFixture $fixture)
foreach ($data as $field => $value) {
$attributes = $fixture->getDataFieldConfig($field);
$attributes['value'] = $value;
if (array_key_exists('group', $attributes) && $attributes['group'] !== null) {
if (array_key_exists('group', $attributes) && $attributes['group'] != 'null') {
$tabs[$attributes['group']][$field] = $attributes;
} elseif (!array_key_exists('group', $attributes)) {
$this->unassignedFields[$field] = $attributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ public function sortGridByField($field, $sort = "desc")
*/
protected function openFilterBlock()
{
$this->getTemplateBlock()->waitForElementNotVisible($this->loader);

$button = $this->_rootElement->find($this->filterButton);
if ($button->isVisible() && !$this->_rootElement->find($this->filterButton . $this->active)->isVisible()) {
$button->click();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
* See COPYING.txt for license details.
*/
-->
<fixture class="Magento\Backend\Test\Fixture\Search">
<fixture xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Fixture/etc/fixture.xsd"
class="Magento\Backend\Test\Fixture\GlobalSearch">
<module>Magento_Backend</module>
<dataset name="default">
<field name="query" xsi:type="string">catalogProductSimple::default::name</field>
</dataset>
<fields>
<query>
<field name="query">
<attribute_code>query</attribute_code>
<backend_type>virtual</backend_type>
<fixture>Magento\Backend\Test\Fixture\Search\Query</fixture>
</query>
<source>Magento\Backend\Test\Fixture\GlobalSearch\Query</source>
</field>
</fields>
</fixture>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See COPYING.txt for license details.
*/

namespace Magento\Backend\Test\Fixture;
namespace Magento\Backend\Test\Fixture\Source;

use Magento\Mtf\Fixture\FixtureInterface;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
* @spi
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" ?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<repository xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
<storage class="Magento\Core\Test\Repository\ConfigData">
<dataset name="store_information">
<field path="general/store_information/name" scope="general" scope_id="1" label="" xsi:type="string">Store 1</field>
<field path="general/store_information/phone" scope="general" scope_id="1" label="" xsi:type="string">1234-123-123</field>
<field path="general/store_information/country_id" scope="general" scope_id="1" label="United States" xsi:type="string">US</field>
<field path="general/store_information/region_id" scope="general" scope_id="1" label="California" xsi:type="string">12</field>
<field path="general/store_information/postcode" scope="general" scope_id="1" label="" xsi:type="string">90322</field>
<field path="general/store_information/city" scope="general" scope_id="1" label="" xsi:type="string">Culver City</field>
<field path="general/store_information/street_line1" scope="general" scope_id="1" label="" xsi:type="string">10441 Jefferson Blvd</field>
<field path="general/store_information/street_line2" scope="general" scope_id="1" label="" xsi:type="string">Suite 200</field>
</dataset>
</storage>
</repository>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
* @spi
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
Expand Down
Loading

0 comments on commit 9e8434e

Please sign in to comment.