Skip to content

Commit c724e5d

Browse files
authored
Merge pull request #15 from magento-pangolin/sprint-develop
[Pangolins] Sprint 13 - Stories: - MQE-388 Write store settings before tests - MQE-508 before and after tags should have their own group/type in the schema - MQE-483 Sanitize test naming to prevent Jenkins build failure - MQE-432 Create variable reference verification tests - MQE-421 Create Unit Tests for the object model - MQE-235 [Generator] Add additional Assertion methods - MQE-336 [Generator] Add support for Codeception "Locator" selectors - MQE-448 Create a script to generate full Product metadata from Swagger - MQE-462 Update waitForLoadingMaskToDisappear to handle duplicated masks - MQE-497 Add useCaseId annotation - MQE-434 Create operation api unit tests - Bugs: - MQE-472 [Data Input] Unable to resolve array data input in MFTF. - MQE-531 Unit and Verification tests do not run with MFTF PR - MQE-544 Change verification test filenames to begin with Uppercase - MQE-516 Duplicated $data.key$ references are not replaced correctly - MQE-406 Omitting defaultValue for actionGroup argument causes error
2 parents 193da38 + 053c01f commit c724e5d

File tree

86 files changed

+3829
-397
lines changed

Some content is hidden

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

86 files changed

+3829
-397
lines changed

.travis.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ language: php
22
php:
33
- 7.0
44
- 7.1
5-
install:
6-
- composer install --no-interaction --prefer-source
7-
before_script:
8-
- composer require codacy/coverage --dev
5+
install: composer install --no-interaction --prefer-source
6+
env:
7+
matrix:
8+
- VERIFICATION_TOOL=copyright-check
9+
- VERIFICATION_TOOL=phpunit-checks
10+
- VERIFICATION_TOOL=static-checks
911
script:
10-
- bin/all-checks
12+
- bin/$VERIFICATION_TOOL
1113
after_script:
12-
- php vendor/bin/codacycoverage phpunit
13-
14-
14+
- if [ $VERIFICATION_TOOL == "phpunit-checks" ]; then php vendor/bin/codacycoverage phpunit; fi

bin/static-checks

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
echo "===============================PHP CODE SNIFFER REPORT==============================="
55
vendor/bin/phpcs ./src --standard=./dev/tests/static/Magento
6+
vendor/bin/phpcs ./dev/tests/unit --standard=./dev/tests/static/Magento
7+
vendor/bin/phpcs ./dev/tests/verification --standard=./dev/tests/static/Magento
68

79
echo "===============================COPY PASTE DETECTOR REPORT==============================="
810
vendor/bin/phpcpd ./src

composer.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,30 @@
44
"description": "Magento2 Functional Testing Framework",
55
"keywords": ["magento", "automation", "functional", "testing"],
66
"require": {
7-
"php": "~7.0",
8-
"codeception/codeception": "2.2|2.3",
7+
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0",
8+
"codeception/codeception": "~2.3.4",
99
"flow/jsonpath": ">0.2",
1010
"fzaninotto/faker": "^1.6",
11-
"mustache/mustache": "~2.5"
11+
"mustache/mustache": "~2.5",
12+
"epfremme/swagger-php": "^2.0"
1213
},
1314
"require-dev": {
1415
"squizlabs/php_codesniffer": "1.5.3",
1516
"sebastian/phpcpd": "~3.0",
16-
"brainmaestro/composer-git-hooks": "^2.3"
17+
"brainmaestro/composer-git-hooks": "^2.3",
18+
"codeception/aspect-mock": "^2.0",
19+
"codacy/coverage": "^1.4"
1720
},
1821
"autoload": {
1922
"psr-4": {
2023
"Magento\\FunctionalTestingFramework\\": ["src/Magento/FunctionalTestingFramework"]
2124
}
2225
},
26+
"autoload-dev": {
27+
"psr-4": {
28+
"tests\\unit\\Magento\\FunctionalTestingFramework\\": ["dev/tests/unit/Magento/FunctionalTestingFramework"]
29+
}
30+
},
2331
"extra": {
2432
"hooks": {
2533
"pre-push": "bin/copyright-check"

dev/tests/_bootstrap.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
define('PROJECT_ROOT', dirname(dirname(__DIR__)));
99
require_once PROJECT_ROOT . '/vendor/autoload.php';
1010

11+
// Set up AspectMock
12+
$kernel = \AspectMock\Kernel::getInstance();
13+
$kernel->init([
14+
'debug' => true,
15+
'includePaths' => [PROJECT_ROOT . '/src']
16+
]);
17+
1118
// Load needed framework env params
1219
$TEST_ENVS = [
1320
'MAGENTO_BASE_URL' => 'http://baseurl:8080',
@@ -23,7 +30,6 @@
2330
// Add our test module to the whitelist
2431
putenv('MODULE_WHITELIST=Magento_TestModule');
2532

26-
2733
// Define our own set of paths for the tests
2834
defined('FW_BP') || define('FW_BP', PROJECT_ROOT);
2935

dev/tests/phpunit.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.3/phpunit.xsd"
1111
convertNoticesToExceptions="false"
12-
bootstrap="_bootstrap.php">
12+
bootstrap="_bootstrap.php"
13+
backupGlobals="false">
1314
<testsuites>
1415
<testsuite name="verification">
1516
<directory>verification</directory>
@@ -27,4 +28,4 @@
2728
<directory suffix=".php">../../src/Magento/FunctionalTestingFramework/Util</directory>
2829
</whitelist>
2930
</filter>
30-
</phpunit>
31+
</phpunit>
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace tests\unit\Magento\FunctionalTestFramework\DataGenerator\Handlers;
8+
9+
use AspectMock\Test as AspectMock;
10+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
11+
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
12+
use Magento\FunctionalTestingFramework\DataGenerator\Parsers\DataProfileSchemaParser;
13+
use Magento\FunctionalTestingFramework\ObjectManager;
14+
use Magento\FunctionalTestingFramework\ObjectManagerFactory;
15+
use PHPUnit\Framework\TestCase;
16+
17+
/**
18+
* Class DataObjectHandlerTest
19+
*/
20+
class DataObjectHandlerTest extends TestCase
21+
{
22+
// All tests share this array, feel free to add but be careful modifying or removing
23+
const PARSER_OUTPUT = [
24+
'entity' => [
25+
'EntityOne' => [
26+
'type' => 'testType',
27+
'data' => [
28+
0 => [
29+
'key' => 'testKey',
30+
'value' => 'testValue'
31+
]
32+
]
33+
]
34+
]
35+
];
36+
37+
/**
38+
* Set up everything required to mock DataObjectHander::getInstance()
39+
* The first call to getInstance() uses these mocks to emulate the parser, initializing internal state
40+
* according to the PARSER_OUTPUT value
41+
*/
42+
public static function setUpBeforeClass()
43+
{
44+
$mockDataProfileSchemaParser = AspectMock::double(DataProfileSchemaParser::class, [
45+
'readDataProfiles' => self::PARSER_OUTPUT
46+
])->make();
47+
48+
$mockObjectManager = AspectMock::double(ObjectManager::class, [
49+
'create' => $mockDataProfileSchemaParser
50+
])->make();
51+
52+
AspectMock::double(ObjectManagerFactory::class, [
53+
'getObjectManager' => $mockObjectManager
54+
]);
55+
}
56+
57+
/**
58+
* getAllObjects should contain the expected data object
59+
*/
60+
public function testGetAllObjects()
61+
{
62+
// Call the method under test
63+
64+
$actual = DataObjectHandler::getInstance()->getAllObjects();
65+
66+
// Assert
67+
68+
$expected = new EntityDataObject('EntityOne', 'testType', ['testkey' => 'testValue'], [], null, []);
69+
$this->assertArrayHasKey('EntityOne', $actual);
70+
$this->assertEquals($expected, $actual['EntityOne']);
71+
}
72+
73+
/**
74+
* getObject should return the expected data object if it exists
75+
*/
76+
public function testGetObject()
77+
{
78+
// Call the method under test
79+
80+
$actual = DataObjectHandler::getInstance()->getObject('EntityOne');
81+
82+
// Assert
83+
84+
$expected = new EntityDataObject('EntityOne', 'testType', ['testkey' => 'testValue'], [], null, []);
85+
$this->assertEquals($expected, $actual);
86+
}
87+
88+
/**
89+
* getObject should return null if the data object does not exist
90+
*/
91+
public function testGetObjectNull()
92+
{
93+
$actual = DataObjectHandler::getInstance()->getObject('h953u789h0g73t521'); // doesnt exist
94+
$this->assertNull($actual);
95+
}
96+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace tests\unit\Magento\FunctionalTestFramework\DataGenerator\Handlers;
8+
9+
use PHPUnit\Framework\TestCase;
10+
11+
/**
12+
* Class OperationDefinitionObjectHandlerTest
13+
*/
14+
class OperationDefinitionObjectHandlerTest extends TestCase
15+
{
16+
public function testTodo()
17+
{
18+
$this->markTestIncomplete('TODO');
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace tests\unit\Magento\FunctionalTestFramework\DataGenerator\Objects;
8+
9+
use PHPUnit\Framework\TestCase;
10+
11+
/**
12+
* Class EntityDataObjectTest
13+
*/
14+
class EntityDataObjectTest extends TestCase
15+
{
16+
public function testTodo()
17+
{
18+
$this->markTestIncomplete('TODO');
19+
}
20+
}

0 commit comments

Comments
 (0)