Skip to content

Commit 5f7e1d3

Browse files
author
Dmytro Aponasenko
committed
MTA-1355: Update tests with configuration fixture
1 parent 8cb8c04 commit 5f7e1d3

File tree

68 files changed

+2664
-106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2664
-106
lines changed

dev/tests/functional/composer.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
{
2-
"repositories": [
3-
{
4-
"type": "git",
5-
"url": "https://daponasenko:Magento%^78@github.corp.ebay.com/mtf/mtf.git"
6-
}
7-
],
82
"require": {
9-
"magento/mtf": "dev-MTA-1136",
3+
"magento/mtf": "1.0.0-rc12",
104
"php": ">=5.4.0",
115
"phpunit/phpunit": "4.1.0",
126
"phpunit/phpunit-selenium": ">=1.2",

dev/tests/functional/lib/Mtf/Util/Generate/Fixture/FieldsProvider.php

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
/**
1313
* Class FieldsProvider
14-
*
1514
*/
1615
class FieldsProvider implements FieldsProviderInterface
1716
{
@@ -25,6 +24,13 @@ class FieldsProvider implements FieldsProviderInterface
2524
*/
2625
protected $resource;
2726

27+
/**
28+
* Magento connection.
29+
*
30+
* @var \Magento\Framework\DB\Adapter\AdapterInterface
31+
*/
32+
protected $connection;
33+
2834
/**
2935
* @constructor
3036
* @param \Magento\Framework\ObjectManagerInterface $objectManager
@@ -35,6 +41,22 @@ public function __construct(ObjectManagerInterface $objectManager)
3541
$this->resource = $objectManager->create('Magento\Framework\App\Resource');
3642
}
3743

44+
/**
45+
* Check connection to DB.
46+
*
47+
* @return bool
48+
*/
49+
public function checkConnection()
50+
{
51+
$this->connection = $this->getConnection('core_write');
52+
if (!$this->connection || $this->connection instanceof \Zend_Db_Adapter_Exception) {
53+
echo ('Connection to Magento 2 database is absent.' . PHP_EOL);
54+
return false;
55+
}
56+
57+
return true;
58+
}
59+
3860
/**
3961
* Collect fields for the entity based on its type
4062
*
@@ -105,8 +127,7 @@ protected function flatCollectFields(array $fixture)
105127
$entityType = $fixture['entity_type'];
106128

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

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

135-
/** @var $connection \Magento\Framework\DB\Adapter\AdapterInterface */
136-
$connection = $this->resource->getConnection('core_write');
137156
$fields = [];
138157
foreach ($entityTypes as $entityType) {
139-
$fields = array_merge($fields, $connection->describeTable($entityType));
158+
$fields = array_merge($fields, $this->connection->describeTable($entityType));
140159
}
141160

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

153172
return $attributes;
154173
}
174+
175+
/**
176+
* Retrieve connection to resource specified by $resourceName.
177+
*
178+
* @param string $resourceName
179+
* @return \Exception|false|\Magento\Framework\DB\Adapter\AdapterInterface|\Zend_Exception
180+
*/
181+
protected function getConnection($resourceName)
182+
{
183+
try {
184+
$connection = $this->resource->getConnection($resourceName);
185+
return $connection;
186+
} catch (\Zend_Exception $e) {
187+
echo $e->getMessage() . PHP_EOL;
188+
return $e;
189+
}
190+
}
155191
}

dev/tests/functional/lib/Mtf/Util/Generate/Repository/CollectionProvider.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,37 @@ class CollectionProvider implements CollectionProviderInterface
1919
*/
2020
protected $objectManager;
2121

22+
/**
23+
* Magetno resource instance.
24+
*
25+
* @var \Magento\Framework\App\Resource
26+
*/
27+
protected $resource;
28+
2229
/**
2330
* @constructor
2431
* @param \Magento\Framework\ObjectManagerInterface $objectManager
2532
*/
2633
public function __construct(ObjectManagerInterface $objectManager)
2734
{
2835
$this->objectManager = $objectManager;
36+
$this->resource = $objectManager->create('Magento\Framework\App\Resource');
37+
}
38+
39+
/**
40+
* Check connection to DB.
41+
*
42+
* @return bool
43+
*/
44+
public function checkConnection()
45+
{
46+
$connection = $this->getConnection('read');
47+
if (!$connection || $connection instanceof \Zend_Db_Adapter_Exception) {
48+
echo ('Connection to Magento 2 database is absent.' . PHP_EOL);
49+
return false;
50+
}
51+
52+
return true;
2953
}
3054

3155
/**
@@ -107,4 +131,21 @@ protected function eavCollection(array $fixture)
107131

108132
return $collection->getItems();
109133
}
134+
135+
/**
136+
* Retrieve connection to resource specified by $resourceName.
137+
*
138+
* @param string $resourceName
139+
* @return \Exception|false|\Magento\Framework\DB\Adapter\AdapterInterface|\Zend_Exception
140+
*/
141+
protected function getConnection($resourceName)
142+
{
143+
try {
144+
$connection = $this->resource->getConnection($resourceName);
145+
return $connection;
146+
} catch (\Zend_Exception $e) {
147+
echo $e->getMessage() . PHP_EOL;
148+
return $e;
149+
}
150+
}
110151
}

dev/tests/functional/phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<env name="events_preset" value="base" />
4343
<env name="module_whitelist" value="Magento_Install" />
4444
<env name="report_file_name" value="test-cases-report.xml"/>
45+
<env name="basedir" value="var/log" />
4546
</php>
4647

4748
</phpunit>

dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct.xml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
<identifier>sku</identifier>
1717
<repository_class>Magento\Bundle\Test\Repository\BundleProduct</repository_class>
1818
<handler_interface>Magento\Bundle\Test\Handler\BundleProduct\BundleProductInterface</handler_interface>
19-
<dataset name="data_config">
20-
<field name="type_id" xsi:type="string">bundle</field>
21-
<field name="create_url_params" xsi:type="array">
19+
<data_config>
20+
<item name="type_id" xsi:type="string">bundle</item>
21+
<item name="create_url_params" xsi:type="array">
2222
<item name="type" xsi:type="string">bundle</item>
2323
<item name="set" xsi:type="string">4</item>
24-
</field>
25-
<field name="input_prefix" xsi:type="string">product</field>
26-
</dataset>
24+
</item>
25+
<item name="input_prefix" xsi:type="string">product</item>
26+
</data_config>
2727
<fields>
2828
<field name="category_ids">
2929
<attribute_code>category_ids</attribute_code>
@@ -88,7 +88,7 @@
8888
<attribute_code>enable_googlecheckout</attribute_code>
8989
<backend_type>int</backend_type>
9090
<is_required>0</is_required>
91-
<default_value xsi:type="number">1</default_value>
91+
<default_value xsi:type="null" />
9292
<input>select</input>
9393
</field>
9494
<field name="gallery">
@@ -190,7 +190,7 @@
190190
<attribute_code>msrp_display_actual_price_type</attribute_code>
191191
<backend_type>varchar</backend_type>
192192
<is_required>0</is_required>
193-
<default_value xsi:type="number">4</default_value>
193+
<default_value xsi:type="null" />
194194
<input>select</input>
195195
</field>
196196
<field name="name">
@@ -226,7 +226,7 @@
226226
<attribute_code>options_container</attribute_code>
227227
<backend_type>varchar</backend_type>
228228
<is_required>0</is_required>
229-
<default_value xsi:type="string">container2</default_value>
229+
<default_value xsi:type="null" />
230230
<input>select</input>
231231
</field>
232232
<field name="page_layout">
@@ -273,7 +273,6 @@
273273
<attribute_code>status</attribute_code>
274274
<backend_type>int</backend_type>
275275
<is_required>0</is_required>
276-
<default_value xsi:type="string">1</default_value>
277276
<input>checkbox</input>
278277
<group>product-details</group>
279278
</field>
@@ -289,7 +288,6 @@
289288
<attribute_code>quantity_and_stock_status</attribute_code>
290289
<backend_type>int</backend_type>
291290
<is_required>0</is_required>
292-
<default_value xsi:type="number">1</default_value>
293291
<input>select</input>
294292
<group>product-details</group>
295293
</field>
@@ -402,7 +400,6 @@
402400
<attribute_code>tax_class_id</attribute_code>
403401
<backend_type>int</backend_type>
404402
<is_required>0</is_required>
405-
<default_value xsi:type="string">Taxable Goods</default_value>
406403
<input>select</input>
407404
<group>product-details</group>
408405
<source>Magento\Catalog\Test\Fixture\CatalogProductSimple\TaxClass</source>
@@ -456,7 +453,6 @@
456453
<attribute_code>visibility</attribute_code>
457454
<backend_type>int</backend_type>
458455
<is_required>0</is_required>
459-
<default_value xsi:type="number">4</default_value>
460456
<input>select</input>
461457
<group>autosettings</group>
462458
</field>
@@ -506,9 +502,6 @@
506502
<field name="website_ids">
507503
<attribute_code>website_ids</attribute_code>
508504
<backend_type>virtual</backend_type>
509-
<default_value xsi:type="array">
510-
<item name="0" xsi:type="string">Main Website</item>
511-
</default_value>
512505
<group>websites</group>
513506
</field>
514507
</fields>

dev/tests/functional/tests/app/Magento/Bundle/Test/etc/fixture.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<fixture>Magento\Bundle\Test\Fixture\Bundle\BundleSelections</fixture>
2626
</bundle_selections>
2727
</fields>
28-
<data_set>
28+
<dataset>
2929
<sku />
3030
<name />
3131
<short_description />
@@ -36,7 +36,7 @@
3636
<price_type />
3737
<shipment_type />
3838
<bundle_selections />
39-
</data_set>
39+
</dataset>
4040
<data_config>
4141
<create_url_params>
4242
<type>bundle</type>

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
<identifier>sku</identifier>
1717
<repository_class>Magento\Catalog\Test\Repository\CatalogProductSimple</repository_class>
1818
<handler_interface>Magento\Catalog\Test\Handler\CatalogProductSimple\CatalogProductSimpleInterface</handler_interface>
19-
<dataset name="data_config">
20-
<field name="type_id" xsi:type="string">simple</field>
21-
<field name="create_url_params" xsi:type="array">
19+
<data_config>
20+
<item name="type_id" xsi:type="string">simple</item>
21+
<item name="create_url_params" xsi:type="array">
2222
<item name="type" xsi:type="string">simple</item>
2323
<item name="set" xsi:type="string">4</item>
24-
</field>
25-
<field name="input_prefix" xsi:type="string">product</field>
26-
</dataset>
24+
</item>
25+
<item name="input_prefix" xsi:type="string">product</item>
26+
</data_config>
2727
<fields>
2828
<field name="field">
2929
<attribute_code>category_ids</attribute_code>
@@ -191,7 +191,7 @@
191191
<attribute_code>msrp_display_actual_price_type</attribute_code>
192192
<backend_type>varchar</backend_type>
193193
<is_required>0</is_required>
194-
<default_value xsi:type="string">Use config</default_value>
194+
<default_value xsi:type="null" />
195195
<input>select</input>
196196
</field>
197197
<field name="name">
@@ -213,7 +213,7 @@
213213
<attribute_code>options_container</attribute_code>
214214
<backend_type>varchar</backend_type>
215215
<is_required>0</is_required>
216-
<default_value xsi:type="string">Block after Info Column</default_value>
216+
<default_value xsi:type="null" />
217217
<input>select</input>
218218
</field>
219219
<field name="page_layout">
@@ -425,7 +425,7 @@
425425
<attribute_code>is_returnable</attribute_code>
426426
<backend_type>varchar</backend_type>
427427
<is_required>0</is_required>
428-
<default_value xsi:type="number">2</default_value>
428+
<default_value xsi:type="null" />
429429
<input>select</input>
430430
<group>autosettings</group>
431431
</field>

dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
<field name="name" xsi:type="string">product_100_dollar%isolation%</field>
121121
<field name="type_id" xsi:type="string">simple</field>
122122
<field name="quantity_and_stock_status" xsi:type="array">
123-
<item name="qty" xsi:type="string">666</item>
123+
<item name="qty" xsi:type="number">666.0000</item>
124124
<item name="is_in_stock" xsi:type="string">In Stock</item>
125125
</field>
126126
<field name="weight" xsi:type="string">1</field>

dev/tests/functional/tests/app/Magento/Catalog/Test/etc/fixture.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@
6161
<backend_type>virtual</backend_type>
6262
</attribute_set_id>
6363
</fields>
64-
<data_set>
64+
<dataset>
6565
<sku />
6666
<name />
6767
<short_description />
6868
<description />
6969
<tax_class_id />
70-
</data_set>
70+
</dataset>
7171
<data_config>
7272
<create_url_params>
7373
<type>virtual</type>
@@ -101,13 +101,13 @@
101101
<backend_type>virtual</backend_type>
102102
</attribute_set_id>
103103
</fields>
104-
<data_set>
104+
<dataset>
105105
<sku />
106106
<name />
107107
<short_description />
108108
<description />
109109
<tax_class_id />
110-
</data_set>
110+
</dataset>
111111
<data_config>
112112
<create_url_params>
113113
<type>virtual</type>

0 commit comments

Comments
 (0)