Problem/Motivation
I'm not entirely sure why this is, so this might be a bug or it might not.
DbLogTest
fails consistently locally, but doesn't show up as failing in branch tests.
It fails because it generates this error:
[20-Mar-2017 09:19:36 Australia/Sydney] Uncaught PHP Exception InvalidArgumentException: "The URI 'http://localhost:8888user' is malformed." at /Users/paul/pj2/drupal/core/lib/Drupal/Core/Url.php line 274
This comes down to the way DbLogTest::generateLogEntries()
uses $request->getRequestUri()
to build the URI, which doesn't add a slash into the path. However, this test passes in the tesbot, which is why it's not obvious what to do about it.
There are a number of issues in this meta dealing with changing the tests for DbLog: #2847428: [Meta] Modernize dblog module
Proposed resolution
I'm able to fix it with this patch:
--- a/core/modules/dblog/src/Tests/DbLogTest.php
+++ b/core/modules/dblog/src/Tests/DbLogTest.php
@@ -220,7 +220,7 @@ private function generateLogEntries($count, $options = []) {
'link' => $link,
'user' => $this->adminUser,
'uid' => $this->adminUser->id(),
- 'request_uri' => $base_root . \Drupal::request()->getRequestUri(),
+ 'request_uri' => $base_root . '/' . \Drupal::request()->getRequestUri(),
'referer' => \Drupal::request()->server->get('HTTP_REFERER'),
'ip' => '127.0.0.1',
'timestamp' => REQUEST_TIME,
However, this may end up breaking it in the testbot. Let's find out.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#2 | 2861973_2.patch | 739 bytes | Mile23 |
Comments
Comment #2
Mile23Here's a patch.
Also, this issue is set for 8.4.x, but I realize in hindsight it should be for 8.3.x because it's a test improvement (if it's an improvement).
Comment #3
dagmarThanks @Mile23. I never experienced this in the past. Actually I have this simple php file
When I run this with
drush src file.php
I get this:It seems this is the expected behavior, so, maybe is something related to your local environment.
Can you describe what Os/Webserver are you using? Thanks
Comment #10
larowlanTriaged this as part of bug-smash, will reach out to @Mile23 on slack to ask if this is still valid.
Comment #11
Mile23MAMP 5.6, using PHP 7.3.9 and MySQL 5.7.26.
Here are two logs. Note that different, overlapping sets of tests fail depending on which tool you use to run them.
Comment #13
quietone CreditAttribution: quietone as a volunteer commentedTested on 9.2.x and cannot reproduce.
ddev version v1.16.0 PHP 7.3.24 MariaDB 10.3.25
$ php ./core/scripts/run-tests.sh --sqlite foo.sqlite --concurrency 5 dblog
Drupal test run
---------------
Tests to be run:
- Drupal\Tests\dblog\Functional\DbLogResourceTest
- Drupal\Tests\dblog\Functional\DbLogTest
- Drupal\Tests\dblog\Functional\DbLogViewsTest
- Drupal\Tests\dblog\Kernel\ConnectionFailureTest
- Drupal\Tests\dblog\Kernel\DbLogControllerTest
- Drupal\Tests\dblog\Kernel\DbLogFormInjectionTest
- Drupal\Tests\dblog\Kernel\DbLogTest
- Drupal\Tests\dblog\Kernel\Views\ViewsIntegrationTest
Test run started:
Saturday, January 9, 2021 - 05:49
Test summary
------------
Drupal\Tests\dblog\Kernel\ConnectionFailureTest 1 passes
Drupal\Tests\dblog\Kernel\DbLogControllerTest 2 passes
Drupal\Tests\dblog\Kernel\DbLogFormInjectionTest 1 passes
Drupal\Tests\dblog\Kernel\DbLogTest 1 passes
Drupal\Tests\dblog\Functional\DbLogResourceTest 1 passes
Drupal\Tests\dblog\Kernel\Views\ViewsIntegrationTest 3 passes
Drupal\Tests\dblog\Functional\DbLogTest 11 passes
Drupal\Tests\dblog\Functional\DbLogViewsTest 12 passes
Test run duration: 3 min 55 sec
$ ./vendor/bin/phpunit -c core/ --testsuite functional --group dblog
PHPUnit 8.5.13 by Sebastian Bergmann and contributors.
Testing
........................ 24 / 24 (100%)
Time: 6.31 minutes, Memory: 174.00 MB
OK (24 tests, 679 assertions)
HTML output was generated
Comment #14
quietone CreditAttribution: quietone as a volunteer commentedAnd same result for 9.1.x, cannot reproduce.
Comment #18
smustgrave CreditAttribution: smustgrave at Mobomo commentedI'm on ddev v1.19.2
Drupal core 9.5.x
and cannot reproduce.
Seems @quietone couldn't either in #13 + 14. Closing as can't reproduce
If you're still experiencing this please reopen with an update issue summary and testing steps (most importantly local setup)