summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2017-01-24 14:32:49 (GMT)
committerNathaniel Catchpole2017-01-24 14:32:49 (GMT)
commitd07733f148d2b53f876f4dd372621f3911b9e099 (patch)
treecb95ad428d81254087218e03fb98313dfd8c172d
parent3af6a3e5382f58d57336f1b264341f1b9407b934 (diff)
Issue #2823400 by vaplas, Adita, hardik.p, alexpott: Random fail in CopyFileTest
-rw-r--r--core/modules/migrate/tests/src/Kernel/process/CopyFileTest.php39
1 files changed, 37 insertions, 2 deletions
diff --git a/core/modules/migrate/tests/src/Kernel/process/CopyFileTest.php b/core/modules/migrate/tests/src/Kernel/process/CopyFileTest.php
index 427d413..ecd1bb1 100644
--- a/core/modules/migrate/tests/src/Kernel/process/CopyFileTest.php
+++ b/core/modules/migrate/tests/src/Kernel/process/CopyFileTest.php
@@ -3,7 +3,7 @@
namespace Drupal\Tests\migrate\Kernel\process;
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
-use Drupal\KernelTests\Core\File\FileTestBase;
+use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Plugin\migrate\process\FileCopy;
use Drupal\migrate\Row;
@@ -13,7 +13,7 @@ use Drupal\migrate\Row;
*
* @group migrate
*/
-class CopyFileTest extends FileTestBase {
+class CopyFileTest extends KernelTestBase {
/**
* {@inheritdoc}
@@ -180,4 +180,39 @@ class CopyFileTest extends FileTestBase {
return $result;
}
+ /**
+ * Create a file and return the URI of it.
+ *
+ * @param $filepath
+ * Optional string specifying the file path. If none is provided then a
+ * randomly named file will be created in the site's files directory.
+ * @param $contents
+ * Optional contents to save into the file. If a NULL value is provided an
+ * arbitrary string will be used.
+ * @param $scheme
+ * Optional string indicating the stream scheme to use. Drupal core includes
+ * public, private, and temporary. The public wrapper is the default.
+ * @return
+ * File URI.
+ */
+ protected function createUri($filepath = NULL, $contents = NULL, $scheme = NULL) {
+ if (!isset($filepath)) {
+ // Prefix with non-latin characters to ensure that all file-related
+ // tests work with international filenames.
+ $filepath = 'Файл для тестирования ' . $this->randomMachineName();
+ }
+ if (empty($scheme)) {
+ $scheme = file_default_scheme();
+ }
+ $filepath = $scheme . '://' . $filepath;
+
+ if (empty($contents)) {
+ $contents = "file_put_contents() doesn't seem to appreciate empty strings so let's put in some data.";
+ }
+
+ file_put_contents($filepath, $contents);
+ $this->assertFileExists($filepath, t('The test file exists on the disk.'));
+ return $filepath;
+ }
+
}