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
- Remove
$test_file = $this->getTestFile('text');
- 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
Comments
Comment #2
msankhala commentedComment #3
msankhala commentedHere is the patch
Comment #4
surbz commentedThanks for this patch @msankhala
This makes more sense now and the patch applies cleanly as well.
// \m/
Comment #5
surbz commentedComment #6
alexpottCommitted and pushed 7ee41bffbc to 8.7.x and e1db334696 to 8.6.x. Thanks!