Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
HandlerArgumentUserUidTest
makes no HTTP requests but is a functional test
Proposed resolution
Convert HandlerArgumentUserUidTest
into a Kernel test
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
N/A
Comment | File | Size | Author |
---|---|---|---|
#4 | 3042472-4.patch | 4.93 KB | claudiu.cristea |
Comments
Comment #2
claudiu.cristeaThis patch decreases the locally test run from 9.5 to 2.4 seconds.
Comment #3
phenaproximaNice! It'll be nice to see all these issues land and hopefully knock down the time it takes to run the full core test suite :)
Interesting. I can take a guess at why this change was made, but how did this test ever work before? :)
This should be protected.
This seems like it should go into setUp().
If assertEquals() is comparing strings, it should probably be assertSame(). :)
Comment #4
claudiu.cristea@phenaproxima, thank you.
#3.1: That is a bug and is not related directly to this particular conversion, just that is the testing view used here. The kernel test also passes w/o that change. It's a little bit out-of-scope but as I've already discovered, I think it would be too much to fix in a dedicated follow-up.
#3.2: Fixed.
#3.3: I disagree with this. Normally we put in setup code that is reusable across all tests from a class. It's correct to put those lines in
::setUp()
but is also correct to let them in the test, when there is only one test or when they concern only that test.#3.4: Can you elaborate on this, because I think exactly the opposite? And moreover, when we compare strings in Drupal, when one string could be a
MarkupInterface
object and the other just a string. In that case the assertion will fail. So, we need==
(which isassertEquals()
), not===
(assertSame()
).Comment #5
phenaproximaIf comparing a string to something "stringable", like a MarkupInterface, then you are absolutely right; assertSame() is not the right tool. But if you're asserting the output of a method that returns a plain string, I feel like assertSame() is better, since it is a slightly stronger guarantee that you're asserting a correct value.
Comment #6
LendudeYeah, bit of an unrelated change, but not THAT unrelated, since this view is used in the test, and this is small enough in scope to do 'convert and clean up' I think. Updated the title to indicate this
I have no strong feelings on the assertSame vs assertEquals, this is fine with me, so gonna RTBC it, and we'll see...
Comment #7
alexpottCommitted and pushed 9676337962 to 8.8.x and 0b3d688d26 to 8.7.x. Thanks!
As a test only change backported to 8.7.x - I discussed backporting test-only changes with @catch (as a release manager).
I have no strong feelings either on assertEquals vs assertSame