|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +namespace tests\unit\Magento\FunctionalTestFramework\Test\Util; |
| 7 | + |
| 8 | +use Magento\FunctionalTestingFramework\Test\Util\ActionGroupObjectExtractor; |
| 9 | +use Magento\FunctionalTestingFramework\Util\MagentoTestCase; |
| 10 | +use tests\unit\Util\TestLoggingUtil; |
| 11 | + |
| 12 | +class ActionGroupObjectExtractorTest extends MagentoTestCase |
| 13 | +{ |
| 14 | + /** @var ActionGroupObjectExtractor */ |
| 15 | + private $testActionGroupObjectExtractor; |
| 16 | + |
| 17 | + /** |
| 18 | + * Setup method |
| 19 | + */ |
| 20 | + public function setUp() |
| 21 | + { |
| 22 | + $this->testActionGroupObjectExtractor = new ActionGroupObjectExtractor(); |
| 23 | + TestLoggingUtil::getInstance()->setMockLoggingUtil(); |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * Tests basic action object extraction with an empty stepKey |
| 28 | + */ |
| 29 | + public function testEmptyStepKey() |
| 30 | + { |
| 31 | + $this->expectExceptionMessage("StepKeys cannot be empty. Action='sampleAction' in filename.xml"); |
| 32 | + $this->testActionGroupObjectExtractor->extractActionGroup($this->createBasicActionObjectArray("")); |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * Utility function to return mock parser output for testing extraction into ActionObjects. |
| 37 | + * |
| 38 | + * @param string $stepKey |
| 39 | + * @param string $actionGroup |
| 40 | + * @param string $filename |
| 41 | + * @return array |
| 42 | + */ |
| 43 | + private function createBasicActionObjectArray( |
| 44 | + $stepKey = 'testAction1', |
| 45 | + $actionGroup = "actionGroup", |
| 46 | + $filename = "filename.xml" |
| 47 | + ) { |
| 48 | + $baseArray = [ |
| 49 | + 'nodeName' => 'actionGroup', |
| 50 | + 'name' => $actionGroup, |
| 51 | + 'filename' => $filename, |
| 52 | + $stepKey => [ |
| 53 | + "nodeName" => "sampleAction", |
| 54 | + "stepKey" => $stepKey, |
| 55 | + "someAttribute" => "someAttributeValue" |
| 56 | + ] |
| 57 | + ]; |
| 58 | + return $baseArray; |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * clean up function runs after all tests |
| 63 | + */ |
| 64 | + public static function tearDownAfterClass() |
| 65 | + { |
| 66 | + TestLoggingUtil::getInstance()->clearMockLoggingUtil(); |
| 67 | + } |
| 68 | +} |
0 commit comments