Problem/Motivation

Following #3374405: Allow upload of zipped hospital price file the tests fail on d.o.


Drupal\Tests\hospital_price_transparency\Functional\HospitalPriceTransparencyTest
exception: [Other] Line 0 of sites/default/files/simpletest/phpunit-3.xml:
PHPUnit Test failed to complete; Error: PHPUnit 9.6.8 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\hospital_price_transparency\Functional\HospitalPriceTransparencyTest
E                                                                   1 / 1 (100%)

Time: 00:03.092, Memory: 4.00 MB

There was 1 error:

1) Drupal\Tests\hospital_price_transparency\Functional\HospitalPriceTransparencyTest::testHospitalPriceTransparency
Behat\Mink\Exception\ExpectationException: Current response status code is 500, but 200 expected.

/var/www/html/vendor/behat/mink/src/WebAssert.php:794
/var/www/html/vendor/behat/mink/src/WebAssert.php:130
/var/www/html/modules/contrib/hospital_price_transparency/tests/src/Functional/HospitalPriceTransparencyTest.php:139
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:728

I found the browser output from Jenkins and the error looks like this:

Called from GuzzleHttp\Promise\FulfilledPromise::GuzzleHttp\Promise\{closure}() line 48

GET request to: http://php-apache-jenkins-drupal-contrib-719294/subdirectory/hpt/3

The website encountered an unexpected error. Please try again later.

Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException: The file "public:/file.xml" does not exist in Symfony\Component\HttpFoundation\File\File->__construct() (line 36 of vendor/symfony/http-foundation/File/File.php).
Symfony\Component\HttpFoundation\BinaryFileResponse->setFile('public:/file.xml', NULL, , 1) (Line: 52)
Symfony\Component\HttpFoundation\BinaryFileResponse->__construct('public:/file.xml') (Line: 28)
Drupal\hospital_price_transparency\Controller\HospitalPriceTransparencyController->file(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 166)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Original Report

See https://www.drupal.org/pift-ci-job/2719405

It started on 18 Jul 2023 at 21:29 CDT

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

danflanagan8 created an issue. See original summary.

danflanagan8’s picture

Issue summary: View changes

I'm not reproducing this locally.

danflanagan8’s picture

Oh, it's because of some changes that were made to the module and tests a few days earlier (July 14). See #3374405: Allow upload of zipped hospital price file

That's probably it. I couldn't run the new tests on d.o prior to committing since there were new binary files being added.

danflanagan8’s picture

Issue summary: View changes
danflanagan8’s picture

Issue summary: View changes
danflanagan8’s picture

StatusFileSize
new888 bytes

Is this a realpath thing?

danflanagan8’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: hpt-failing-tests-3380067-6.patch, failed testing. View results

danflanagan8’s picture

That didn't work. The error changed to this in the html output:

Called from GuzzleHttp\Promise\FulfilledPromise::GuzzleHttp\Promise\{closure}() line 48
GET request to: http://php-apache-jenkins-drupal8-contrib-patches-167737/subdirectory/hpt/3
The website encountered an unexpected error. Please try again later.

Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException: The file "" does not exist in Symfony\Component\HttpFoundation\File\File->__construct() (line 36 of vendor/symfony/http-foundation/File/File.php).
Symfony\Component\HttpFoundation\BinaryFileResponse->setFile('', NULL, , 1) (Line: 52)
Symfony\Component\HttpFoundation\BinaryFileResponse->__construct('') (Line: 28)
Drupal\hospital_price_transparency\Controller\HospitalPriceTransparencyController->file(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 166)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
danflanagan8’s picture

Oh! There's a clue I missed. :)

There's a missing slash:

public:/file.xml

That uri gets built here:

$extract_to_dir = pathinfo($file->getFileUri(), PATHINFO_DIRNAME);
$zip->extract($extract_to_dir, [$zipped_filename]);
$unzipped_file_uri = $extract_to_dir . '/' . $zipped_filename;
$new_file = File::create([
  'uri' => $unzipped_file_uri,
]);

$file->getFileUri() gives public://xml_zip.zip and $extract_to_dir resolves as public:.

So then $unzipped_file_uri gets built with one slash instead of a double slash. That's what needs to be fixed, but I'm not sure exactly the best way.

danflanagan8’s picture

Status: Needs work » Needs review
StatusFileSize
new1.61 KB

I think this does it.

danflanagan8’s picture

StatusFileSize
new4.14 KB
new2.53 KB

Yay!

Here's a bit more test coverage though that focuses on the uri of the extracted zip files.

danflanagan8’s picture

Phew! I guess some servers can deal with the malformed uri? Or some zip packages can do that? Regardless, this is better. My manual testing was positive as well. Let's commit it.

  • danflanagan8 committed 61400a87 on 1.0.x
    Issue #3380067 by danflanagan8: HPT tests started failing on D10.1
    
danflanagan8’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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