Issue #3028708 by Mile23: Deprecate simpletest_generate_file()

merge-requests/55/head
Alex Pott 2019-09-02 11:04:09 +01:00
parent 1be0372d40
commit a99b54f992
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
2 changed files with 16 additions and 0 deletions

View File

@ -565,8 +565,14 @@ function simpletest_classloader_register() {
*
* @return string
* The name of the file, including the path.
*
* @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
* \Drupal\Tests\TestFileCreationTrait::generateFile() instead.
*
* @see https://www.drupal.org/node/3077768
*/
function simpletest_generate_file($filename, $width, $lines, $type = 'binary-text') {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Tests\TestFileCreationTrait::generateFile() instead. See https://www.drupal.org/node/3077768', E_USER_DEPRECATED);
$text = '';
for ($i = 0; $i < $lines; $i++) {
// Generate $width - 1 characters to leave space for the "\n" character.

View File

@ -82,4 +82,14 @@ class SimpletestDeprecationTest extends KernelTestBase {
);
}
/**
* @expectedDeprecation simpletest_generate_file() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Tests\TestFileCreationTrait::generateFile() instead. See https://www.drupal.org/node/3077768
*/
public function testDeprecatedSimpletestGenerateFile() {
$file = simpletest_generate_file('foo', 40, 10);
$public_file = 'public://' . $file . '.txt';
$this->assertFileExists($public_file);
$this->assertTrue(unlink($public_file));
}
}