Skip to content
Snippets Groups Projects
Commit 0c1fb826 authored by catch's avatar catch
Browse files

Issue #3496529 by spokje, acbramley: [random test failure] DownloadTest::doPrivateFileTransferTest

parent ee1c3991
No related branches found
No related tags found
4 merge requests!5423Draft: Resolve #3329907 "Test2",!3478Issue #3337882: Deleted menus are not removed from content type config,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!579Issue #2230909: Simple decimals fail to pass validation
Pipeline #448626 passed with warnings
Pipeline: drupal

#448633

    Pipeline: drupal

    #448632

      Pipeline: drupal

      #448628

        ......@@ -30,14 +30,14 @@ public static function reset(): void {
        'move' => [],
        'delete' => [],
        ];
        \Drupal::state()->set('file_test.results', $results);
        \Drupal::keyValue('file_test')->set('results', $results);
        // These hooks will return these values, see FileTestHelper::setReturn().
        $return = [
        'validate' => [],
        'download' => NULL,
        ];
        \Drupal::state()->set('file_test.return', $return);
        \Drupal::keyValue('file_test')->set('return', $return);
        }
        /**
        ......@@ -57,7 +57,7 @@ public static function reset(): void {
        * @see Drupal\file_test\FileTestHelper::reset()
        */
        public static function getCalls($op): array {
        $results = \Drupal::state()->get('file_test.results', []);
        $results = \Drupal::keyValue('file_test')->get('results', []);
        return $results[$op];
        }
        ......@@ -70,7 +70,7 @@ public static function getCalls($op): array {
        * parameters passed to each call.
        */
        public static function getAllCalls(): array {
        return \Drupal::state()->get('file_test.results', []);
        return \Drupal::keyValue('file_test')->get('results', []);
        }
        /**
        ......@@ -87,9 +87,9 @@ public static function getAllCalls(): array {
        */
        public static function logCall($op, $args): void {
        if (\Drupal::state()->get('file_test.count_hook_invocations', TRUE)) {
        $results = \Drupal::state()->get('file_test.results', []);
        $results = \Drupal::keyValue('file_test')->get('results', []);
        $results[$op][] = $args;
        \Drupal::state()->set('file_test.results', $results);
        \Drupal::keyValue('file_test')->set('results', $results);
        }
        }
        ......@@ -105,9 +105,10 @@ public static function logCall($op, $args): void {
        * @see Drupal\file_test\FileTestHelper::reset()
        */
        public static function setReturn($op, $value): void {
        $return = \Drupal::state()->get('file_test.return', []);
        $return = \Drupal::keyValue('file_test')->get('return', []);
        $return[$op] = $value;
        \Drupal::state()->set('file_test.return', $return);
        \Drupal::keyValue('file_test')->set('return', $return);
        }
        /**
        ......
        ......@@ -212,7 +212,7 @@ public function entityTypeAlter(&$entity_types) : void {
        * @see Drupal\file_test\FileTestHelper::reset()
        */
        public function getReturn($op): array|int|null {
        $return = \Drupal::state()->get('file_test.return', [$op => NULL]);
        $return = \Drupal::keyValue('file_test')->get('return', [$op => NULL]);
        return $return[$op];
        }
        ......
        ......@@ -105,7 +105,7 @@ protected function doPrivateFileTransferTest(): void {
        $this->assertSession()->responseHeaderDoesNotExist('x-drupal-cache');
        $this->assertSession()->statusCodeEquals(200);
        // Ensure hook_file_download is fired correctly.
        $this->assertEquals($file->getFileUri(), \Drupal::state()->get('file_test.results')['download'][0][0]);
        $this->assertEquals($file->getFileUri(), FileTestHelper::getCalls('download')[0][0]);
        // Test that the file transferred correctly.
        $this->assertSame($contents, $this->getSession()->getPage()->getContent(), 'Contents of the file are correct.');
        ......@@ -117,7 +117,7 @@ protected function doPrivateFileTransferTest(): void {
        $response = $http_client->head($not_found_url, ['http_errors' => FALSE]);
        $this->assertSame(404, $response->getStatusCode(), 'Correctly returned 404 response for a non-existent file.');
        // Assert that hook_file_download is not called.
        $this->assertEquals([], \Drupal::state()->get('file_test.results')['download']);
        $this->assertEquals([], FileTestHelper::getCalls('download'));
        // Having tried a non-existent file, try the original file again to ensure
        // it's returned instead of a 404 response.
        ......@@ -143,7 +143,7 @@ protected function doPrivateFileTransferTest(): void {
        $this->drupalGet('/system/files');
        $this->assertSession()->statusCodeEquals(404);
        // Assert that hook_file_download is not called.
        $this->assertEquals([], \Drupal::state()->get('file_test.results')['download']);
        $this->assertEquals([], FileTestHelper::getCalls('download'));
        }
        /**
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment