Drupal\Tests\canvas\Kernel\Controller\ApiMediaControllersPostTest::testPost fails intermittently in CI with a mismatch on the itok query parameter in the src URL returned by the media upload API. The itok is computed with a date-based upload folder.
First seen here: https://git.drupalcode.org/project/canvas/-/jobs/9609943
and reproduced locally:
❯ ddev exec -d /var/www/html/modules/contrib/canvas composer run phpunit -- tests/src/Kernel/Controller/ApiMediaControllersPostTest.php
> ./tests/scripts/phpunit.sh 'tests/src/Kernel/Controller/ApiMediaControllersPostTest.php'
PHPUnit 11.5.55 by Sebastian Bergmann and contributors.
Runtime: PHP 8.4.20
Configuration: /var/www/html/modules/contrib/canvas/phpunit.xml.dist
FF... 5 / 5 (100%)
Time: 00:28.944, Memory: 118.23 MB
There were 2 failures:
1) Drupal\Tests\canvas\Kernel\Controller\ApiMediaControllersPostTest::testPost with data set "Create a new image" ('image', ['gracie-big.jpg', 'Gracie Dog', 'Gracie Dog in its most happy state'], [1, ['::SITE_DIR_BASE_URL::/files/:...xv7Qhl', 'Gracie Dog in its most happy state', 3000, 2595]])
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
'id' => 1,
'uuid' => '197d0907-6527-4941-a3e9-9e03163f5f54',
'inputs_resolved' => Array &1 [
- 'src' => '::SITE_DIR_BASE_URL::/files/::MEDIA_FOLDER::/gracie-big.jpg?alternateWidths=::SITE_DIR_BASE_URL::/files/styles/canvas_parametrized_width--%7Bwidth%7D/public/::MEDIA_FOLDER::/gracie-big.jpg.avif%3Fitok%3Dh5xv7Qhl',
+ 'src' => '::SITE_DIR_BASE_URL::/files/::MEDIA_FOLDER::/gracie-big.jpg?alternateWidths=::SITE_DIR_BASE_URL::/files/styles/canvas_parametrized_width--%7Bwidth%7D/public/::MEDIA_FOLDER::/gracie-big.jpg.avif%3Fitok%3DYbWUs9wV',
'alt' => 'Gracie Dog in its most happy state',
'width' => 3000,
'height' => 2595,
],
]
/var/www/html/modules/contrib/canvas/tests/src/Kernel/Controller/ApiMediaControllersPostTest.php:132
2) Drupal\Tests\canvas\Kernel\Controller\ApiMediaControllersPostTest::testPost with data set "Create a new image without alt nor title" ('image', ['gracie-big.jpg'], [1, ['::SITE_DIR_BASE_URL::/files/:...xv7Qhl', '', 3000, 2595]])
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
'id' => 1,
'uuid' => 'dcdc9b19-1be8-4de9-b689-325d4a2b816b',
'inputs_resolved' => Array &1 [
- 'src' => '::SITE_DIR_BASE_URL::/files/::MEDIA_FOLDER::/gracie-big.jpg?alternateWidths=::SITE_DIR_BASE_URL::/files/styles/canvas_parametrized_width--%7Bwidth%7D/public/::MEDIA_FOLDER::/gracie-big.jpg.avif%3Fitok%3Dh5xv7Qhl',
+ 'src' => '::SITE_DIR_BASE_URL::/files/::MEDIA_FOLDER::/gracie-big.jpg?alternateWidths=::SITE_DIR_BASE_URL::/files/styles/canvas_parametrized_width--%7Bwidth%7D/public/::MEDIA_FOLDER::/gracie-big.jpg.avif%3Fitok%3DYbWUs9wV',
'alt' => '',
'width' => 3000,
'height' => 2595,
],
]
/var/www/html/modules/contrib/canvas/tests/src/Kernel/Controller/ApiMediaControllersPostTest.php:132
FAILURES!
Tests: 5, Assertions: 150, Failures: 2.
Script ./tests/scripts/phpunit.sh handling the phpunit event returned with error code 1
Failed to execute command `composer run phpunit -- tests/src/Kernel/Controller/ApiMediaControllersPostTest.php`: exit status 1
Comments
Comment #3
justafishComment #4
justafishComment #6
penyaskito???
Comment #10
wim leersComment #12
wim leers