You are here

public function ComponentsInfoTest::providerTestIsProtectedNamespace in Components! 8.2

Provides test data to ::testIsProtectedNamespace().

See also

testIsProtectedNamespace()

File

tests/src/Unit/ComponentsInfoTest.php, line 473

Class

ComponentsInfoTest
@coversDefaultClass \Drupal\components\Template\ComponentsInfo @group components

Namespace

Drupal\Tests\components\Unit

Code

public function providerTestIsProtectedNamespace() : array {
  return [
    'no components data in info.yml' => [
      'moduleInfo' => [
        'fooModule' => [
          'name' => 'Foo Module',
          'type' => 'module',
          'non-components' => 'value',
        ],
      ],
      'themeInfo' => [
        'fooTheme' => [
          'name' => 'Foo Theme',
          'type' => 'theme',
          'no-components' => 'value',
        ],
      ],
      'expected' => [
        'fooModule' => TRUE,
        'fooTheme' => TRUE,
      ],
    ],
    'auto opt-in if default namespace is used' => [
      'moduleInfo' => [
        'fooModule' => [
          'name' => 'Foo Module',
          'type' => 'module',
          'non-components' => 'value',
          'components' => [
            'namespaces' => [
              'fooModule' => 'fooPath',
            ],
          ],
        ],
      ],
      'themeInfo' => [
        'fooTheme' => [
          'name' => 'Foo Theme',
          'type' => 'theme',
          'no-components' => 'value',
          'components' => [
            'namespaces' => [
              'notFooTheme' => 'fooPath',
            ],
          ],
        ],
      ],
      'expected' => [
        'fooModule' => FALSE,
        'fooTheme' => TRUE,
        'notFooTheme' => FALSE,
      ],
    ],
    'manual opt-in with .info.yml flag' => [
      'moduleInfo' => [
        'fooModule' => [
          'name' => 'Foo Module',
          'type' => 'module',
          'non-components' => 'value',
          'components' => [
            'allow_default_namespace_reuse' => TRUE,
          ],
        ],
      ],
      'themeInfo' => [
        'fooTheme' => [
          'name' => 'Foo Theme',
          'type' => 'theme',
          'components' => [],
        ],
      ],
      'expected' => [
        'fooModule' => FALSE,
        'fooTheme' => TRUE,
      ],
    ],
  ];
}