ConfigDependencyManagerTest.php

Same filename in this branch
  1. 9 core/tests/Drupal/Tests/Core/Config/Entity/ConfigDependencyManagerTest.php
Same filename in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Config/ConfigDependencyManagerTest.php
  2. 8.9.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigDependencyManagerTest.php
  3. 10 core/tests/Drupal/Tests/Core/Config/ConfigDependencyManagerTest.php
  4. 10 core/tests/Drupal/Tests/Core/Config/Entity/ConfigDependencyManagerTest.php
  5. 11.x core/tests/Drupal/Tests/Core/Config/ConfigDependencyManagerTest.php
  6. 11.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigDependencyManagerTest.php

Namespace

Drupal\Tests\Core\Config

File

core/tests/Drupal/Tests/Core/Config/ConfigDependencyManagerTest.php

View source
<?php

namespace Drupal\Tests\Core\Config;

use Drupal\Core\Config\Entity\ConfigDependencyManager;
use Drupal\Tests\UnitTestCase;

/**
 * Tests the ConfigDependencyManager class.
 *
 * @group Config
 *
 * @coversDefaultClass \Drupal\Core\Config\Entity\ConfigDependencyManager
 */
class ConfigDependencyManagerTest extends UnitTestCase {
    
    /**
     * @dataProvider providerTestSortAll
     */
    public function testSortAll(array $data, array $expected_order) {
        $dependency_manager = new ConfigDependencyManager();
        $dependency_manager->setData($data);
        $this->assertEquals($expected_order, $dependency_manager->sortAll());
    }
    public function providerTestSortAll() {
        $datasets[] = [
            [
                'provider.entity_b' => [],
                'provider.entity_a' => [],
            ],
            [
                'provider.entity_a',
                'provider.entity_b',
            ],
        ];
        $datasets[] = [
            [
                'provider.entity_a' => [],
                'provider.entity_b' => [],
            ],
            [
                'provider.entity_a',
                'provider.entity_b',
            ],
        ];
        $datasets[] = [
            [
                'provider.entity_b' => [
                    'dependencies' => [
                        'config' => [
                            'provider.entity_a',
                        ],
                    ],
                ],
                'provider.entity_a' => [],
            ],
            [
                'provider.entity_a',
                'provider.entity_b',
            ],
        ];
        $datasets[] = [
            [
                'provider.entity_a' => [],
                'provider.entity_b' => [
                    'dependencies' => [
                        'config' => [
                            'provider.entity_a',
                        ],
                    ],
                ],
            ],
            [
                'provider.entity_a',
                'provider.entity_b',
            ],
        ];
        $datasets[] = [
            [
                'provider.entity_b' => [],
                'provider.entity_a' => [
                    'dependencies' => [
                        'config' => [
                            'provider.entity_b',
                        ],
                    ],
                ],
            ],
            [
                'provider.entity_b',
                'provider.entity_a',
            ],
        ];
        $datasets[] = [
            [
                'provider.entity_a' => [
                    'dependencies' => [
                        'config' => [
                            'provider.entity_b',
                        ],
                    ],
                ],
                'provider.entity_b' => [],
            ],
            [
                'provider.entity_b',
                'provider.entity_a',
            ],
        ];
        $datasets[] = [
            [
                'provider.entity_a' => [
                    'dependencies' => [
                        'config' => [
                            'provider.entity_b',
                        ],
                    ],
                ],
                'provider.entity_b' => [],
                'block.block.a' => [],
                'block.block.b' => [],
            ],
            [
                'block.block.a',
                'provider.entity_b',
                'block.block.b',
                'provider.entity_a',
            ],
        ];
        $datasets[] = [
            [
                'provider.entity_b' => [],
                'block.block.b' => [],
                'block.block.a' => [],
                'provider.entity_a' => [
                    'dependencies' => [
                        'config' => [
                            'provider.entity_b',
                        ],
                    ],
                ],
            ],
            [
                'block.block.a',
                'provider.entity_b',
                'block.block.b',
                'provider.entity_a',
            ],
        ];
        $datasets[] = [
            [
                'provider.entity_b' => [],
                'block.block.b' => [],
                'block.block.a' => [],
                'provider.entity_a' => [
                    'dependencies' => [
                        'config' => [
                            'provider.entity_b',
                        ],
                    ],
                ],
                'provider.entity_c' => [
                    'dependencies' => [
                        'config' => [
                            'block.block.a',
                        ],
                    ],
                ],
            ],
            [
                'block.block.a',
                'block.block.b',
                'provider.entity_b',
                'provider.entity_a',
                'provider.entity_c',
            ],
        ];
        $datasets[] = [
            [
                'provider.entity_b' => [
                    'dependencies' => [
                        'module' => [
                            'system',
                        ],
                    ],
                ],
                'block.block.b' => [],
                'block.block.a' => [
                    'dependencies' => [
                        'module' => [
                            'system',
                        ],
                    ],
                ],
                'provider.entity_a' => [
                    'dependencies' => [
                        'config' => [
                            'provider.entity_c',
                        ],
                    ],
                ],
                'provider.entity_c' => [
                    'dependencies' => [
                        'config' => [
                            'block.block.a',
                        ],
                    ],
                ],
            ],
            [
                'block.block.b',
                'block.block.a',
                'provider.entity_c',
                'provider.entity_a',
                'provider.entity_b',
            ],
        ];
        return $datasets;
    }

}

Classes

Title Deprecated Summary
ConfigDependencyManagerTest Tests the ConfigDependencyManager class.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.