123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace Drupal\KernelTests;
- use Drupal\Component\Diff\Diff;
- trait AssertConfigTrait {
-
- protected function assertConfigDiff(Diff $result, $config_name, array $skipped_config) {
- foreach ($result->getEdits() as $op) {
- switch (get_class($op)) {
- case 'Drupal\Component\Diff\Engine\DiffOpCopy':
-
- break;
- case 'Drupal\Component\Diff\Engine\DiffOpDelete':
- case 'Drupal\Component\Diff\Engine\DiffOpChange':
-
-
- if (!in_array($config_name, array_keys($skipped_config))) {
- throw new \Exception($config_name . ': ' . var_export($op, TRUE));
- }
-
- if ($skipped_config[$config_name] === TRUE) {
- continue;
- }
-
-
-
- $all_skipped = TRUE;
- $changes = get_class($op) == 'Drupal\Component\Diff\Engine\DiffOpDelete' ? $op->orig : $op->closing;
- foreach ($changes as $closing) {
-
-
- $found = FALSE;
- if (!empty($skipped_config[$config_name])) {
- foreach ($skipped_config[$config_name] as $line) {
- if (strpos($closing, $line) !== FALSE) {
- $found = TRUE;
- break;
- }
- }
- }
- $all_skipped = $all_skipped && $found;
- }
- if (!$all_skipped) {
- throw new \Exception($config_name . ': ' . var_export($op, TRUE));
- }
- break;
- case 'Drupal\Component\Diff\Engine\DiffOpAdd':
-
- if ($op->closing[0] === '_core:') {
- continue;
- }
- foreach ($op->closing as $closing) {
-
- if (strpos($closing, 'uuid: ') === 0) {
- continue;
- }
- throw new \Exception($config_name . ': ' . var_export($op, TRUE));
- }
- break;
- default:
- throw new \Exception($config_name . ': ' . var_export($op, TRUE));
- }
- }
- }
- }
|