You are here

public function ComponentsInfoTest::testIsProtectedNamespace in Components! 8.2

Tests checking for protected namespaces.

@covers ::isProtectedNamespace

@dataProvider providerTestIsProtectedNamespace

Parameters

array $moduleInfo: List of module .info.yml data.

array $themeInfo: List of theme .info.yml data.

array $expected: Expected data.

File

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

Class

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

Namespace

Drupal\Tests\components\Unit

Code

public function testIsProtectedNamespace(array $moduleInfo, array $themeInfo, array $expected) {
  $this->moduleExtensionList
    ->expects($this
    ->exactly(1))
    ->method('getAllInstalledInfo')
    ->willReturn($moduleInfo);
  $this->themeExtensionList
    ->expects($this
    ->exactly(1))
    ->method('getAllInstalledInfo')
    ->willReturn($themeInfo);
  $this
    ->newSystemUnderTest();
  foreach ($expected as $extension => $value) {
    $actual = $this->systemUnderTest
      ->isProtectedNamespace($extension);
    if ($value) {
      $this
        ->assertTrue($actual, 'Failed checking if isProtectedNamespace("' . $extension . '") was TRUE');
    }
    else {
      $this
        ->assertNotTrue($actual, 'Failed checking if isProtectedNamespace("' . $extension . '") was FALSE');
    }
  }
}