ConfigSorterTest.php in Configuration Split 2.0.x
File
tests/src/Kernel/ConfigSorterTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\config_split\Kernel;
use Drupal\config_split\Config\ConfigSorter;
use Drupal\Core\Config\FileStorage;
use Drupal\KernelTests\KernelTestBase;
class ConfigSorterTest extends KernelTestBase {
public function testSortingUmamiConfig() {
$path = $this->container
->get('extension.list.profile')
->getPath('demo_umami');
$storage = new FileStorage($path . '/config/install');
$sorter = new ConfigSorter($this->container
->get('config.typed'), $storage);
foreach ($storage
->listAll() as $name) {
$original = $storage
->read($name);
$shuffled = $this
->shuffleDeep($original);
$sorted = $sorter
->sort($name, $shuffled);
self::assertSame($original, $sorted, "{$name} is sorted again");
}
}
private function shuffleDeep($config) {
if (!is_array($config) || empty($config)) {
return $config;
}
$keys = array_keys($config);
shuffle($keys);
foreach ($keys as $key) {
$new[$key] = $this
->shuffleDeep($config[$key]);
}
return $new;
}
}