Skip to content

MFTF-33301: Eliminated AspectMock usage for TestObjectHandlerTest #844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,43 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace tests\unit\Magento\FunctionalTestFramework\Test\Handlers;

use AspectMock\Test as AspectMock;

use Magento\FunctionalTestingFramework\ObjectManager;
use Magento\FunctionalTestingFramework\ObjectManagerFactory;
use Exception;
use Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler;
use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
use Magento\FunctionalTestingFramework\Test\Objects\TestHookObject;
use Magento\FunctionalTestingFramework\Test\Objects\TestObject;
use Magento\FunctionalTestingFramework\Test\Parsers\TestDataParser;
use Magento\FunctionalTestingFramework\Test\Util\TestObjectExtractor;
use Magento\FunctionalTestingFramework\Util\GenerationErrorHandler;
use tests\unit\Util\MagentoTestCase;
use tests\unit\Util\MockModuleResolverBuilder;
use tests\unit\Util\ObjectHandlerUtil;
use tests\unit\Util\TestDataArrayBuilder;
use tests\unit\Util\MockModuleResolverBuilder;
use tests\unit\Util\TestLoggingUtil;
use Magento\FunctionalTestingFramework\Util\GenerationErrorHandler;

class TestObjectHandlerTest extends MagentoTestCase
{
public function setUp(): void
/**
* Before test functionality.
*
* @return void
* @throws Exception
*/
protected function setUp(): void
{
TestLoggingUtil::getInstance()->setMockLoggingUtil();
}

/**
* Basic test to validate array => test object conversion.
*
* @throws \Exception
* @return void
* @throws Exception
*/
public function testGetTestObject()
public function testGetTestObject(): void
{
// set up mock data
$testDataArrayBuilder = new TestDataArrayBuilder();
Expand All @@ -53,7 +57,6 @@ public function testGetTestObject()

// run object handler method
$toh = TestObjectHandler::getInstance();
$mockConfig = AspectMock::double(TestObjectHandler::class, ['initTestData' => false]);
$actualTestObject = $toh->getObject($testDataArrayBuilder->testName);

// perform asserts
Expand Down Expand Up @@ -114,19 +117,22 @@ public function testGetTestObject()
}

/**
* Tests basic getting of a test that has a fileName
* Tests basic getting of a test that has a fileName.
*
* @return void
*/
public function testGetTestWithFileName()
public function testGetTestWithFileName(): void
{
$this->markTestIncomplete('TODO');
}

/**
* Tests the function used to get a series of relevant tests by group.
*
* @throws \Exception
* @return void
* @throws Exception
*/
public function testGetTestsByGroup()
public function testGetTestsByGroup(): void
{
// set up mock data with Exclude Test
$includeTest = (new TestDataArrayBuilder())
Expand Down Expand Up @@ -155,11 +161,12 @@ public function testGetTestsByGroup()
}

/**
* Tests the function used to parse and determine a test's Module (used in allure Features annotation)
* Tests the function used to parse and determine a test's Module (used in allure Features annotation).
*
* @throws \Exception
* @return void
* @throws Exception
*/
public function testGetTestWithModuleName()
public function testGetTestWithModuleName(): void
{
// set up Test Data
$moduleExpected = "SomeModuleName";
Expand Down Expand Up @@ -201,11 +208,12 @@ public function testGetTestWithModuleName()
}

/**
* getObject should throw exception if test extends from itself
* getObject should throw exception if test extends from itself.
*
* @throws \Exception
* @return void
* @throws Exception
*/
public function testGetTestObjectWithInvalidExtends()
public function testGetTestObjectWithInvalidExtends(): void
{
// set up Test Data
$testOne = (new TestDataArrayBuilder())
Expand All @@ -230,11 +238,12 @@ public function testGetTestObjectWithInvalidExtends()
}

/**
* getAllObjects should throw exception if test extends from itself
* getAllObjects should throw exception if test extends from itself.
*
* @throws \Exception
* @return void
* @throws Exception
*/
public function testGetAllTestObjectsWithInvalidExtends()
public function testGetAllTestObjectsWithInvalidExtends(): void
{
// set up Test Data
$testOne = (new TestDataArrayBuilder())
Expand Down Expand Up @@ -270,11 +279,12 @@ public function testGetAllTestObjectsWithInvalidExtends()
}

/**
* Validate test object when ENABLE_PAUSE is set to true
* Validate test object when ENABLE_PAUSE is set to true.
*
* @throws \Exception
* @return void
* @throws Exception
*/
public function testGetTestObjectWhenEnablePause()
public function testGetTestObjectWhenEnablePause(): void
{
// set up mock data
putenv('ENABLE_PAUSE=true');
Expand All @@ -293,7 +303,6 @@ public function testGetTestObjectWhenEnablePause()

// run object handler method
$toh = TestObjectHandler::getInstance();
$mockConfig = AspectMock::double(TestObjectHandler::class, ['initTestData' => false]);
$actualTestObject = $toh->getObject($testDataArrayBuilder->testName);

// perform asserts
Expand Down Expand Up @@ -363,14 +372,13 @@ public function testGetTestObjectWhenEnablePause()
}

/**
* After method functionality
* After method functionality.
*
* @return void
*/
public function tearDown(): void
protected function tearDown(): void
{
TestLoggingUtil::getInstance()->clearMockLoggingUtil();
AspectMock::clean();
parent::tearDownAfterClass();
}
}