|
24 | 24 | use ReflectionProperty;
|
25 | 25 | use tests\unit\Util\MagentoTestCase;
|
26 | 26 | use tests\unit\Util\TestLoggingUtil;
|
| 27 | +use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException; |
27 | 28 |
|
28 | 29 | class TestGeneratorTest extends MagentoTestCase
|
29 | 30 | {
|
@@ -299,6 +300,104 @@ function ($filename) use (&$generatedTests) {
|
299 | 300 | $this->assertArrayNotHasKey('test2Cest', $generatedTests);
|
300 | 301 | }
|
301 | 302 |
|
| 303 | + /** |
| 304 | + * Test for exception thrown when duplicate arguments found |
| 305 | + * |
| 306 | + * @return void |
| 307 | + * @throws TestFrameworkException |
| 308 | + */ |
| 309 | + public function testIfExceptionThrownWhenDuplicateArgumentsFound() |
| 310 | + { |
| 311 | + $fileContents = '<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 312 | + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> |
| 313 | + <actionGroup name="ActionGroupReturningValueActionGroup"> |
| 314 | + <arguments> |
| 315 | + <argument name="count" type="string"/> |
| 316 | + <argument name="count" type="string"/> |
| 317 | + </arguments> |
| 318 | + <grabMultiple selector="selector" stepKey="grabProducts1"/> |
| 319 | + <assertCount stepKey="assertCount"> |
| 320 | + <expectedResult type="int">{{count}}</expectedResult> |
| 321 | + <actualResult type="variable">grabProducts1</actualResult> |
| 322 | + </assertCount> |
| 323 | + <return value="{$grabProducts1}" stepKey="returnProducts1"/> |
| 324 | + </actionGroup> |
| 325 | + </actionGroups>'; |
| 326 | + $actionInput = 'fakeInput'; |
| 327 | + $actionObject = new ActionObject('fakeAction', 'comment', [ |
| 328 | + 'userInput' => $actionInput |
| 329 | + ]); |
| 330 | + $annotation1 = ['group' => ['someGroupValue']]; |
| 331 | + |
| 332 | + $test1 = new TestObject( |
| 333 | + 'test1', |
| 334 | + ['fakeAction' => $actionObject], |
| 335 | + $annotation1, |
| 336 | + [], |
| 337 | + 'filename' |
| 338 | + ); |
| 339 | + $annotation2 = ['group' => ['someOtherGroupValue']]; |
| 340 | + |
| 341 | + $test2 = new TestObject( |
| 342 | + 'test2', |
| 343 | + ['fakeAction' => $actionObject], |
| 344 | + $annotation2, |
| 345 | + [], |
| 346 | + 'filename' |
| 347 | + ); |
| 348 | + $testGeneratorObject = TestGenerator::getInstance('', ['sampleTest' => $test1, 'test2' => $test2]); |
| 349 | + $result = $testGeneratorObject->throwExceptionIfDuplicateArgumentsFound($testGeneratorObject); |
| 350 | + $this->assertEquals($result, ""); |
| 351 | + } |
| 352 | + |
| 353 | + /** |
| 354 | + * Test for exception not thrown when duplicate arguments not found |
| 355 | + * |
| 356 | + * @return void |
| 357 | + */ |
| 358 | + public function testIfExceptionNotThrownWhenDuplicateArgumentsNotFound() |
| 359 | + { |
| 360 | + $fileContents = '<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 361 | + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> |
| 362 | + <actionGroup name="ActionGroupReturningValueActionGroup"> |
| 363 | + <arguments> |
| 364 | + <argument name="count" type="string"/> |
| 365 | + </arguments> |
| 366 | + <grabMultiple selector="selector" stepKey="grabProducts1"/> |
| 367 | + <assertCount stepKey="assertCount"> |
| 368 | + <expectedResult type="int">{{count}}</expectedResult> |
| 369 | + <actualResult type="variable">grabProducts1</actualResult> |
| 370 | + </assertCount> |
| 371 | + <return value="{$grabProducts1}" stepKey="returnProducts1"/> |
| 372 | + </actionGroup> |
| 373 | + </actionGroups>'; |
| 374 | + $actionInput = 'fakeInput'; |
| 375 | + $actionObject = new ActionObject('fakeAction', 'comment', [ |
| 376 | + 'userInput' => $actionInput |
| 377 | + ]); |
| 378 | + $annotation1 = ['group' => ['someGroupValue']]; |
| 379 | + |
| 380 | + $test1 = new TestObject( |
| 381 | + 'test1', |
| 382 | + ['fakeAction' => $actionObject], |
| 383 | + $annotation1, |
| 384 | + [], |
| 385 | + 'filename' |
| 386 | + ); |
| 387 | + $annotation2 = ['group' => ['someOtherGroupValue']]; |
| 388 | + |
| 389 | + $test2 = new TestObject( |
| 390 | + 'test2', |
| 391 | + ['fakeAction' => $actionObject], |
| 392 | + $annotation2, |
| 393 | + [], |
| 394 | + 'filename' |
| 395 | + ); |
| 396 | + $testGeneratorObject = TestGenerator::getInstance('', ['sampleTest' => $test1, 'test2' => $test2]); |
| 397 | + $result = $testGeneratorObject->throwExceptionIfDuplicateArgumentsFound($testGeneratorObject); |
| 398 | + $this->assertEquals($result, ""); |
| 399 | + } |
| 400 | + |
302 | 401 | /**
|
303 | 402 | * Tests that TestGenerator createAllTestFiles correctly filters based on group.
|
304 | 403 | *
|
|
0 commit comments