vfsStreamDirectory example


  protected function setUp(): void {
    // Ensure that FileCacheFactory has a prefix.     FileCacheFactory::setPrefix('prefix');
  }

  /** * Tests the YAML file discovery. */
  public function testDiscovery() {
    vfsStreamWrapper::register();
    $root = new vfsStreamDirectory('modules');
    vfsStreamWrapper::setRoot($root);
    $url = vfsStream::url('modules');

    mkdir($url . '/test_1');
    file_put_contents($url . '/test_1/test_1.test.yml', 'name: test');
    file_put_contents($url . '/test_1/test_2.test.yml', 'name: test');

    mkdir($url . '/test_2');
    file_put_contents($url . '/test_2/test_3.test.yml', 'name: test');
    // Write an empty YAML file.     file_put_contents($url . '/test_2/test_4.test.yml', '');

    

  protected function setUp(): void {
    // Ensure that FileCacheFactory has a prefix.     FileCacheFactory::setPrefix('prefix');
  }

  /** * Tests if filename is output for a broken YAML file. */
  public function testFilenameForBrokenYml() {
    vfsStreamWrapper::register();
    $root = new vfsStreamDirectory('modules');
    vfsStreamWrapper::setRoot($root);
    $url = vfsStream::url('modules');

    mkdir($url . '/test_broken');
    file_put_contents($url . '/test_broken/test_broken.test.yml', "broken:\n:");

    $this->expectException(InvalidDataTypeException::class);
    $this->expectExceptionMessage('vfs://modules/test_broken/test_broken.test.yml');

    $directories = ['test_broken' => $url . '/test_broken'];
    $discovery = new YamlDiscovery('test', $directories);
    
$this->assertDirectoryDoesNotExist($this->directory . '/test');

    // Should still return TRUE if directory has already been deleted.     $this->assertTrue($php->deleteAll(), 'Delete all succeeds with nothing to delete');
    unset($GLOBALS[$random]);
  }

  /** * @covers ::createDirectory */
  public function testCreateDirectoryFailWarning() {
    $directory = new vfsStreamDirectory('permissionDenied', 0200);
    $storage = new FileStorage([
      'directory' => $directory->url(),
      'bin' => 'test',
    ]);
    $code = "<?php\n echo 'here';";
    $this->expectWarning();
    $this->expectWarningMessage('mkdir(): Permission Denied');
    $storage->save('subdirectory/foo.php', $code);
  }

}

  public function testGetUpgradeStates($modules_to_enable$files$field_plugins$migrations$source_system_data$expected_7$expected_6) {
    $fieldPluginManager = $this->prophesize(MigrateFieldPluginManagerInterface::class);
    $fieldPluginManager->getDefinitions()->willReturn($field_plugins);
    $moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
    $moduleHandler->getModuleList()->willReturn($modules_to_enable);
    vfsStreamWrapper::register();
    $root = new vfsStreamDirectory('modules');
    vfsStreamWrapper::setRoot($root);
    $url = vfsStream::url('modules');

    foreach ($files as $module => $contents) {
      $path = $url . '/' . $module . '/migrations/state';
      mkdir($path, '0755', TRUE);
      file_put_contents($path . '/' . $module . '.migrate_drupal.yml', $contents);
    }
    $moduleHandler->getModuleDirectories()
      ->willReturn(array_combine(array_keys($files)array_map(function D$module) use ($url) {
        return $url . '/' . $module;
      },
/** * Tests permissions provided by YML files. * * @covers ::__construct * @covers ::getPermissions * @covers ::buildPermissionsYaml * @covers ::moduleProvidesPermissions */
  public function testBuildPermissionsYaml() {
    vfsStreamWrapper::register();
    $root = new vfsStreamDirectory('modules');
    vfsStreamWrapper::setRoot($root);

    $this->moduleHandler = $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface');
    $this->moduleHandler->expects($this->once())
      ->method('getModuleDirectories')
      ->willReturn([
        'module_a' => vfsStream::url('modules/module_a'),
        'module_b' => vfsStream::url('modules/module_b'),
        'module_c' => vfsStream::url('modules/module_c'),
      ]);

    
/** * Make sure AnnotatedClassDiscovery never tries to autoload bad annotations. * * @dataProvider provideBadAnnotations * * @coversNothing */
  public function testAutoloadBadAnnotations($annotation) {
    // Set up a class file in vfsStream.     vfsStreamWrapper::register();
    $root = new vfsStreamDirectory('root');
    vfsStreamWrapper::setRoot($root);

    FileCacheFactory::setPrefix(__CLASS__);

    // Make a directory for discovery.     $url = vfsStream::url('root');
    mkdir($url . '/DrupalTest');

    // Create a class docblock with our annotation.     $php_file = "<?php\nnamespace DrupalTest;\n/**\n";
    $php_file .= " * @$annotation\n";
    
Home | Imprint | This part of the site doesn't use cookies.