File tree 2 files changed +42
-2
lines changed
dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers
src/Magento/FunctionalTestingFramework/Test/Util
2 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,44 @@ public function testGetTestsByGroup()
141
141
$ this ->assertArrayNotHasKey ('excludeTest ' , $ tests );
142
142
}
143
143
144
+ /**
145
+ * Tests the function used to parse and determine a test's Module (used in allure Features annotation)
146
+ *
147
+ * @throws \Exception
148
+ */
149
+ public function testGetTestWithModuleName ()
150
+ {
151
+ // set up Test Data
152
+ $ moduleExpected = "SomeTestModule " ;
153
+ $ filepath = DIRECTORY_SEPARATOR .
154
+ "user " .
155
+ "magento2ce " . DIRECTORY_SEPARATOR .
156
+ "dev " . DIRECTORY_SEPARATOR .
157
+ "tests " . DIRECTORY_SEPARATOR .
158
+ "acceptance " . DIRECTORY_SEPARATOR .
159
+ "tests " . DIRECTORY_SEPARATOR .
160
+ $ moduleExpected . DIRECTORY_SEPARATOR .
161
+ "Tests " . DIRECTORY_SEPARATOR .
162
+ "text.xml " ;
163
+ // set up mock data
164
+ $ testDataArrayBuilder = new TestDataArrayBuilder ();
165
+ $ mockData = $ testDataArrayBuilder
166
+ ->withAnnotations ()
167
+ ->withFailedHook ()
168
+ ->withAfterHook ()
169
+ ->withBeforeHook ()
170
+ ->withTestActions ()
171
+ ->withFileName ($ filepath )
172
+ ->build ();
173
+ $ this ->setMockParserOutput (['tests ' => $ mockData ]);
174
+ // Execute Test Method
175
+ $ toh = TestObjectHandler::getInstance ();
176
+ $ actualTestObject = $ toh ->getObject ($ testDataArrayBuilder ->testName );
177
+ $ moduleName = $ actualTestObject ->getAnnotations ()["features " ][0 ];
178
+ //performAsserts
179
+ $ this ->assertEquals ($ moduleExpected , $ moduleName );
180
+ }
181
+
144
182
/**
145
183
* Function used to set mock for parser return and force init method to run between tests.
146
184
*
Original file line number Diff line number Diff line change @@ -134,11 +134,13 @@ public function extractTestData($testData)
134
134
*/
135
135
private function extractModuleName ($ path )
136
136
{
137
- if ($ path === "" ) {
137
+ if (empty ( $ path) ) {
138
138
return "NO MODULE DETECTED " ;
139
139
}
140
140
$ paths = explode (DIRECTORY_SEPARATOR , $ path );
141
- if ($ paths [count ($ paths )-3 ] == "Mftf " ) {
141
+ if (!isset ($ paths [count ($ paths )-3 ])) {
142
+ return "NO MODULE DETECTED " ;
143
+ } elseif ($ paths [count ($ paths )-3 ] == "Mftf " ) {
142
144
// app/code/Magento/[Analytics]/Test/Mftf/Test/SomeText.xml
143
145
return $ paths [count ($ paths )-5 ];
144
146
}
You can’t perform that action at this time.
0 commit comments