diff options
author | Lee Rowlands <lee.rowlands@previousnext.com.au> | 2023-09-26 09:14:17 +1000 |
---|---|---|
committer | Lee Rowlands <lee.rowlands@previousnext.com.au> | 2023-09-26 09:14:17 +1000 |
commit | 6d93485084c49e3d5cc37cc3888e2c2047e0c462 (patch) | |
tree | 8cf2d27fde3a6a9b14efe7618dae26bfb50ef9c6 /core/modules | |
parent | 0af9348ce711d3fcc960cabc39239dc6c1bc894a (diff) | |
download | drupal-6d93485084c49e3d5cc37cc3888e2c2047e0c462.tar.gz drupal-6d93485084c49e3d5cc37cc3888e2c2047e0c462.zip |
Issue #3386458 by catch, quietone, alexpott, larowlan: Add GenericModuleTestBase and use it to test general module things
Diffstat (limited to 'core/modules')
84 files changed, 1065 insertions, 447 deletions
diff --git a/core/modules/action/tests/src/Functional/GenericTest.php b/core/modules/action/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..c67627892dd --- /dev/null +++ b/core/modules/action/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\action\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for action. + * + * @group action + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/announcements_feed/tests/src/Functional/GenericTest.php b/core/modules/announcements_feed/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..63fa6200297 --- /dev/null +++ b/core/modules/announcements_feed/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\announcements_feed\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for announcements_feed. + * + * @group announcements_feed + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/automated_cron/tests/src/Functional/GenericTest.php b/core/modules/automated_cron/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..8e8edc0fc5e --- /dev/null +++ b/core/modules/automated_cron/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\automated_cron\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for automated_cron. + * + * @group automated_cron + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/ban/tests/src/Functional/GenericTest.php b/core/modules/ban/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..a1ca6003f25 --- /dev/null +++ b/core/modules/ban/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\ban\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for ban. + * + * @group ban + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/basic_auth/tests/src/Functional/GenericTest.php b/core/modules/basic_auth/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..678d1bed159 --- /dev/null +++ b/core/modules/basic_auth/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\basic_auth\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for basic_auth. + * + * @group basic_auth + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/big_pipe/tests/src/Functional/GenericTest.php b/core/modules/big_pipe/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..7b5aed92676 --- /dev/null +++ b/core/modules/big_pipe/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\big_pipe\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for big_pipe. + * + * @group big_pipe + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/block/tests/src/Functional/GenericTest.php b/core/modules/block/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..f69d0caed3a --- /dev/null +++ b/core/modules/block/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\block\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for block. + * + * @group block + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/block_content/tests/src/Functional/GenericTest.php b/core/modules/block_content/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..29c93a1708e --- /dev/null +++ b/core/modules/block_content/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\block_content\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for block_content. + * + * @group block_content + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/book/tests/src/Functional/GenericTest.php b/core/modules/book/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..9d88fcb4a9a --- /dev/null +++ b/core/modules/book/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\book\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for book. + * + * @group book + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/breakpoint/tests/src/Functional/GenericTest.php b/core/modules/breakpoint/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..355a09d550d --- /dev/null +++ b/core/modules/breakpoint/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\breakpoint\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for breakpoint. + * + * @group breakpoint + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/ckeditor5/tests/src/Functional/GenericTest.php b/core/modules/ckeditor5/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..7e58cd064f3 --- /dev/null +++ b/core/modules/ckeditor5/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\ckeditor5\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for ckeditor5. + * + * @group ckeditor5 + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/comment/tests/src/Functional/GenericTest.php b/core/modules/comment/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..f6dc8a08545 --- /dev/null +++ b/core/modules/comment/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\comment\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for comment. + * + * @group comment + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/config/tests/src/Functional/GenericTest.php b/core/modules/config/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..97215c10233 --- /dev/null +++ b/core/modules/config/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\config\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for config. + * + * @group config + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/config_translation/tests/src/Functional/GenericTest.php b/core/modules/config_translation/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..9fbe71dcbe3 --- /dev/null +++ b/core/modules/config_translation/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\config_translation\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for config_translation. + * + * @group config_translation + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/contact/tests/src/Functional/GenericTest.php b/core/modules/contact/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..4e2be63a525 --- /dev/null +++ b/core/modules/contact/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\contact\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for contact. + * + * @group contact + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/content_moderation/tests/src/Functional/GenericTest.php b/core/modules/content_moderation/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..25cf6df650e --- /dev/null +++ b/core/modules/content_moderation/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\content_moderation\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for content_moderation. + * + * @group content_moderation + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/content_translation/tests/src/Functional/GenericTest.php b/core/modules/content_translation/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..25efc14fa1a --- /dev/null +++ b/core/modules/content_translation/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\content_translation\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for content_translation. + * + * @group content_translation + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/contextual/tests/src/Functional/GenericTest.php b/core/modules/contextual/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..0387c894d23 --- /dev/null +++ b/core/modules/contextual/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\contextual\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for contextual. + * + * @group contextual + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/datetime/tests/src/Functional/GenericTest.php b/core/modules/datetime/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..98d85e42f8a --- /dev/null +++ b/core/modules/datetime/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\datetime\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for datetime. + * + * @group datetime + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/datetime_range/tests/src/Functional/GenericTest.php b/core/modules/datetime_range/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..0ecab43f512 --- /dev/null +++ b/core/modules/datetime_range/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\datetime_range\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for datetime_range. + * + * @group datetime_range + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/dblog/tests/src/Functional/GenericTest.php b/core/modules/dblog/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..4a05f749ed1 --- /dev/null +++ b/core/modules/dblog/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\dblog\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for dblog. + * + * @group dblog + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/dynamic_page_cache/tests/src/Functional/GenericTest.php b/core/modules/dynamic_page_cache/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..e965f10d3e5 --- /dev/null +++ b/core/modules/dynamic_page_cache/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\dynamic_page_cache\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for dynamic_page_cache. + * + * @group dynamic_page_cache + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/editor/tests/src/Functional/GenericTest.php b/core/modules/editor/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..bdc6a1a3136 --- /dev/null +++ b/core/modules/editor/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\editor\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for editor. + * + * @group editor + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/field/tests/src/Functional/GenericTest.php b/core/modules/field/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..2ab3881cc2d --- /dev/null +++ b/core/modules/field/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\field\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for field. + * + * @group field + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/field_layout/tests/src/Functional/GenericTest.php b/core/modules/field_layout/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..7e1abd41465 --- /dev/null +++ b/core/modules/field_layout/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\field_layout\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for field_layout. + * + * @group field_layout + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/field_ui/tests/src/Functional/GenericTest.php b/core/modules/field_ui/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..394f6122636 --- /dev/null +++ b/core/modules/field_ui/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\field_ui\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for field_ui. + * + * @group field_ui + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/file/tests/src/Functional/GenericTest.php b/core/modules/file/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..a2e594d4663 --- /dev/null +++ b/core/modules/file/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\file\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for file. + * + * @group file + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/filter/tests/src/Functional/GenericTest.php b/core/modules/filter/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..d8948a0aca6 --- /dev/null +++ b/core/modules/filter/tests/src/Functional/GenericTest.php @@ -0,0 +1,23 @@ +<?php + +namespace Drupal\Tests\filter\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for filter. + * + * @group filter + */ +class GenericTest extends GenericModuleTestBase { + + /** + * {@inheritdoc} + */ + protected function preUninstallSteps(): void { + $storage = \Drupal::entityTypeManager()->getStorage('filter_format'); + $text_formats = $storage->loadMultiple(); + $storage->delete($text_formats); + } + +} diff --git a/core/modules/forum/tests/src/Functional/GenericTest.php b/core/modules/forum/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..999f8f35297 --- /dev/null +++ b/core/modules/forum/tests/src/Functional/GenericTest.php @@ -0,0 +1,23 @@ +<?php + +namespace Drupal\Tests\forum\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for forum. + * + * @group forum + */ +class GenericTest extends GenericModuleTestBase { + + /** + * {@inheritdoc} + */ + protected function preUninstallSteps(): void { + $storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); + $terms = $storage->loadMultiple(); + $storage->delete($terms); + } + +} diff --git a/core/modules/help/tests/modules/help_page_test/help_page_test.module b/core/modules/help/tests/modules/help_page_test/help_page_test.module index 49aac7a6b75..079bb8a8799 100644 --- a/core/modules/help/tests/modules/help_page_test/help_page_test.module +++ b/core/modules/help/tests/modules/help_page_test/help_page_test.module @@ -15,7 +15,7 @@ function help_page_test_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { case 'help.page.help_page_test': // Make the help text conform to core standards. See - // \Drupal\system\Tests\Module\InstallUninstallTest::assertHelp(). + // \Drupal\system\Tests\Functional\GenericModuleTestBase::assertHookHelp(). return t('Read the <a href=":url">online documentation for the Help Page Test module</a>.', [':url' => 'http://www.example.com']); case 'help_page_test.has_help': diff --git a/core/modules/help/tests/src/Functional/GenericTest.php b/core/modules/help/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..0458e2e0c2b --- /dev/null +++ b/core/modules/help/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\help\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for help. + * + * @group help + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/help/tests/src/Functional/HelpTopicsSyntaxTest.php b/core/modules/help/tests/src/Functional/HelpTopicsSyntaxTest.php index b4c3d7f0913..cf8ee14cf77 100644 --- a/core/modules/help/tests/src/Functional/HelpTopicsSyntaxTest.php +++ b/core/modules/help/tests/src/Functional/HelpTopicsSyntaxTest.php @@ -13,12 +13,6 @@ use PHPUnit\Framework\AssertionFailedError; /** * Verifies that all core Help topics can be rendered and comply with standards. * - * @todo This test should eventually be folded into - * Drupal\Tests\system\Functional\Module\InstallUninstallTest - * when help_topics becomes stable, so that it will test with only one module - * at a time installed and not duplicate the effort of installing. See issue - * https://www.drupal.org/project/drupal/issues/3074040 - * * @group help */ class HelpTopicsSyntaxTest extends BrowserTestBase { diff --git a/core/modules/history/tests/src/Functional/GenericTest.php b/core/modules/history/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..a242d3113fc --- /dev/null +++ b/core/modules/history/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\history\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for history. + * + * @group history + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/image/tests/src/Functional/GenericTest.php b/core/modules/image/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..bedf88874e5 --- /dev/null +++ b/core/modules/image/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\image\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for image. + * + * @group image + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/inline_form_errors/tests/src/Functional/GenericTest.php b/core/modules/inline_form_errors/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..8d6f294ec86 --- /dev/null +++ b/core/modules/inline_form_errors/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\inline_form_errors\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for inline_form_errors. + * + * @group inline_form_errors + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/jsonapi/tests/src/Functional/GenericTest.php b/core/modules/jsonapi/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..583ebb7b560 --- /dev/null +++ b/core/modules/jsonapi/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\jsonapi\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for jsonapi. + * + * @group jsonapi + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/language/tests/src/Functional/GenericTest.php b/core/modules/language/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..f0ee4822ab7 --- /dev/null +++ b/core/modules/language/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\language\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for language. + * + * @group language + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/layout_builder/tests/src/Functional/GenericTest.php b/core/modules/layout_builder/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..9fffe5b5d66 --- /dev/null +++ b/core/modules/layout_builder/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\layout_builder\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for layout_builder. + * + * @group layout_builder + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/layout_discovery/tests/src/Functional/GenericTest.php b/core/modules/layout_discovery/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..d93515892af --- /dev/null +++ b/core/modules/layout_discovery/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\layout_discovery\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for layout_discovery. + * + * @group layout_discovery + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/link/tests/src/Functional/GenericTest.php b/core/modules/link/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..099d55b064c --- /dev/null +++ b/core/modules/link/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\link\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for link. + * + * @group link + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/locale/tests/src/Functional/GenericTest.php b/core/modules/locale/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..1105d94d8a8 --- /dev/null +++ b/core/modules/locale/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\locale\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for locale. + * + * @group locale + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/media/tests/src/Functional/GenericTest.php b/core/modules/media/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..afff4719ab0 --- /dev/null +++ b/core/modules/media/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\media\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for media. + * + * @group media + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/media_library/tests/src/Functional/GenericTest.php b/core/modules/media_library/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..e42b2a8be08 --- /dev/null +++ b/core/modules/media_library/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\media_library\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for media_library. + * + * @group media_library + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/menu_link_content/tests/src/Functional/GenericTest.php b/core/modules/menu_link_content/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..6ec3b0d9a7d --- /dev/null +++ b/core/modules/menu_link_content/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\menu_link_content\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for menu_link_content. + * + * @group menu_link_content + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/menu_ui/tests/src/Functional/GenericTest.php b/core/modules/menu_ui/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..4961f6b6e23 --- /dev/null +++ b/core/modules/menu_ui/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\menu_ui\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for menu_ui. + * + * @group menu_ui + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/migrate/tests/src/Functional/GenericTest.php b/core/modules/migrate/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..0663750c3fd --- /dev/null +++ b/core/modules/migrate/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\migrate\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for migrate. + * + * @group migrate + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/migrate_drupal/tests/src/Functional/GenericTest.php b/core/modules/migrate_drupal/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..bedb2d9d3d5 --- /dev/null +++ b/core/modules/migrate_drupal/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\migrate_drupal\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for migrate_drupal. + * + * @group migrate_drupal + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/GenericTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..18f4f4ac85f --- /dev/null +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\migrate_drupal_ui\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for migrate_drupal_ui. + * + * @group migrate_drupal_ui + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/mysql/tests/src/Functional/GenericTest.php b/core/modules/mysql/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..6b086fd5dc9 --- /dev/null +++ b/core/modules/mysql/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\mysql\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for mysql. + * + * @group mysql + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/node/tests/src/Functional/GenericTest.php b/core/modules/node/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..100f1d26ee4 --- /dev/null +++ b/core/modules/node/tests/src/Functional/GenericTest.php @@ -0,0 +1,23 @@ +<?php + +namespace Drupal\Tests\node\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for node. + * + * @group node + */ +class GenericTest extends GenericModuleTestBase { + + /** + * {@inheritdoc} + */ + protected function setUp(): void { + // Ensure the generic test base is working as expected. + $this->assertSame('node', $this->getModule()); + parent::setUp(); + } + +} diff --git a/core/modules/options/tests/src/Functional/GenericTest.php b/core/modules/options/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..61f5954d8a1 --- /dev/null +++ b/core/modules/options/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\options\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for options. + * + * @group options + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/page_cache/tests/src/Functional/GenericTest.php b/core/modules/page_cache/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..20bc76fd058 --- /dev/null +++ b/core/modules/page_cache/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\page_cache\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for page_cache. + * + * @group page_cache + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/path/tests/src/Functional/GenericTest.php b/core/modules/path/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..83bdc7a1f47 --- /dev/null +++ b/core/modules/path/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\path\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for path. + * + * @group path + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/path_alias/tests/src/Functional/GenericTest.php b/core/modules/path_alias/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..39e0a389005 --- /dev/null +++ b/core/modules/path_alias/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\path_alias\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for path_alias. + * + * @group path_alias + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/pgsql/tests/src/Functional/GenericTest.php b/core/modules/pgsql/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..eba843d03df --- /dev/null +++ b/core/modules/pgsql/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\pgsql\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for pgsql. + * + * @group pgsql + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/phpass/tests/src/Functional/GenericTest.php b/core/modules/phpass/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..7036462f024 --- /dev/null +++ b/core/modules/phpass/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\phpass\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for phpass. + * + * @group phpass + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/responsive_image/tests/src/Functional/GenericTest.php b/core/modules/responsive_image/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..83385caf8e8 --- /dev/null +++ b/core/modules/responsive_image/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\responsive_image\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for responsive_image. + * + * @group responsive_image + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/rest/tests/src/Functional/GenericTest.php b/core/modules/rest/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..74eeceb9c24 --- /dev/null +++ b/core/modules/rest/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\rest\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for rest. + * + * @group rest + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/sdc/tests/src/Functional/GenericTest.php b/core/modules/sdc/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..f302913ca0d --- /dev/null +++ b/core/modules/sdc/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\sdc\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for sdc. + * + * @group sdc + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/search/tests/src/Functional/GenericTest.php b/core/modules/search/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..e9dfa226861 --- /dev/null +++ b/core/modules/search/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\search\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for search. + * + * @group search + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/serialization/tests/src/Functional/GenericTest.php b/core/modules/serialization/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..cc9a29cf00c --- /dev/null +++ b/core/modules/serialization/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\serialization\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for serialization. + * + * @group serialization + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/settings_tray/tests/src/Functional/GenericTest.php b/core/modules/settings_tray/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..f46af7c0000 --- /dev/null +++ b/core/modules/settings_tray/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\settings_tray\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for settings_tray. + * + * @group settings_tray + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/shortcut/tests/src/Functional/GenericTest.php b/core/modules/shortcut/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..399acc621b4 --- /dev/null +++ b/core/modules/shortcut/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\shortcut\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for shortcut. + * + * @group shortcut + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/sqlite/tests/src/Functional/GenericTest.php b/core/modules/sqlite/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..6857183372f --- /dev/null +++ b/core/modules/sqlite/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\sqlite\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for sqlite. + * + * @group sqlite + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/statistics/tests/src/Functional/GenericTest.php b/core/modules/statistics/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..281fc907ec8 --- /dev/null +++ b/core/modules/statistics/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\statistics\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for statistics. + * + * @group statistics + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/syslog/tests/src/Functional/GenericTest.php b/core/modules/syslog/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..ab4a970d5dd --- /dev/null +++ b/core/modules/syslog/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\syslog\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for syslog. + * + * @group syslog + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.module b/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.module index a2321aaf793..3b7f5f4b052 100644 --- a/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.module +++ b/core/modules/system/tests/modules/experimental_module_requirements_test/experimental_module_requirements_test.module @@ -11,8 +11,7 @@ function experimental_module_requirements_test_help($route_name) { switch ($route_name) { case 'help.page.experimental_module_requirements_test': - // Make the help text conform to core standards. See - // \Drupal\system\Tests\Module\InstallUninstallTest::assertHelp(). + // Make the help text conform to core standards. return t('The Experimental Requirements Test module is not done yet. It may eat your data, but you can read the <a href=":url">online documentation for the Experimental Requirements Test module</a>.', [':url' => 'http://www.example.com']); } } diff --git a/core/modules/system/tests/modules/experimental_module_test/experimental_module_test.module b/core/modules/system/tests/modules/experimental_module_test/experimental_module_test.module index 1f5072085f5..937f1f033e6 100644 --- a/core/modules/system/tests/modules/experimental_module_test/experimental_module_test.module +++ b/core/modules/system/tests/modules/experimental_module_test/experimental_module_test.module @@ -14,8 +14,7 @@ function experimental_module_test_help($route_name, RouteMatchInterface $route_m switch ($route_name) { case 'help.page.experimental_module_test': - // Make the help text conform to core standards. See - // \Drupal\system\Tests\Module\InstallUninstallTest::assertHelp(). + // Make the help text conform to core standards. return t('The Experimental Test module is not done yet. It may eat your data, but you can read the <a href=":url">online documentation for the Experimental Test module</a>.', [':url' => 'http://www.example.com']); } diff --git a/core/modules/system/tests/src/Functional/GenericTest.php b/core/modules/system/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..5311043d9f5 --- /dev/null +++ b/core/modules/system/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\system\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for system. + * + * @group system + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/system/tests/src/Functional/Module/GenericModuleTestBase.php b/core/modules/system/tests/src/Functional/Module/GenericModuleTestBase.php new file mode 100644 index 00000000000..aa3d81e7a4f --- /dev/null +++ b/core/modules/system/tests/src/Functional/Module/GenericModuleTestBase.php @@ -0,0 +1,83 @@ +<?php + +namespace Drupal\Tests\system\Functional\Module; + +use Drupal\Core\Database\Database; +use Drupal\Tests\BrowserTestBase; + +/** + * Runs a series of generic tests for one module. + */ +abstract class GenericModuleTestBase extends BrowserTestBase { + + /** + * {@inheritdoc} + */ + protected static $modules = [ + 'help', + ]; + + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + + /** + * Get the module name. + * + * @return string + * The module to test. + */ + protected function getModule(): string { + return explode('\\', get_class($this))[2]; + } + + /** + * Checks some generic things about a module. + */ + public function testModuleGenericIssues(): void { + $module = $this->getModule(); + \Drupal::service('module_installer')->install([$module]); + $info = \Drupal::service('extension.list.module')->getExtensionInfo($module); + if (!empty($info['required']) && !empty($info['hidden'])) { + $this->markTestSkipped('Nothing to assert for hidden, required modules.'); + } + $this->drupalLogin($this->rootUser); + $this->assertHookHelp($module); + + if (empty($info['required'])) { + $connection = Database::getConnection(); + + // When the database driver is provided by a module, then that module + // cannot be uninstalled. + if ($module !== $connection->getProvider()) { + // Check that the module can be uninstalled and then re-installed again. + $this->preUnInstallSteps(); + $this->assertTrue(\Drupal::service('module_installer')->uninstall([$module]), "Failed to uninstall '$module' module"); + $this->assertTrue(\Drupal::service('module_installer')->install([$module]), "Failed to install '$module' module"); + } + } + } + + /** + * Verifies hook_help() syntax. + * + * @param string $module + * The module. + */ + protected function assertHookHelp(string $module): void { + $info = \Drupal::service('extension.list.module')->getExtensionInfo($module); + if (empty($info['hidden'])) { + $this->drupalGet('admin/help/' . $module); + $this->assertSession()->statusCodeEquals(200); + $this->assertSession()->pageTextContains($info['name'] . ' module'); + $this->assertSession()->linkExists('online documentation for the ' . $info['name'] . ' module', 0, "Correct online documentation link is in the help page for $module"); + } + } + + /** + * Helper to perform any steps required prior to uninstalling a module. + */ + protected function preUnInstallSteps(): void {} + +} diff --git a/core/modules/system/tests/src/Functional/Module/GenericTest.php b/core/modules/system/tests/src/Functional/Module/GenericTest.php new file mode 100644 index 00000000000..b3457048cd6 --- /dev/null +++ b/core/modules/system/tests/src/Functional/Module/GenericTest.php @@ -0,0 +1,10 @@ +<?php + +namespace Drupal\Tests\system\Functional\Module; + +/** + * Generic test for system module. + * + * @group system + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php deleted file mode 100644 index 808235a9bf4..00000000000 --- a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php +++ /dev/null @@ -1,436 +0,0 @@ -<?php - -namespace Drupal\Tests\system\Functional\Module; - -use Drupal\Core\Extension\ExtensionLifecycle; -use Drupal\Core\Logger\RfcLogLevel; -use Drupal\workspaces\Entity\Workspace; - -/** - * Install/uninstall core module and confirm table creation/deletion. - * - * @group #slow - * @group Module - */ -class InstallUninstallTest extends ModuleTestBase { - - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; - - /** - * {@inheritdoc} - */ - protected static $modules = [ - 'system_test', - 'dblog', - 'taxonomy', - 'update_test_postupdate', - ]; - - /** - * Tests that a fixed set of modules can be installed and uninstalled. - */ - public function testInstallUninstall() { - // Set a variable so that the hook implementations in system_test.module - // will display messages via - // \Drupal\Core\Messenger\MessengerInterface::addStatus(). - $this->container->get('state')->set('system_test.verbose_module_hooks', TRUE); - - // Install and uninstall module_test to ensure hook_preinstall_module and - // hook_preuninstall_module are fired as expected. - $this->container->get('module_installer')->install(['module_test']); - $this->assertEquals('module_test', $this->container->get('state')->get('system_test_preinstall_module')); - $this->container->get('module_installer')->uninstall(['module_test']); - $this->assertEquals('module_test', $this->container->get('state')->get('system_test_preuninstall_module')); - $this->resetAll(); - - $all_modules = $this->container->get('extension.list.module')->getList(); - - // Test help on required modules, but do not test uninstalling. - $required_modules = array_filter($all_modules, function ($module) { - if (!empty($module->info['required']) || $module->status == TRUE) { - if ($module->info['package'] != 'Testing' && empty($module->info['hidden'])) { - return TRUE; - } - } - return FALSE; - }); - - $required_modules['help'] = $all_modules['help']; - - // Filter out contrib, hidden, testing, experimental, and deprecated - // modules. We also don't need to enable modules that are already enabled. - $all_modules = array_filter($all_modules, function ($module) { - if (!empty($module->info['hidden']) - || !empty($module->info['required']) - || $module->status == TRUE - || $module->info['package'] === 'Testing' - || $module->info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::DEPRECATED) { - return FALSE; - } - return TRUE; - }); - - // Install the Help module, and verify it installed successfully. - unset($all_modules['help']); - $this->assertModuleNotInstalled('help'); - $edit = []; - $edit["modules[help][enable]"] = TRUE; - $this->drupalGet('admin/modules'); - $this->submitForm($edit, 'Install'); - $this->assertSession()->pageTextContains('has been enabled'); - $this->assertSession()->pageTextContains('hook_modules_installed fired for help'); - $this->assertModuleSuccessfullyInstalled('help'); - - // Add new role to allow browsing help pages. - $this->adminUser->addRole($this->createRole(['access help pages']))->save(); - - // Test help for the required modules. - foreach ($required_modules as $name => $module) { - $this->assertHelp($name, $module->info['name']); - } - - // Go through each module in the list and try to install and uninstall - // it with its dependencies. - foreach ($all_modules as $name => $module) { - $was_installed_list = \Drupal::moduleHandler()->getModuleList(); - - // Start a list of modules that we expect to be installed this time. - $modules_to_install = [$name]; - foreach (array_keys($module->requires) as $dependency) { - if (isset($all_modules[$dependency])) { - $modules_to_install[] = $dependency; - } - } - - // Check that each module is not yet enabled and does not have any - // database tables yet. - foreach ($modules_to_install as $module_to_install) { - $this->assertModuleNotInstalled($module_to_install); - } - - // Install the module. - $edit = []; - $lifecycle = $module->info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER]; - $edit['modules[' . $name . '][enable]'] = TRUE; - $this->drupalGet('admin/modules'); - $this->submitForm($edit, 'Install'); - - // Handle experimental modules, which require a confirmation screen. - if ($lifecycle === ExtensionLifecycle::EXPERIMENTAL) { - $this->assertSession()->pageTextContains('Are you sure you wish to enable an experimental module?'); - if (count($modules_to_install) > 1) { - // When there are experimental modules, needed dependencies do not - // result in the same page title, but there will be expected text - // indicating they need to be enabled. - $this->assertSession()->pageTextContains('You must enable'); - } - $this->submitForm([], 'Continue'); - } - // Handle deprecated modules, which require a confirmation screen. - elseif ($lifecycle === ExtensionLifecycle::DEPRECATED) { - $this->assertSession()->pageTextContains('Are you sure you wish to enable a deprecated module?'); - if (count($modules_to_install) > 1) { - // When there are deprecated modules, needed dependencies do not - // result in the same page title, but there will be expected text - // indicating they need to be enabled. - $this->assertSession()->pageTextContains('You must enable'); - } - $this->submitForm([], 'Continue'); - } - // Handle the case where modules were installed along with this one and - // where we therefore hit a confirmation screen. - elseif (count($modules_to_install) > 1) { - // Verify that we are on the correct form and that the expected text - // about enabling dependencies appears. - $this->assertSession()->pageTextContains('Some required modules must be enabled'); - $this->assertSession()->pageTextContains('You must enable'); - $this->submitForm([], 'Continue'); - } - - // List the module display names to check the confirmation message. - $module_names = []; - foreach ($modules_to_install as $module_to_install) { - $module_names[] = $all_modules[$module_to_install]->info['name']; - } - if (count($modules_to_install) > 1) { - $this->assertSession()->pageTextContains(count($module_names) . ' modules have been enabled: ' . implode(', ', $module_names)); - } - else { - $this->assertSession()->pageTextContains('Module ' . $module_names[0] . ' has been enabled.'); - } - - // Check that hook_modules_installed() was invoked with the expected list - // of modules, that each module's database tables now exist, and that - // appropriate messages appear in the logs. - foreach ($modules_to_install as $module_to_install) { - $this->assertSession()->pageTextContains('hook_modules_installed fired for ' . $module_to_install); - $this->assertLogMessage('system', "%module module installed.", ['%module' => $module_to_install], RfcLogLevel::INFO); - $this->assertInstallModuleUpdates($module_to_install); - $this->assertModuleSuccessfullyInstalled($module_to_install); - } - - // Verify the help page. - $this->assertHelp($name, $module->info['name']); - - // Uninstall the original module, plus everything else that was installed - // with it. - // @todo Remove in https://www.drupal.org/project/node/3261652 - if ($name == 'forum') { - // Forum has an extra step to be able to uninstall it. - $this->preUninstallForum(); - } - - // Delete all workspaces before uninstall. - if ($name == 'workspaces') { - $workspaces = Workspace::loadMultiple(); - \Drupal::entityTypeManager()->getStorage('workspace')->delete($workspaces); - } - - $now_installed_list = \Drupal::moduleHandler()->getModuleList(); - $added_modules = array_diff(array_keys($now_installed_list), array_keys($was_installed_list)); - while ($added_modules) { - $initial_count = count($added_modules); - foreach ($added_modules as $to_uninstall) { - // See if we can currently uninstall this module (if its dependencies - // have been uninstalled), and do so if we can. - $this->drupalGet('admin/modules/uninstall'); - $checkbox = $this->assertSession()->fieldExists("uninstall[$to_uninstall]"); - if (!$checkbox->hasAttribute('disabled')) { - // This one is eligible for being uninstalled. - $package = $all_modules[$to_uninstall]->info['package']; - $this->assertSuccessfulUninstall($to_uninstall, $package); - $added_modules = array_diff($added_modules, [$to_uninstall]); - } - } - - // If we were not able to find a module to uninstall, fail and exit the - // loop. - $final_count = count($added_modules); - if ($initial_count == $final_count) { - $this->fail('Remaining modules could not be uninstalled for ' . $name); - break; - } - } - } - - // Uninstall the help module and put it back into the list of modules. - $all_modules['help'] = $required_modules['help']; - $this->assertSuccessfulUninstall('help', $required_modules['help']->info['package']); - - // Now that all modules have been tested, go back and try to enable them - // all again at once. This tests two things: - // - That each module can be successfully enabled again after being - // uninstalled. - // - That enabling more than one module at the same time does not lead to - // any errors. - $edit = []; - $count_experimental = 0; - $count_deprecated = 0; - foreach ($all_modules as $name => $module) { - $edit['modules[' . $name . '][enable]'] = TRUE; - if ($module->info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::EXPERIMENTAL) { - $count_experimental++; - } - if ($module->info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::DEPRECATED) { - $count_deprecated++; - } - } - $this->drupalGet('admin/modules'); - $this->submitForm($edit, 'Install'); - - // If there are experimental and deprecated modules, click the confirm form. - if ($count_experimental > 0 && $count_deprecated > 0) { - $this->assertSession()->titleEquals('Are you sure you wish to enable experimental and deprecated modules? | Drupal'); - $this->submitForm([], 'Continue'); - } - // If there are experimental, and no deprecated modules, click the confirm - // form. - elseif ($count_experimental > 0) { - if ($count_experimental === 1) { - $page_title = 'Are you sure you wish to enable an experimental module? | Drupal'; - } - else { - $page_title = 'Are you sure you wish to enable experimental modules? | Drupal'; - } - $this->assertSession()->titleEquals($page_title); - $this->submitForm([], 'Continue'); - } - // If there are deprecated, and no experimental modules, click the confirm - // form. - elseif ($count_deprecated > 0) { - if ($count_deprecated === 1) { - $page_title = 'Are you sure you wish to enable a deprecated module? | Drupal'; - } - else { - $page_title = 'Are you sure you wish to enable deprecated modules? | Drupal'; - } - $this->assertSession()->titleEquals($page_title); - $this->submitForm([], 'Continue'); - } - $this->assertSession()->pageTextContains(count($all_modules) . ' modules have been enabled: '); - } - - /** - * Asserts that a module is not yet installed. - * - * @param string $name - * Name of the module to check. - * - * @internal - */ - protected function assertModuleNotInstalled(string $name): void { - $this->assertModules([$name], FALSE); - $this->assertModuleTablesDoNotExist($name); - } - - /** - * Asserts that a module was successfully installed. - * - * @param string $name - * Name of the module to check. - * - * @internal - */ - protected function assertModuleSuccessfullyInstalled(string $name): void { - $this->assertModules([$name], TRUE); - $this->assertModuleTablesExist($name); - $this->assertModuleConfig($name); - } - - /** - * Uninstalls a module and asserts that it was done correctly. - * - * @param string $module - * The name of the module to uninstall. - * @param string $package - * (optional) The package of the module to uninstall. Defaults - * to 'Core'. - * - * @internal - */ - protected function assertSuccessfulUninstall(string $module, string $package = 'Core'): void { - $edit = []; - $edit['uninstall[' . $module . ']'] = TRUE; - $this->drupalGet('admin/modules/uninstall'); - $this->submitForm($edit, 'Uninstall'); - $this->submitForm([], 'Uninstall'); - $this->assertSession()->pageTextContains('The selected modules have been uninstalled.'); - $this->assertModules([$module], FALSE); - - // Check that the appropriate hook was fired and the appropriate log - // message appears. (But don't check for the log message if the dblog - // module was just uninstalled, since the {watchdog} table won't be there - // anymore.) - $this->assertSession()->pageTextContains('hook_modules_uninstalled fired for ' . $module); - $this->assertLogMessage('system', "%module module uninstalled.", ['%module' => $module], RfcLogLevel::INFO); - - // Check that the module's database tables no longer exist. - $this->assertModuleTablesDoNotExist($module); - // Check that the module's config files no longer exist. - $this->assertNoModuleConfig($module); - $this->assertUninstallModuleUpdates($module); - } - - /** - * Asserts the module post update functions after install. - * - * @param string $module - * The module that got installed. - * - * @internal - */ - protected function assertInstallModuleUpdates(string $module): void { - /** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */ - $post_update_registry = \Drupal::service('update.post_update_registry'); - $all_update_functions = $post_update_registry->getPendingUpdateFunctions(); - $empty_result = TRUE; - foreach ($all_update_functions as $function) { - [$function_module] = explode('_post_update_', $function); - if ($module === $function_module) { - $empty_result = FALSE; - break; - } - } - $this->assertTrue($empty_result, 'Ensures that no pending post update functions are available.'); - - $existing_updates = \Drupal::keyValue('post_update')->get('existing_updates', []); - switch ($module) { - case 'update_test_postupdate': - $expected = [ - 'update_test_postupdate_post_update_first', - 'update_test_postupdate_post_update_second', - 'update_test_postupdate_post_update_test1', - 'update_test_postupdate_post_update_test0', - 'update_test_postupdate_post_update_foo', - 'update_test_postupdate_post_update_bar', - 'update_test_postupdate_post_update_baz', - ]; - $this->assertSame($expected, $existing_updates); - break; - } - } - - /** - * Asserts the module post update functions after uninstall. - * - * @param string $module - * The module that got installed. - * - * @internal - */ - protected function assertUninstallModuleUpdates(string $module): void { - /** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */ - $post_update_registry = \Drupal::service('update.post_update_registry'); - $all_update_functions = $post_update_registry->getPendingUpdateFunctions(); - - switch ($module) { - case 'update_test_postupdate': - $this->assertEmpty(array_intersect(['update_test_postupdate_post_update_first'], $all_update_functions), 'Asserts that no pending post update functions are available.'); - - $existing_updates = \Drupal::keyValue('post_update')->get('existing_updates', []); - $this->assertEmpty(array_intersect(['update_test_postupdate_post_update_first'], $existing_updates), 'Asserts that no post update functions are stored in keyvalue store.'); - break; - } - } - - /** - * Verifies a module's help. - * - * Verifies that the module help page from hook_help() exists and can be - * displayed, and that it contains the phrase "Foo Bar module", where "Foo - * Bar" is the name of the module from the .info.yml file. - * - * @param string $module - * Machine name of the module to verify. - * @param string $name - * Human-readable name of the module to verify. - * - * @internal - */ - protected function assertHelp(string $module, string $name): void { - $this->drupalGet('admin/help/' . $module); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains($name . ' module'); - $this->assertSession()->linkExists('online documentation for the ' . $name . ' module', 0, "Correct online documentation link is in the help page for $module"); - } - - /** - * Deletes forum taxonomy terms, so Forum can be uninstalled. - * - * @todo Remove in https://www.drupal.org/project/node/3261652 - */ - protected function preUninstallForum() { - // There only should be a 'General discussion' term in the 'forums' - // vocabulary, but just delete any terms there in case the name changes. - $query = \Drupal::entityQuery('taxonomy_term')->accessCheck(FALSE); - $query->condition('vid', 'forums'); - $ids = $query->execute(); - $storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); - $terms = $storage->loadMultiple($ids); - $storage->delete($terms); - } - -} diff --git a/core/modules/taxonomy/tests/src/Functional/GenericTest.php b/core/modules/taxonomy/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..8d522ec8bb5 --- /dev/null +++ b/core/modules/taxonomy/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\taxonomy\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for taxonomy. + * + * @group taxonomy + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/telephone/tests/src/Functional/GenericTest.php b/core/modules/telephone/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..f46b44c8880 --- /dev/null +++ b/core/modules/telephone/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\telephone\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for telephone. + * + * @group telephone + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/text/tests/src/Functional/GenericTest.php b/core/modules/text/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..53c7aa05670 --- /dev/null +++ b/core/modules/text/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\text\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for text. + * + * @group text + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/toolbar/tests/src/Functional/GenericTest.php b/core/modules/toolbar/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..e0bdc71d8a2 --- /dev/null +++ b/core/modules/toolbar/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\toolbar\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for toolbar. + * + * @group toolbar + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/tour/tests/src/Functional/GenericTest.php b/core/modules/tour/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..7ba9dab5035 --- /dev/null +++ b/core/modules/tour/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\tour\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for tour. + * + * @group tour + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/tracker/tests/src/Functional/GenericTest.php b/core/modules/tracker/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..5305d4664e7 --- /dev/null +++ b/core/modules/tracker/tests/src/Functional/GenericTest.php @@ -0,0 +1,13 @@ +<?php + +namespace Drupal\Tests\tracker\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for tracker. + * + * @group tracker + * @group legacy + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/update/tests/src/Functional/GenericTest.php b/core/modules/update/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..382db2bf779 --- /dev/null +++ b/core/modules/update/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\update\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for update. + * + * @group update + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/user/tests/src/Functional/GenericTest.php b/core/modules/user/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..46d76972c49 --- /dev/null +++ b/core/modules/user/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\user\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for user. + * + * @group user + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/views/tests/src/Functional/GenericTest.php b/core/modules/views/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..7a2d8575e93 --- /dev/null +++ b/core/modules/views/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\views\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for views. + * + * @group views + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/views_ui/tests/src/Functional/GenericTest.php b/core/modules/views_ui/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..018aec82095 --- /dev/null +++ b/core/modules/views_ui/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\views_ui\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for views_ui. + * + * @group views_ui + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/workflows/tests/src/Functional/GenericTest.php b/core/modules/workflows/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..4cf60632872 --- /dev/null +++ b/core/modules/workflows/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +namespace Drupal\Tests\workflows\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for workflows. + * + * @group workflows + */ +class GenericTest extends GenericModuleTestBase {} diff --git a/core/modules/workspaces/tests/src/Functional/GenericTest.php b/core/modules/workspaces/tests/src/Functional/GenericTest.php new file mode 100644 index 00000000000..7ca8f7d54f7 --- /dev/null +++ b/core/modules/workspaces/tests/src/Functional/GenericTest.php @@ -0,0 +1,23 @@ +<?php + +namespace Drupal\Tests\workspaces\Functional; + +use Drupal\Tests\system\Functional\Module\GenericModuleTestBase; + +/** + * Generic module test for workspaces. + * + * @group workspaces + */ +class GenericTest extends GenericModuleTestBase { + + /** + * {@inheritdoc} + */ + protected function preUninstallSteps(): void { + $storage = \Drupal::entityTypeManager()->getStorage('workspace'); + $workspaces = $storage->loadMultiple(); + $storage->delete($workspaces); + } + +} |