Add automated tests

Created on 10 October 2024, 2 months ago

Problem/Motivation

This module has no tests.

Steps to reproduce

N/A

Proposed resolution

Add tests.

Remaining tasks

All the things.

User interface changes

None.

API changes

None.

Data model changes

None.

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom Eli-T Manchester

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Eli-T
  • Merge request !7Draft: Resolve #3479959 "Add automated tests" → (Open) created by Eli-T
  • 🇬🇧United Kingdom Eli-T Manchester

    Further work is needed - tests do not yet add exemptions.

    It's also unclear why setting site into maintenance mode, then calling $this->assertSession() causes the tests to fail with the following issue

    1) Drupal\Tests\maintenance_exempt\Functional\ExemptionsTest::testNodesNotAccessible
    Exception: Deprecated function: preg_quote(): Passing null to parameter #1 ($str) of type string is deprecated
    Drupal\Core\Path\PathMatcher->matchPath()() (Line: 82)
    
    
    /var/www/html/web/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php:55
    /var/www/html/vendor/guzzlehttp/promises/src/Promise.php:209
    /var/www/html/vendor/guzzlehttp/promises/src/Promise.php:158
    /var/www/html/vendor/guzzlehttp/promises/src/TaskQueue.php:52
    /var/www/html/vendor/guzzlehttp/promises/src/Promise.php:251
    /var/www/html/vendor/guzzlehttp/promises/src/Promise.php:227
    /var/www/html/vendor/guzzlehttp/promises/src/Promise.php:272
    /var/www/html/vendor/guzzlehttp/promises/src/Promise.php:229
    /var/www/html/vendor/guzzlehttp/promises/src/Promise.php:69
    /var/www/html/vendor/guzzlehttp/guzzle/src/Client.php:189
    /var/www/html/web/core/tests/Drupal/Tests/DrupalTestBrowser.php:139
    /var/www/html/vendor/symfony/browser-kit/AbstractBrowser.php:369
    /var/www/html/vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php:122
    /var/www/html/vendor/behat/mink/src/Session.php:175
    /var/www/html/web/core/tests/Drupal/Tests/UiHelperTrait.php:275
    /var/www/html/web/modules/contrib/maintenance_exempt/tests/src/Functional/ExemptionsTest.php:86
    
    ERRORS!
    Tests: 2, Assertions: 8, Errors: 1.
  • 🇬🇧United Kingdom Eli-T Manchester

    OK, this was due to an actual bug in the module, see commit https://git.drupalcode.org/project/maintenance_exempt/-/commit/2db4a3c32...

    Adding more tests.

  • 🇬🇧United Kingdom Eli-T Manchester

    Further work needed.

    • testNodeExemptedByPath() works locally but not on CI.
    • testNodeExemptedByIpAddress() does not work at all - need a way to predict the IP address that a call to drupalGet() in a browser test will be received from, so we can put it in the maintenance exempt config.
  • 🇬🇧United Kingdom Eli-T Manchester

    Also, phpunit is mandatory, but phpunit (next major) is not. We should consider making it so.

  • 🇬🇧United Kingdom Eli-T Manchester

    testNodeExemptedByIpAddress() now works locally but not in CI.

Production build 0.71.5 2024