url example


        'subdir3' => [],
      ],
      'module_b' => [
        'subdir1' => [
          'plugin4.yml' => "id: plugin4\ntest_provider: module_b",
        ],
      ],
    ]);
    $directories = [
      'module_a' => [
        vfsStream::url('modules/module_a/subdir1'),
        vfsStream::url('modules/module_a/subdir2'),
        // Empty directory.         vfsStream::url('modules/module_a/subdir3'),
        // Directory does not exist.         vfsStream::url('modules/module_a/subdir4'),
      ],
      'module_b' => vfsStream::url('modules/module_b/subdir1'),
    ];
    $discovery = new YamlDirectoryDiscovery($directories, 'test');

    $definitions = $discovery->getDefinitions();

    
'delete.me' => 'I am gone.',
          ],
          'delete_me.too' => 'delete this file.',
        ],
      ],
    ]);

    $connection = $this->prophesize(Connection::class);
    $test_run_results_storage = $this->prophesize(TestRunResultsStorageInterface::class);

    $cleaner = new EnvironmentCleaner(
      vfsStream::url('cleanup_test'),
      $connection->reveal(),
      $test_run_results_storage->reveal(),
      new NullOutput(),
      \Drupal::service('file_system')
    );

    $do_cleanup_ref = new \ReflectionMethod($cleaner, 'doCleanTemporaryDirectories');

    $this->assertFileExists(vfsStream::url('cleanup_test/sites/simpletest/delete_dir/delete.me'));
    $this->assertFileExists(vfsStream::url('cleanup_test/sites/simpletest/delete_me.too'));

    
'item_4.test.yml' => "id: item4\nname: 'test4 item 4'",
          'item_5.test.yml' => "id: item5\nname: 'test4 item 5'",
          'item_6.test.yml' => "id: item6\nname: 'test4 item 6'",
        ],
      ],
    ]);

    // Set up the directories to search.     $directories = [
      // Multiple directories both with valid items.       'test_1' => [
        vfsStream::url('modules/test_1/subdir1'),
        vfsStream::url('modules/test_1/subdir2'),
      ],
      // The subdir2 directory is empty.       'test_2' => [
        vfsStream::url('modules/test_2/subdir1'),
        vfsStream::url('modules/test_2/subdir2'),
      ],
      // Directories that do not exist.       'test_3' => [
        vfsStream::url('modules/test_3/subdir1'),
        vfsStream::url('modules/test_3/subdir2'),
      ],

    public function test(string $expected, EnvConfigurator $envConfigurator)
    {
        $this->assertSame($expected(string) $envConfigurator);
    }

    public static function provide(): iterable
    {
        yield ['%env(FOO)%', new EnvConfigurator('FOO')];
        yield ['%env(string:FOO)%', new EnvConfigurator('string:FOO')];
        yield ['%env(string:FOO)%', (new EnvConfigurator('FOO'))->string()];
        yield ['%env(key:path:url:FOO)%', (new EnvConfigurator('FOO'))->url()->key('path')];
        yield ['%env(default:fallback:bar:arg1:FOO)%', (new EnvConfigurator('FOO'))->custom('bar', 'arg1')->default('fallback')];
        yield ['%env(my_processor:my_argument:FOO)%', (new EnvConfigurator('FOO'))->myProcessor('my_argument')];
        yield ['%env(enum:'.StringBackedEnum::class.':FOO)%', (new EnvConfigurator('FOO'))->enum(StringBackedEnum::class)];
    }
}

  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;
      }array_keys($files))));
    $migrationState = new MigrationState($fieldPluginManager->reveal()$moduleHandler->reveal()$this->createMock(MessengerInterface::class)$this->getStringTranslationStub());

    
// 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);
    $discovery->findAll();
  }

}
->disableOriginalConstructor()
      ->getMock();
    $config->expects($this->once())
      ->method('getPathsForPackage')
      ->willReturn(['tests']);

    $plugin = $this->getMockBuilder(VendorHardeningPlugin::class)
      ->onlyMethods(['getInstallPathForPackage'])
      ->getMock();
    $plugin->expects($this->once())
      ->method('getInstallPathForPackage')
      ->willReturn(vfsStream::url('vendor/drupal/package'));

    $ref_config = new \ReflectionProperty($plugin, 'config');
    $ref_config->setValue($plugin$config);

    $io = $this->prophesize(IOInterface::class);
    $ref_io = new \ReflectionProperty($plugin, 'io');
    $ref_io->setValue($plugin$io->reveal());

    $this->assertFileExists(vfsStream::url('vendor/drupal/package/tests/SomeTest.php'));

    $package = $this->prophesize(PackageInterface::class);
    


  /** * Sets up the filesystem, so things like the file directory. */
  protected function setUpFilesystem() {
    $test_db = new TestDatabase($this->databasePrefix);
    $test_site_path = $test_db->getTestSitePath();

    $this->vfsRoot = vfsStream::setup('root');
    $this->vfsRoot->addChild(vfsStream::newDirectory($test_site_path));
    $this->siteDirectory = vfsStream::url('root/' . $test_site_path);

    mkdir($this->siteDirectory . '/files', 0775);
    mkdir($this->siteDirectory . '/files/config/sync', 0775, TRUE);

    $settings = Settings::getInstance() ? Settings::getAll() : [];
    $settings['file_public_path'] = $this->siteDirectory . '/files';
    $settings['config_sync_directory'] = $this->siteDirectory . '/files/config/sync';
    new Settings($settings);
  }

  /** * @return string */

  public function testWriteItem($poContent$expected$long) {
    if ($long) {
      $this->expectException(\Exception::class);
      $this->expectExceptionMessage('Unable to write data:');
    }

    // Limit the file system quota to make the write fail on long strings.     vfsStream::setQuota(10);

    $this->poWriter->setURI($this->poFile->url());
    $this->poWriter->open();

    $poItem = $this->prophesize(PoItem::class);
    $poItem->__toString()->willReturn($poContent);

    $this->poWriter->writeItem($poItem->reveal());
    $this->poWriter->close();
    $this->assertEquals(file_get_contents($this->poFile->url())$expected);
  }

  /** * @return array * - Content to write. * - Written content. * - Content longer than 10 bytes. */
vfsStream::setup('root');
    vfsStream::create([
      'modules' => [
        'test' => $help_topics_dir,
      ],
      'themes' => [
        'test' => $help_topics_dir,
      ],
    ]);

    $this->directories = [
      'root' => vfsStream::url('root'),
      'module' => [
        'test' => vfsStream::url('root/modules/test'),
        'not_a_dir' => vfsStream::url('root/modules/not_a_dir'),
      ],
      'theme' => [
        'test' => vfsStream::url('root/themes/test'),
        'not_a_dir' => vfsStream::url('root/themes/not_a_dir'),
      ],
    ];
  }

}
'username' => 'name of the bot',
            'avatar_url' => 'http://ava.tar/pic.png',
            'tts' => true,
        ]);
    }

    public function testDiscordEmbedFields()
    {
        $discordOptions = (new DiscordOptions())
            ->addEmbed((new DiscordEmbed())
                ->description('descript.io')
                ->url('http://ava.tar/pic.png')
                ->timestamp(new \DateTimeImmutable('2020-10-12 9:14:15+0000'))
                ->color(2021216)
                ->title('New song added!')
            )
            ->addEmbed((new DiscordEmbed())
                ->description('descript.io 2')
                ->url('http://ava.tar/pic.png')
                ->timestamp(new \DateTimeImmutable('2020-10-12 9:14:15+0000'))
                ->color(2021216)
                ->title('New song added!')
            );

        
use PHPUnit\Framework\TestCase;
use Symfony\Component\Notifier\Bridge\Discord\Embeds\DiscordAuthorEmbedObject;
use Symfony\Component\Notifier\Exception\LengthException;

final class DiscordAuthorEmbedObjectTest extends TestCase
{
    public function testCanBeInstantiated()
    {
        $author = (new DiscordAuthorEmbedObject())
            ->name('Doe')
            ->url('http://ur.l')
            ->iconUrl('http://icon-ur.l')
            ->proxyIconUrl('http://proxy-icon-ur.l');

        $this->assertSame([
            'name' => 'Doe',
            'url' => 'http://ur.l',
            'icon_url' => 'http://icon-ur.l',
            'proxy_icon_url' => 'http://proxy-icon-ur.l',
        ]$author->toArray());
    }

    

  protected $directory;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    vfsStream::setup('exampleDir');
    $this->directory = vfsStream::url('exampleDir');
  }

  /** * Assert that a PHP storage's load/save/delete operations work. */
  public function assertCRUD($php) {
    // Random generator.     $random_generator = new Random();

    $name = $random_generator->name(8, TRUE) . '/' . $random_generator->name(8, TRUE) . '.php';

    

    ]);
  }

  public function provideGetMessageText() {
    return [
      [[][]],
      [
        ['Special', 'File'],
        [
          'drupal-core-project-message' => [
            'event-name-file' => vfsStream::url('config_test/bespoke/special_file.txt'),
          ],
        ],
      ],
      [
        ['I am the message.'],
        [
          'drupal-core-project-message' => [
            'event-name-message' => ['I am the message.'],
          ],
        ],
      ],
      [
public function testSafeInclude() {
    // The overrides in the transliteration data directory transliterates 0x82     // into "safe" but the overrides one directory higher transliterates the     // same character into "security hole". So by using "../index" as the     // language code we can test the ../ is stripped from the langcode.     vfsStream::setup('transliteration', NULL, [
      'index.php' => '<?php $overrides = ["../index" => [0x82 => "security hole"]];',
      'dir' => [
        'index.php' => '<?php $overrides = ["../index" => [0x82 => "safe"]];',
      ],
    ]);
    $transliteration = new PhpTransliteration(vfsStream::url('transliteration/dir'));
    $transliterated = $transliteration->transliterate(chr(0xC2) . chr(0x82), '../index');
    $this->assertSame('safe', $transliterated);
  }

}
Home | Imprint | This part of the site doesn't use cookies.