ExtendedGenerationTest.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace tests\verification\Tests;
  7. use Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler;
  8. use Magento\FunctionalTestingFramework\Util\TestGenerator;
  9. use tests\util\MftfTestCase;
  10. class ExtendedGenerationTest extends MftfTestCase
  11. {
  12. /**
  13. * Tests flat generation of a test that is referenced by another test
  14. *
  15. * @throws \Exception
  16. * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
  17. */
  18. public function testExtendedParentTestGeneration()
  19. {
  20. $this->generateAndCompareTest('ParentExtendedTest');
  21. }
  22. /**
  23. * Tests generation of test that extends based on another test when replacing actions
  24. *
  25. * @throws \Exception
  26. * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
  27. */
  28. public function testExtendedTestGenerationReplaceStepKey()
  29. {
  30. $this->generateAndCompareTest('ChildExtendedTestReplace');
  31. }
  32. /**
  33. * Tests generation of test that extends based on another test when replacing actions in hooks
  34. *
  35. * @throws \Exception
  36. * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
  37. */
  38. public function testExtendedTestGenerationReplaceHook()
  39. {
  40. $this->generateAndCompareTest('ChildExtendedTestReplaceHook');
  41. }
  42. /**
  43. * Tests generation of test that extends based on another test when merging actions
  44. *
  45. * @throws \Exception
  46. * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
  47. */
  48. public function testExtendedTestGenerationMergeActions()
  49. {
  50. $this->generateAndCompareTest('ChildExtendedTestMerging');
  51. }
  52. /**
  53. * Tests generation of test that extends based on another test when adding hooks
  54. *
  55. * @throws \Exception
  56. * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
  57. */
  58. public function testExtendedTestGenerationAddHooks()
  59. {
  60. $this->generateAndCompareTest('ChildExtendedTestAddHooks');
  61. }
  62. /**
  63. * Tests generation of test that extends based on another test when removing an action
  64. *
  65. * @throws \Exception
  66. * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
  67. */
  68. public function testExtendedTestGenerationRemoveAction()
  69. {
  70. $this->generateAndCompareTest('ChildExtendedTestRemoveAction');
  71. }
  72. /**
  73. * Tests generation of test that extends based on another test when removing an action
  74. *
  75. * @throws \Exception
  76. * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
  77. */
  78. public function testExtendedTestGenerationRemoveHookAction()
  79. {
  80. $this->generateAndCompareTest('ChildExtendedTestRemoveHookAction');
  81. }
  82. /**
  83. * Tests to ensure extended tests with no parents are not generated
  84. *
  85. * @throws \Exception
  86. * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
  87. */
  88. public function testExtendedTestGenerationNoParent()
  89. {
  90. $testObject = TestObjectHandler::getInstance()->getObject('ChildExtendedTestNoParent');
  91. $test = TestGenerator::getInstance(null, [$testObject]);
  92. $test->createAllTestFiles();
  93. $cestFile = $test->getExportDir() .
  94. DIRECTORY_SEPARATOR .
  95. $testObject->getCodeceptionName() .
  96. ".php";
  97. $this->assertFalse(file_exists($cestFile));
  98. }
  99. /**
  100. * Tests extending a skipped test generation.
  101. *
  102. * @throws \Exception
  103. * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
  104. */
  105. public function testExtendingSkippedGeneration()
  106. {
  107. $this->generateAndCompareTest('ExtendingSkippedTest');
  108. }
  109. /**
  110. * Tests extending and removing parent steps test generation.
  111. *
  112. * @throws \Exception
  113. * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
  114. */
  115. public function testExtendingAndRemovingStepsGeneration()
  116. {
  117. $this->generateAndCompareTest('ExtendedChildTestNotInSuite');
  118. }
  119. }