- Issue created by @vishalkhode
- Status changed to Needs review
9 months ago 11:28am 2 July 2024 - 🇺🇸United States tr Cascadia
IIRC the TestSession class was written because we needed two functional methods on the Session for storing and retrieving the Session data, but an actual Session couldn't be instantiated in a Unit test. The methods we didn't need were required by the interfaced, but didn't contain anything.
Your alternate solution looks good.
Why did you remove the array keys? They are there to serve as documentation, and because if a test case fails the key name is displayed in the error output, helping debugging. If you want to remove the keys, then at the very least the data provider method's documentation block should contain a detailed description of the array structure in the @return text. That way we know what that random data in each of those 8 array elements is supposed to contain.
- 🇺🇸United States tr Cascadia
Oh, and now I recall more details about TestSession. It was split into two classes because during the D9->D10 transition Drupal core changed from Symfony 4 to Symfony 6. Symfony 6 required PHP 8, and the SessionInterface in Symfony 6 used the "mixed" return type that didn't exist in D9/PHP7. So in order to support both D9/PHP 7/Symfony 4 and D10/PHP 8/Symfony 6 with the same code base, we had to make a base TestSession that worked in both versions and make a subclass that was declared conditionally depending on what Drupal version was being used. I just removed that conditional code last week in the 4.0.x branch since we no longer have to support D9. See #3265360: [D10] Test failure →
Regardless, if you can address the array keys then I can merge this.
- 🇮🇳India vishalkhode
@TR: I've added them back. The reason I removed earlier, because when running tests, I was seeing following deprecation messages:
* Providing invalid named argument $min_psr3_level for method Drupal\Tests\rules\Unit\RulesDebugLoggerChannelTest::testLog() is deprecated and will not be supported in PHPUnit 11.0. * Providing invalid named argument $expected_system_logs for method Drupal\Tests\rules\Unit\RulesDebugLoggerChannelTest::testLog() is deprecated and will not be supported in PHPUnit 11.0. * Providing invalid named argument $expected_screen_logs for method Drupal\Tests\rules\Unit\RulesDebugLoggerChannelTest::testLog() is deprecated and will not be supported in PHPUnit 11.0. /Users/user1/drupal11.0.0-beta1/docroot/modules/contrib/rules/tests/src/Unit/RulesDebugLoggerChannelTest.php:94
I earlier read above message as:
Providing named argument is deprecated
, but the actual message wasProviding invalid named argument is deprecated
. So, I've now updated the MR and fixed the deprecations. Though fixing that deprecation was not part of this ticket, if you need I can create a separate ticket and add this changes there, if not, then feel free to merge the MR.Why did you remove the array keys? They are there to serve as documentation, and because if a test case fails the key name is displayed in the error output, helping debugging.
-
TR →
committed d0a78f64 on 4.0.x authored by
vishalkhode →
Issue #3458486 by vishalkhode: Fatal Error in...
-
TR →
committed d0a78f64 on 4.0.x authored by
vishalkhode →
- Status changed to Fixed
8 months ago 7:55pm 2 July 2024 Automatically closed - issue fixed for 2 weeks with no activity.