Problem/Motivation

Drupal\Tests\Core\Session\WriteSafeSessionHandlerTest::testOtherMethods() incorrectly mocks ::gc().

Steps to reproduce

Run Drupal\Tests\Core\Session\WriteSafeSessionHandlerTest::testOtherMethods() on PHP 8.1

Proposed resolution

Fix the test.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#2 3241267-2.patch602 bytesalexpott

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new602 bytes

Before

PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.1.0RC3-dev
Configuration: /Users/alex/dev/sites/drupal8alt.dev/phpunit.xml
Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

Testing Drupal\Tests\Core\Session\WriteSafeSessionHandlerTest
....E                                                               5 / 5 (100%)

Time: 00:00.016, Memory: 10.00 MB

There was 1 error:

1) Drupal\Tests\Core\Session\WriteSafeSessionHandlerTest::testOtherMethods with data set #4 ('gc', true, array(42))
TypeError: Mock_SessionHandlerInterface_0e75fa34::gc(): Return value must be of type int|false, bool returned

After

PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.1.0RC3-dev
Configuration: /Users/alex/dev/sites/drupal8alt.dev/phpunit.xml
Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

Testing Drupal\Tests\Core\Session\WriteSafeSessionHandlerTest
.....                                                               5 / 5 (100%)

Time: 00:00.015, Memory: 10.00 MB

OK (5 tests, 25 assertions)
daffie’s picture

Status: Needs review » Reviewed & tested by the community

The method gc() return an integer or false. See: https://www.php.net/manual/en/sessionhandlerinterface.gc.php

Looks good to me.

  • catch committed 6a8c333 on 9.3.x
    Issue #3241267 by alexpott, daffie: Drupal\Tests\Core\Session\...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 6a8c333 and pushed to 9.3.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.