diff --git a/core/.phpstan-baseline.php b/core/.phpstan-baseline.php index 004f1747f5d7321f9e186faf55dc5df48a0e3c8c..cdc32086a3da070babcb0aa55e0958dfd411bfce 100644 --- a/core/.phpstan-baseline.php +++ b/core/.phpstan-baseline.php @@ -38133,18 +38133,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/system/tests/modules/form_test/src/FormTestServiceObject.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Function hold_test_request\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/modules/system/tests/modules/hold_test/hold_test.module', -]; -$ignoreErrors[] = [ - 'message' => '#^Function hold_test_response\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/modules/system/tests/modules/hold_test/hold_test.module', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\hold_test\\\\EventSubscriber\\\\HoldTestSubscriber\\:\\:hold\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', diff --git a/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php b/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php index 806bdf73a5ca1c1c07f71fd6410d9a65a06512ea..a6ace76f5ceda09a8d7a567508237d92f055a489 100644 --- a/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php +++ b/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php @@ -6,6 +6,7 @@ use Behat\Mink\Element\NodeElement; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; +use Drupal\hold_test\HoldTestHelper; use Drupal\media\Entity\Media; /** @@ -434,11 +435,11 @@ protected function switchToMediaLibraryGrid() { * Switches to the table display of the widget view. */ protected function switchToMediaLibraryTable() { - hold_test_response(TRUE); + HoldTestHelper::responseHold(TRUE); $this->getSession()->getPage()->clickLink('Table'); // Assert the display change is correctly announced for screen readers. $this->assertAnnounceContains('Loading table view.'); - hold_test_response(FALSE); + HoldTestHelper::responseHold(FALSE); $this->assertAnnounceContains('Changed to table view.'); $this->assertMediaLibraryTable(); } diff --git a/core/modules/system/tests/modules/hold_test/hold_test.install b/core/modules/system/tests/modules/hold_test/hold_test.install index 64ef37da27047bcaa3f1d49c72dd7c5d9f6e6ff1..d4f4cc8309d6ef3bb927b676221ac90223690bd4 100644 --- a/core/modules/system/tests/modules/hold_test/hold_test.install +++ b/core/modules/system/tests/modules/hold_test/hold_test.install @@ -7,10 +7,12 @@ declare(strict_types=1); +use Drupal\hold_test\HoldTestHelper; + /** * Implements hook_install(). */ function hold_test_install(): void { - hold_test_request(FALSE); - hold_test_response(FALSE); + HoldTestHelper::requestHold(FALSE); + HoldTestHelper::responseHold(FALSE); } diff --git a/core/modules/system/tests/modules/hold_test/hold_test.module b/core/modules/system/tests/modules/hold_test/hold_test.module deleted file mode 100644 index 37314070d68b63021f07de8fcf731a5d772c9e95..0000000000000000000000000000000000000000 --- a/core/modules/system/tests/modules/hold_test/hold_test.module +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -/** - * @file - * Contains functions for testing hold request/response. - */ - -declare(strict_types=1); - -use Drupal\hold_test\EventSubscriber\HoldTestSubscriber; - -/** - * Request hold. - * - * @param bool $status - * TRUE - enable hold, FALSE - disable hold. - */ -function hold_test_request($status) { - $site_path = \Drupal::getContainer()->getParameter('site.path'); - file_put_contents($site_path . '/hold_test_request.txt', $status); - // If we're releasing the hold wait for a bit to allow the subscriber to read - // the file. - if (!$status) { - usleep(HoldTestSubscriber::WAIT * 2); - } -} - -/** - * Response hold. - * - * @param bool $status - * TRUE - enable hold, FALSE - disable hold. - */ -function hold_test_response($status) { - $site_path = \Drupal::getContainer()->getParameter('site.path'); - file_put_contents($site_path . '/hold_test_response.txt', $status); - // If we're releasing the hold wait for a bit to allow the subscriber to read - // the file. - if (!$status) { - usleep(HoldTestSubscriber::WAIT * 2); - } -} diff --git a/core/modules/system/tests/modules/hold_test/src/HoldTestHelper.php b/core/modules/system/tests/modules/hold_test/src/HoldTestHelper.php new file mode 100644 index 0000000000000000000000000000000000000000..e3518fb0345d64c2e92e27d3ef9ea71677929ffc --- /dev/null +++ b/core/modules/system/tests/modules/hold_test/src/HoldTestHelper.php @@ -0,0 +1,46 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\hold_test; + +use Drupal\hold_test\EventSubscriber\HoldTestSubscriber; + +/** + * Contains methods for testing hold request/response. + */ +class HoldTestHelper { + + /** + * Request hold. + * + * @param bool $status + * TRUE - enable hold, FALSE - disable hold. + */ + public static function requestHold(bool $status): void { + $site_path = \Drupal::getContainer()->getParameter('site.path'); + file_put_contents($site_path . '/hold_test_request.txt', $status); + // If we're releasing the hold wait for a bit to allow the subscriber to + // read the file. + if (!$status) { + usleep(HoldTestSubscriber::WAIT * 2); + } + } + + /** + * Response hold. + * + * @param bool $status + * TRUE - enable hold, FALSE - disable hold. + */ + public static function responseHold(bool $status): void { + $site_path = \Drupal::getContainer()->getParameter('site.path'); + file_put_contents($site_path . '/hold_test_response.txt', $status); + // If we're releasing the hold wait for a bit to allow the subscriber to + // read the file. + if (!$status) { + usleep(HoldTestSubscriber::WAIT * 2); + } + } + +} diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/ThrobberTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/ThrobberTest.php index 0372ae1cd996e606dc80886bd4a64383bec57945..6b2a17d4c6eba136ea4da9ae89d21eb1ad8ed3c6 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/ThrobberTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/ThrobberTest.php @@ -5,6 +5,7 @@ namespace Drupal\FunctionalJavascriptTests\Ajax; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; +use Drupal\hold_test\HoldTestHelper; /** * Tests the throbber. @@ -64,28 +65,28 @@ public function testThemingThrobberElement(): void { // Test theming fullscreen throbber. $session->executeScript($custom_ajax_progress_indicator_fullscreen); - hold_test_response(TRUE); + HoldTestHelper::responseHold(TRUE); $page->clickLink('Content: Published (grouped)'); $this->assertNotNull($web_assert->waitForElement('css', '.custom-ajax-progress-fullscreen'), 'Custom ajaxProgressIndicatorFullscreen.'); - hold_test_response(FALSE); + HoldTestHelper::responseHold(FALSE); $web_assert->assertNoElementAfterWait('css', '.custom-ajax-progress-fullscreen'); // Test theming throbber message. $web_assert->waitForElementVisible('css', '[data-drupal-selector="edit-options-group-info-add-group"]'); $session->executeScript($custom_ajax_progress_message); - hold_test_response(TRUE); + HoldTestHelper::responseHold(TRUE); $page->pressButton('Add another item'); $this->assertNotNull($web_assert->waitForElement('css', '.ajax-progress-throbber .custom-ajax-progress-message'), 'Custom ajaxProgressMessage.'); - hold_test_response(FALSE); + HoldTestHelper::responseHold(FALSE); $web_assert->assertNoElementAfterWait('css', '.ajax-progress-throbber'); // Test theming throbber. $web_assert->waitForElementVisible('css', '[data-drupal-selector="edit-options-group-info-group-items-3-title"]'); $session->executeScript($custom_ajax_progress_throbber); - hold_test_response(TRUE); + HoldTestHelper::responseHold(TRUE); $page->pressButton('Add another item'); $this->assertNotNull($web_assert->waitForElement('css', '.custom-ajax-progress-throbber'), 'Custom ajaxProgressThrobber.'); - hold_test_response(FALSE); + HoldTestHelper::responseHold(FALSE); $web_assert->assertNoElementAfterWait('css', '.custom-ajax-progress-throbber'); // Test progress throbber position on a dropbutton in a table display. @@ -93,10 +94,10 @@ public function testThemingThrobberElement(): void { $this->clickLink('Place block'); $web_assert->assertWaitOnAjaxRequest(); $this->assertNotEmpty($web_assert->waitForElementVisible('css', '#drupal-modal')); - hold_test_response(TRUE); + HoldTestHelper::responseHold(TRUE); $this->clickLink('Place block'); $this->assertNotNull($web_assert->waitForElement('xpath', '//div[contains(@class, "dropbutton-wrapper")]/following-sibling::div[contains(@class, "ajax-progress-throbber")]')); - hold_test_response(FALSE); + HoldTestHelper::responseHold(FALSE); $web_assert->assertNoElementAfterWait('css', '.ajax-progress-throbber'); }