diff --git a/dev/tests/_bootstrap.php b/dev/tests/_bootstrap.php index 0adfc2e74..4364b7f9a 100644 --- a/dev/tests/_bootstrap.php +++ b/dev/tests/_bootstrap.php @@ -30,7 +30,7 @@ // set mftf appplication context \Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::create( true, - \Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::GENERATION_PHASE, + \Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::UNIT_TEST_PHASE, true, false ); diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/AnnotationExtractorTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/AnnotationExtractorTest.php index 752cde89c..fcdad2e40 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/AnnotationExtractorTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/AnnotationExtractorTest.php @@ -114,7 +114,7 @@ public function testMissingAnnotations() // Asserts TestLoggingUtil::getInstance()->validateMockLogStatement( 'warning', - 'Test testFileName is missing required annotations.', + 'DEPRECATION: Test testFileName is missing required annotations.', [ 'testName' => 'testFileName', 'missingAnnotations' => "title, description, severity" diff --git a/dev/tests/unit/Util/TestLoggingUtil.php b/dev/tests/unit/Util/TestLoggingUtil.php index 7c2ecc142..655048552 100644 --- a/dev/tests/unit/Util/TestLoggingUtil.php +++ b/dev/tests/unit/Util/TestLoggingUtil.php @@ -8,6 +8,7 @@ use AspectMock\Test as AspectMock; use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil; +use Magento\FunctionalTestingFramework\Util\Logger\MftfLogger; use Monolog\Handler\TestHandler; use Monolog\Logger; use PHPUnit\Framework\Assert; @@ -54,7 +55,7 @@ public static function getInstance() public function setMockLoggingUtil() { $this->testLogHandler = new TestHandler(); - $testLogger = new Logger('testLogger'); + $testLogger = new MftfLogger('testLogger'); $testLogger->pushHandler($this->testLogHandler); $mockLoggingUtil = AspectMock::double( LoggingUtil::class, diff --git a/src/Magento/FunctionalTestingFramework/Config/MftfApplicationConfig.php b/src/Magento/FunctionalTestingFramework/Config/MftfApplicationConfig.php index 76403e1c1..eeabdf117 100644 --- a/src/Magento/FunctionalTestingFramework/Config/MftfApplicationConfig.php +++ b/src/Magento/FunctionalTestingFramework/Config/MftfApplicationConfig.php @@ -11,7 +11,8 @@ class MftfApplicationConfig { const GENERATION_PHASE = "generation"; const EXECUTION_PHASE = "execution"; - const MFTF_PHASES = [self::GENERATION_PHASE, self::EXECUTION_PHASE]; + const UNIT_TEST_PHASE = "testing"; + const MFTF_PHASES = [self::GENERATION_PHASE, self::EXECUTION_PHASE, self::UNIT_TEST_PHASE]; /** * Determines whether the user has specified a force option for generation diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Util/DataExtensionUtil.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Util/DataExtensionUtil.php index 53f0a6e6c..1123531ed 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Util/DataExtensionUtil.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Util/DataExtensionUtil.php @@ -52,8 +52,9 @@ public function extendEntity($entityObject) PHP_EOL ); } - if (MftfApplicationConfig::getConfig()->verboseEnabled()) { - echo("Extending Data: " . $parentEntity->getName() . " => " . $entityObject->getName() . PHP_EOL); + if (MftfApplicationConfig::getConfig()->verboseEnabled() && + MftfApplicationConfig::getConfig()->getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE) { + print("Extending Data: " . $parentEntity->getName() . " => " . $entityObject->getName() . PHP_EOL); } //get parent entity type if child does not have a type diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php index 4a5dc4696..0c73b9c86 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php @@ -280,7 +280,7 @@ public function trimAssertionAttributes() if (!empty($oldAttributes)) { $appConfig = MftfApplicationConfig::getConfig(); if ($appConfig->getPhase() == MftfApplicationConfig::GENERATION_PHASE && $appConfig->verboseEnabled()) { - LoggingUtil::getInstance()->getLogger(ActionObject::class)->warning( + LoggingUtil::getInstance()->getLogger(ActionObject::class)->deprecation( "use of one line Assertion actions will be deprecated in MFTF 3.0.0, please use nested syntax", ["action" => $this->type, "stepKey" => $this->stepKey] ); diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/AnnotationExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/AnnotationExtractor.php index 909b72906..fa3f675bf 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/AnnotationExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/AnnotationExtractor.php @@ -114,7 +114,7 @@ private function validateMissingAnnotations($annotationObjects, $filename) if (!empty($missingAnnotations)) { $message = "Test {$filename} is missing required annotations."; - LoggingUtil::getInstance()->getLogger(ActionObject::class)->warning( + LoggingUtil::getInstance()->getLogger(ActionObject::class)->deprecation( $message, ["testName" => $filename, "missingAnnotations" => implode(", ", $missingAnnotations)] ); diff --git a/src/Magento/FunctionalTestingFramework/Util/Logger/LoggingUtil.php b/src/Magento/FunctionalTestingFramework/Util/Logger/LoggingUtil.php index 51a4e5d8c..536a4a698 100644 --- a/src/Magento/FunctionalTestingFramework/Util/Logger/LoggingUtil.php +++ b/src/Magento/FunctionalTestingFramework/Util/Logger/LoggingUtil.php @@ -52,7 +52,7 @@ private function __construct() * existing instance is simply returned. * * @param string $clazz - * @return Logger + * @return MftfLogger * @throws \Exception */ public function getLogger($clazz) @@ -62,7 +62,7 @@ public function getLogger($clazz) } if (!array_key_exists($clazz, $this->loggers)) { - $logger = new Logger($clazz); + $logger = new MftfLogger($clazz); $logger->pushHandler(new StreamHandler($this->getLoggingPath())); $this->loggers[$clazz] = $logger; } diff --git a/src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php b/src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php new file mode 100644 index 000000000..5844858a0 --- /dev/null +++ b/src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php @@ -0,0 +1,31 @@ +getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE) { + print ($message . json_encode($context) . "\n"); + } + parent::warning($message, $context); + } +}