You are here

protected function IndividualExportImportTest::getRandomDataStorage in Configuration Split 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Kernel/IndividualExportImportTest.php \Drupal\Tests\config_split\Kernel\IndividualExportImportTest::getRandomDataStorage()

Get random data in a config storage.

Return value

\Drupal\Core\Config\StorageInterface The storage witrh random data.

1 call to IndividualExportImportTest::getRandomDataStorage()
IndividualExportImportTest::testExportNonEmptyFiles in tests/src/Kernel/IndividualExportImportTest.php
Test exporting when there is already data to be overwritten.

File

tests/src/Kernel/IndividualExportImportTest.php, line 232

Class

IndividualExportImportTest
Test the export and import of individual splits.

Namespace

Drupal\Tests\config_split\Kernel

Code

protected function getRandomDataStorage() : StorageInterface {
  $random = new MemoryStorage();
  $collections = array_merge($this
    ->getActiveStorage()
    ->getAllCollectionNames(), [
    StorageInterface::DEFAULT_COLLECTION,
    $this
      ->randomMachineName(),
  ]);
  foreach ($collections as $collection) {
    $random = $random
      ->createCollection($collection);
    $size = random_int(4, 10);
    for ($i = 0; $i < $size; $i++) {
      $random
        ->write($this
        ->randomMachineName(), (array) $this
        ->randomObject());
    }
  }
  return $random;
}