You are here

public function FlysystemPluginManagerTest::test in Flysystem 8

Same name and namespace in other branches
  1. 3.x tests/src/Unit/Plugin/FlysystemPluginManagerTest.php \Drupal\Tests\flysystem\Unit\Plugin\FlysystemPluginManagerTest::test()
  2. 2.0.x tests/src/Unit/Plugin/FlysystemPluginManagerTest.php \Drupal\Tests\flysystem\Unit\Plugin\FlysystemPluginManagerTest::test()
  3. 3.0.x tests/src/Unit/Plugin/FlysystemPluginManagerTest.php \Drupal\Tests\flysystem\Unit\Plugin\FlysystemPluginManagerTest::test()

@covers \Drupal\flysystem\Plugin\FlysystemPluginManager

File

tests/src/Unit/Plugin/FlysystemPluginManagerTest.php, line 19

Class

FlysystemPluginManagerTest
@coversDefaultClass \Drupal\flysystem\Plugin\FlysystemPluginManager @group flysystem

Namespace

Drupal\Tests\flysystem\Unit\Plugin

Code

public function test() {
  $namespaces = new \ArrayObject();
  $cache_backend = new MemoryBackend('bin');
  $module_handle = $this
    ->getMock(ModuleHandlerInterface::class);
  $manager = new FlysystemPluginManager($namespaces, $cache_backend, $module_handle);
  $this
    ->assertSame('missing', $manager
    ->getFallbackPluginId('beep'));
  $this
    ->assertInternalType('array', $manager
    ->getDefinitions());

  // Test alterDefinitions().
  $method = new \ReflectionMethod($manager, 'alterDefinitions');
  $method
    ->setAccessible(TRUE);
  $definitions = [
    'test1' => [
      'extensions' => [],
    ],
    'test2' => [
      'extensions' => [
        'pdo',
      ],
    ],
    'test3' => [
      'extensions' => [
        'missing_extension',
      ],
    ],
  ];
  $method
    ->invokeArgs($manager, [
    &$definitions,
  ]);
  $this
    ->assertSame(2, count($definitions));
  $this
    ->assertArrayHasKey('test1', $definitions);
  $this
    ->assertArrayHasKey('test2', $definitions);
  $this
    ->assertArrayNotHasKey('test3', $definitions);
}