Skip to content

Commit

Permalink
33581: Eliminated AspectMock where it was imported but never used
Browse files Browse the repository at this point in the history
  • Loading branch information
anzin committed Jul 26, 2021
1 parent 9dfd3e3 commit ac6cef4
Show file tree
Hide file tree
Showing 7 changed files with 461 additions and 337 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

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

use AspectMock\Test as AspectMock;
use Exception;
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
use Magento\FunctionalTestingFramework\DataGenerator\Parsers\DataProfileSchemaParser;
use Magento\FunctionalTestingFramework\ObjectManager;
use Magento\FunctionalTestingFramework\ObjectManagerFactory;
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
use tests\unit\Util\MagentoTestCase;
use tests\unit\Util\ObjectHandlerUtil;
use tests\unit\Util\TestLoggingUtil;
Expand All @@ -22,9 +21,9 @@
class DataObjectHandlerTest extends MagentoTestCase
{
/**
* Setup method
* @inheritDoc
*/
public function setUp(): void
protected function setUp(): void
{
TestLoggingUtil::getInstance()->setMockLoggingUtil();
}
Expand Down Expand Up @@ -145,9 +144,12 @@ public function setUp(): void
];

/**
* getAllObjects should contain the expected data object
* Validate getAllObjects should contain the expected data object.
*
* @return void
* @throws Exception
*/
public function testGetAllObjects()
public function testGetAllObjects(): void
{
ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT);

Expand All @@ -161,9 +163,12 @@ public function testGetAllObjects()
}

/**
* test deprecated data object
* Validate test deprecated data object.
*
* @return void
* @throws Exception
*/
public function testDeprecatedDataObject()
public function testDeprecatedDataObject(): void
{
ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT_DEPRECATED);

Expand All @@ -173,15 +178,18 @@ public function testDeprecatedDataObject()
//validate deprecation warning
TestLoggingUtil::getInstance()->validateMockLogStatement(
'warning',
"DEPRECATION: The data entity 'EntityOne' is deprecated.",
["fileName" => "filename.xml", "deprecatedMessage" => "deprecation message"]
'DEPRECATION: The data entity \'EntityOne\' is deprecated.',
['fileName' => 'filename.xml', 'deprecatedMessage' => 'deprecation message']
);
}

/**
* getObject should return the expected data object if it exists
* Validate getObject should return the expected data object if it exists.
*
* @return void
* @throws Exception
*/
public function testGetObject()
public function testGetObject(): void
{
ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT);

Expand All @@ -194,9 +202,12 @@ public function testGetObject()
}

/**
* getAllObjects should return the expected data object if it exists
* Validate getAllObjects should return the expected data object if it exists.
*
* @return void
* @throws Exception
*/
public function testGetObjectNull()
public function testGetObjectNull(): void
{
ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT);

Expand All @@ -205,9 +216,12 @@ public function testGetObjectNull()
}

/**
* getAllObjects should contain the expected data object with extends
* Validate getAllObjects should contain the expected data object with extends.
*
* @return void
* @throws Exception
*/
public function testGetAllObjectsWithDataExtends()
public function testGetAllObjectsWithDataExtends(): void
{
ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT_WITH_EXTEND);

Expand All @@ -229,9 +243,12 @@ public function testGetAllObjectsWithDataExtends()
}

/**
* getObject should return the expected data object with extended data if it exists
* Validate getObject should return the expected data object with extended data if it exists.
*
* @return void
* @throws Exception
*/
public function testGetObjectWithDataExtends()
public function testGetObjectWithDataExtends(): void
{
ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT_WITH_EXTEND);

Expand All @@ -252,15 +269,18 @@ public function testGetObjectWithDataExtends()
}

/**
* getAllObjects should throw TestFrameworkException exception if some data extends itself
* Validate getAllObjects should throw TestFrameworkException exception if some data extends itself.
*
* @return void
* @throws Exception
*/
public function testGetAllObjectsWithDataExtendsItself()
public function testGetAllObjectsWithDataExtendsItself(): void
{
ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT_WITH_EXTEND_INVALID);

$this->expectException(\Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException::class);
$this->expectException(TestFrameworkException::class);
$this->expectExceptionMessage(
"Mftf Data can not extend from itself: "
'Mftf Data can not extend from itself: '
. self::PARSER_OUTPUT_WITH_EXTEND_INVALID['entity']['EntityOne']['name']
);

Expand All @@ -269,15 +289,18 @@ public function testGetAllObjectsWithDataExtendsItself()
}

/**
* getObject should throw TestFrameworkException exception if requested data extends itself
* Validate getObject should throw TestFrameworkException exception if requested data extends itself.
*
* @return void
* @throws Exception
*/
public function testGetObjectWithDataExtendsItself()
public function testGetObjectWithDataExtendsItself(): void
{
ObjectHandlerUtil::mockDataObjectHandlerWithData(self::PARSER_OUTPUT_WITH_EXTEND_INVALID);

$this->expectException(\Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException::class);
$this->expectException(TestFrameworkException::class);
$this->expectExceptionMessage(
"Mftf Data can not extend from itself: "
'Mftf Data can not extend from itself: '
. self::PARSER_OUTPUT_WITH_EXTEND_INVALID['entity']['EntityOne']['name']
);

Expand All @@ -288,7 +311,7 @@ public function testGetObjectWithDataExtendsItself()
}

/**
* clean up function runs after all tests
* @inheritDoc
*/
public static function tearDownAfterClass(): void
{
Expand Down
Loading

0 comments on commit ac6cef4

Please sign in to comment.