Skip to content

Commit

Permalink
Merge branch 'develop' into imported-magento-magento2-functional-test…
Browse files Browse the repository at this point in the history
…ing-framework-845
  • Loading branch information
jilu1 authored Aug 3, 2021
2 parents a456476 + 93676a8 commit dc2aa4f
Show file tree
Hide file tree
Showing 27 changed files with 1,387 additions and 776 deletions.
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
Magento Functional Testing Framework Changelog
================================================
3.6.0
---------

### Enhancements

* Maintainability
* Updated composer dependencies to be PHP 8 compatible with the except of codeception/aspect-mock.

### GitHub Pull Requests:

* [#830](https://github.com/magento/magento2-functional-testing-framework/pull/830) -- Add ability to configure multiple OTPs
* [#832](https://github.com/magento/magento2-functional-testing-framework/pull/832) -- Updated monolog/monolog to ^2.2
* [#833](https://github.com/magento/magento2-functional-testing-framework/pull/833) -- Removed usage of AspectMock in FilesystemTest
* [#834](https://github.com/magento/magento2-functional-testing-framework/pull/834) -- Removed usage of AspectMock in AnnotationsCheckTest
* [#838](https://github.com/magento/magento2-functional-testing-framework/pull/838) -- Removed usage of AspectMock in DeprecatedEntityUsageCheckTest
* [#841](https://github.com/magento/magento2-functional-testing-framework/pull/841) -- Removed usage of AspectMock in GenerationErrorHandlerTest
* [#854](https://github.com/magento/magento2-functional-testing-framework/pull/854) -- Updated "monolog" to the latest version 2.3.1

3.5.1
---------

### GitHub Pull Requests:

* [#825](https://github.com/magento/magento2-functional-testing-framework/pull/825) -- Update allure-codeception in order to support php8


3.5.0
---------

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "magento/magento2-functional-testing-framework",
"description": "Magento2 Functional Testing Framework",
"type": "library",
"version": "3.5.1",
"version": "3.6.0",
"license": "AGPL-3.0",
"keywords": ["magento", "automation", "functional", "testing"],
"config": {
Expand All @@ -25,8 +25,9 @@
"csharpru/vault-php": "^4.2.1",
"csharpru/vault-php-guzzle6-transport": "^2.0",
"hoa/console": "~3.0",
"monolog/monolog": "^2.2",
"monolog/monolog": "^2.3",
"mustache/mustache": "~2.5",
"nikic/php-parser": "^4.4",
"php-webdriver/webdriver": "^1.9.0",
"spomky-labs/otphp": "^10.0",
"symfony/console": "^4.4",
Expand All @@ -35,8 +36,7 @@
"symfony/mime": "^5.0",
"symfony/process": "^4.4",
"vlucas/phpdotenv": "^2.4",
"weew/helpers-array": "^1.3",
"nikic/php-parser": "^4.4"
"weew/helpers-array": "^1.3"
},
"require-dev": {
"brainmaestro/composer-git-hooks": "^2.3.1",
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,46 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace tests\unit\Magento\FunctionalTestFramework\Console;

use AspectMock\Test as AspectMock;
use PHPUnit\Framework\TestCase;
use Exception;
use Magento\FunctionalTestingFramework\Console\BaseGenerateCommand;
use Magento\FunctionalTestingFramework\Suite\Objects\SuiteObject;
use Magento\FunctionalTestingFramework\Suite\Handlers\SuiteObjectHandler;
use Magento\FunctionalTestingFramework\Test\Objects\TestObject;
use Magento\FunctionalTestingFramework\Suite\Objects\SuiteObject;
use Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler;
use Magento\FunctionalTestingFramework\Test\Objects\TestObject;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use ReflectionException;
use ReflectionProperty;

class BaseGenerateCommandTest extends TestCase
{
public function tearDown(): void
/**
* @inheritDoc
*/
protected function tearDown(): void
{
AspectMock::clean();
$handler = TestObjectHandler::getInstance();
$testsProperty = new ReflectionProperty(TestObjectHandler::class, 'tests');
$testsProperty->setAccessible(true);
$testsProperty->setValue($handler, []);
$testObjectHandlerProperty = new ReflectionProperty(TestObjectHandler::class, 'testObjectHandler');
$testObjectHandlerProperty->setAccessible(true);
$testObjectHandlerProperty->setValue($handler);

$handler = SuiteObjectHandler::getInstance();
$suiteObjectsProperty = new ReflectionProperty(SuiteObjectHandler::class, 'suiteObjects');
$suiteObjectsProperty->setAccessible(true);
$suiteObjectsProperty->setValue($handler, []);
$suiteObjectHandlerProperty = new ReflectionProperty(SuiteObjectHandler::class, 'instance');
$suiteObjectHandlerProperty->setAccessible(true);
$suiteObjectHandlerProperty->setValue($handler);
}

public function testOneTestOneSuiteConfig()
public function testOneTestOneSuiteConfig(): void
{
$testOne = new TestObject('Test1', [], [], []);
$suiteOne = new SuiteObject('Suite1', ['Test1' => $testOne], [], []);
Expand All @@ -35,7 +57,7 @@ public function testOneTestOneSuiteConfig()
$this->assertEquals($expected, $actual);
}

public function testOneTestTwoSuitesConfig()
public function testOneTestTwoSuitesConfig(): void
{
$testOne = new TestObject('Test1', [], [], []);
$suiteOne = new SuiteObject('Suite1', ['Test1' => $testOne], [], []);
Expand All @@ -51,7 +73,7 @@ public function testOneTestTwoSuitesConfig()
$this->assertEquals($expected, $actual);
}

public function testOneTestOneGroup()
public function testOneTestOneGroup(): void
{
$testOne = new TestObject('Test1', [], ['group' => ['Group1']], []);

Expand All @@ -65,7 +87,7 @@ public function testOneTestOneGroup()
$this->assertEquals($expected, $actual);
}

public function testThreeTestsTwoGroup()
public function testThreeTestsTwoGroup(): void
{
$testOne = new TestObject('Test1', [], ['group' => ['Group1']], []);
$testTwo = new TestObject('Test2', [], ['group' => ['Group1']], []);
Expand All @@ -81,7 +103,7 @@ public function testThreeTestsTwoGroup()
$this->assertEquals($expected, $actual);
}

public function testOneTestOneSuiteOneGroupConfig()
public function testOneTestOneSuiteOneGroupConfig(): void
{
$testOne = new TestObject('Test1', [], ['group' => ['Group1']], []);
$suiteOne = new SuiteObject('Suite1', ['Test1' => $testOne], [], []);
Expand All @@ -96,7 +118,7 @@ public function testOneTestOneSuiteOneGroupConfig()
$this->assertEquals($expected, $actual);
}

public function testTwoTestOneSuiteTwoGroupConfig()
public function testTwoTestOneSuiteTwoGroupConfig(): void
{
$testOne = new TestObject('Test1', [], ['group' => ['Group1']], []);
$testTwo = new TestObject('Test2', [], ['group' => ['Group2']], []);
Expand All @@ -112,7 +134,7 @@ public function testTwoTestOneSuiteTwoGroupConfig()
$this->assertEquals($expected, $actual);
}

public function testTwoTestTwoSuiteOneGroupConfig()
public function testTwoTestTwoSuiteOneGroupConfig(): void
{
$testOne = new TestObject('Test1', [], ['group' => ['Group1']], []);
$testTwo = new TestObject('Test2', [], ['group' => ['Group1']], []);
Expand All @@ -131,10 +153,12 @@ public function testTwoTestTwoSuiteOneGroupConfig()

/**
* Test specific usecase of a test that is in a group with the group being called along with the suite
* i.e. run:group Group1 Suite1
* @throws \Exception
* i.e. run:group Group1 Suite1.
*
* @return void
* @throws Exception
*/
public function testThreeTestOneSuiteOneGroupMix()
public function testThreeTestOneSuiteOneGroupMix(): void
{
$testOne = new TestObject('Test1', [], [], []);
$testTwo = new TestObject('Test2', [], [], []);
Expand All @@ -156,7 +180,7 @@ public function testThreeTestOneSuiteOneGroupMix()
$this->assertEquals($expected, $actual);
}

public function testSuiteToTestSyntax()
public function testSuiteToTestSyntax(): void
{
$testOne = new TestObject('Test1', [], [], []);
$suiteOne = new SuiteObject(
Expand All @@ -175,51 +199,82 @@ public function testSuiteToTestSyntax()
}

/**
* Mock handlers to skip parsing
* Mock handlers to skip parsing.
*
* @param array $testArray
* @param array $suiteArray
* @throws \Exception
*
* @return void
* @throws Exception
*/
public function mockHandlers($testArray, $suiteArray)
public function mockHandlers(array $testArray, array $suiteArray): void
{
AspectMock::double(TestObjectHandler::class, ['initTestData' => ''])->make();
// bypass the initTestData method
$testObjectHandlerClass = new ReflectionClass(TestObjectHandler::class);
$constructor = $testObjectHandlerClass->getConstructor();
$constructor->setAccessible(true);
$testObjectHandlerObject = $testObjectHandlerClass->newInstanceWithoutConstructor();
$constructor->invoke($testObjectHandlerObject);

$testObjectHandlerProperty = new ReflectionProperty(TestObjectHandler::class, 'testObjectHandler');
$testObjectHandlerProperty->setAccessible(true);
$testObjectHandlerProperty->setValue($testObjectHandlerObject);

$handler = TestObjectHandler::getInstance();
$property = new \ReflectionProperty(TestObjectHandler::class, 'tests');
$property = new ReflectionProperty(TestObjectHandler::class, 'tests');
$property->setAccessible(true);
$property->setValue($handler, $testArray);

AspectMock::double(SuiteObjectHandler::class, ['initSuiteData' => ''])->make();
// bypass the initTestData method
$suiteObjectHandlerClass = new ReflectionClass(SuiteObjectHandler::class);
$constructor = $suiteObjectHandlerClass->getConstructor();
$constructor->setAccessible(true);
$suiteObjectHandlerObject = $suiteObjectHandlerClass->newInstanceWithoutConstructor();
$constructor->invoke($suiteObjectHandlerObject);

$suiteObjectHandlerProperty = new ReflectionProperty(SuiteObjectHandler::class, 'instance');
$suiteObjectHandlerProperty->setAccessible(true);
$suiteObjectHandlerProperty->setValue($suiteObjectHandlerObject);

$handler = SuiteObjectHandler::getInstance();
$property = new \ReflectionProperty(SuiteObjectHandler::class, 'suiteObjects');
$property = new ReflectionProperty(SuiteObjectHandler::class, 'suiteObjects');
$property->setAccessible(true);
$property->setValue($handler, $suiteArray);
}

/**
* Changes visibility and runs getTestAndSuiteConfiguration
* Changes visibility and runs getTestAndSuiteConfiguration.
*
* @param array $testArray
*
* @return string
* @throws ReflectionException
*/
public function callTestConfig($testArray)
public function callTestConfig(array $testArray): string
{
$command = new BaseGenerateCommand();
$class = new \ReflectionClass($command);
$class = new ReflectionClass($command);
$method = $class->getMethod('getTestAndSuiteConfiguration');
$method->setAccessible(true);

return $method->invokeArgs($command, [$testArray]);
}

/**
* Changes visibility and runs getGroupAndSuiteConfiguration
* Changes visibility and runs getGroupAndSuiteConfiguration.
*
* @param array $groupArray
*
* @return string
* @throws ReflectionException
*/
public function callGroupConfig($groupArray)
public function callGroupConfig(array $groupArray): string
{
$command = new BaseGenerateCommand();
$class = new \ReflectionClass($command);
$class = new ReflectionClass($command);
$method = $class->getMethod('getGroupAndSuiteConfiguration');
$method->setAccessible(true);

return $method->invokeArgs($command, [$groupArray]);
}
}
Loading

0 comments on commit dc2aa4f

Please sign in to comment.