comparison core/tests/Drupal/Tests/ConfigTestTrait.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
2 2
3 namespace Drupal\Tests; 3 namespace Drupal\Tests;
4 4
5 use Drupal\Core\Config\ConfigImporter; 5 use Drupal\Core\Config\ConfigImporter;
6 use Drupal\Core\Config\StorageComparer; 6 use Drupal\Core\Config\StorageComparer;
7 use Drupal\Core\Config\StorageCopyTrait;
7 use Drupal\Core\Config\StorageInterface; 8 use Drupal\Core\Config\StorageInterface;
8 9
9 /** 10 /**
10 * Provides helper methods to deal with config system objects in tests. 11 * Provides helper methods to deal with config system objects in tests.
11 */ 12 */
12 trait ConfigTestTrait { 13 trait ConfigTestTrait {
14
15 use StorageCopyTrait;
13 16
14 /** 17 /**
15 * Returns a ConfigImporter object to import test configuration. 18 * Returns a ConfigImporter object to import test configuration.
16 * 19 *
17 * @return \Drupal\Core\Config\ConfigImporter 20 * @return \Drupal\Core\Config\ConfigImporter
20 protected function configImporter() { 23 protected function configImporter() {
21 if (!$this->configImporter) { 24 if (!$this->configImporter) {
22 // Set up the ConfigImporter object for testing. 25 // Set up the ConfigImporter object for testing.
23 $storage_comparer = new StorageComparer( 26 $storage_comparer = new StorageComparer(
24 $this->container->get('config.storage.sync'), 27 $this->container->get('config.storage.sync'),
25 $this->container->get('config.storage'), 28 $this->container->get('config.storage')
26 $this->container->get('config.manager')
27 ); 29 );
28 $this->configImporter = new ConfigImporter( 30 $this->configImporter = new ConfigImporter(
29 $storage_comparer, 31 $storage_comparer,
30 $this->container->get('event_dispatcher'), 32 $this->container->get('event_dispatcher'),
31 $this->container->get('config.manager'), 33 $this->container->get('config.manager'),
48 * The source config storage service. 50 * The source config storage service.
49 * @param \Drupal\Core\Config\StorageInterface $target_storage 51 * @param \Drupal\Core\Config\StorageInterface $target_storage
50 * The target config storage service. 52 * The target config storage service.
51 */ 53 */
52 protected function copyConfig(StorageInterface $source_storage, StorageInterface $target_storage) { 54 protected function copyConfig(StorageInterface $source_storage, StorageInterface $target_storage) {
53 $target_storage->deleteAll(); 55 static::replaceStorageContents($source_storage, $target_storage);
54 foreach ($source_storage->listAll() as $name) {
55 $target_storage->write($name, $source_storage->read($name));
56 }
57 } 56 }
58 57
59 } 58 }