Problem/Motivation

While looking at \Drupal\Tests\file\Functional\FileFieldDisplayTest::testNodeDisplay() I noticed the following snippet:

    $test_file = $this->getTestFile('text');
    simpletest_generate_file('escaped-&-text', 64, 10, 'text');
    $test_file = File::create([
      'uri' => 'public://escaped-&-text.txt',
      'name' => 'escaped-&-text',
      'filesize' => filesize('public://escaped-&-text.txt'),
    ]);

As you can see that $test_file variable is being overwritten by File::create() call and there is a simpletest_generate_file() call which should be avoided because this is a PHPUnit test.

Proposed resolution

  1. Remove $test_file = $this->getTestFile('text');
  2. replace simpletest_generate_file() call with its equivalent $this->generateFile()

Remaining tasks

Write patch

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

msankhala created an issue. See original summary.

msankhala’s picture

Issue summary: View changes
msankhala’s picture

Status: Active » Needs review
Issue tags: +Novice
FileSize
826 bytes

Here is the patch

surbz’s picture

Thanks for this patch @msankhala
This makes more sense now and the patch applies cleanly as well.

// \m/

surbz’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 7ee41bffbc to 8.7.x and e1db334696 to 8.6.x. Thanks!

  • alexpott committed 7ee41bf on 8.7.x
    Issue #2985317 by msankhala: Remove unused local variable and...

  • alexpott committed e1db334 on 8.6.x
    Issue #2985317 by msankhala: Remove unused local variable and...

Status: Fixed » Closed (fixed)

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