Unverified Commit a99b54f9 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3028708 by Mile23: Deprecate simpletest_generate_file()

parent 1be0372d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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.
+10 −0
Original line number Diff line number Diff line
@@ -82,4 +82,14 @@ public function testDeprecatedPhpUnitFunctions() {
    );
  }

  /**
   * @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));
  }

}