setup example

// do we want to set up only one transport?         if ($transport = $input->getArgument('transport')) {
            if (!$this->transportLocator->has($transport)) {
                throw new \RuntimeException(sprintf('The "%s" transport does not exist.', $transport));
            }
            $transportNames = [$transport];
        }

        foreach ($transportNames as $id => $transportName) {
            $transport = $this->transportLocator->get($transportName);
            if ($transport instanceof SetupableTransportInterface) {
                $transport->setup();
                $io->success(sprintf('The "%s" transport was set up successfully.', $transportName));
            } else {
                $io->note(sprintf('The "%s" transport does not support setup.', $transportName));
            }
        }

        return 0;
    }

    public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
    {
        
 [
                Types::DATETIME_IMMUTABLE,
            ]);

            $this->driverConnection->commit();

            return $doctrineEnvelope;
        } catch (\Throwable $e) {
            $this->driverConnection->rollBack();

            if ($this->autoSetup && $e instanceof TableNotFoundException) {
                $this->setup();
                goto get;
            }

            throw $e;
        }
    }

    public function ack(string $id): bool
    {
        try {
            if ($this->driverConnection->getDatabasePlatform() instanceof MySQLPlatform) {
                
/** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $poHeader = $this->prophesize(PoHeader::class);
    $poHeader->__toString()->willReturn('');
    $this->poWriter = new PoStreamWriter();
    $this->poWriter->setHeader($poHeader->reveal());

    $root = vfsStream::setup();
    $this->poFile = new vfsStreamFile('powriter.po');
    $root->addChild($this->poFile);
  }

  /** * @covers ::getURI */
  public function testGetUriException() {
    $this->expectException(\Exception::class);
    $this->expectExceptionMessage('No URI set.');

    

  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';

    
$settings = new Settings([]);
    $this->streamWrapperManager = $this->createMock(StreamWrapperManagerInterface::class);
    $this->logger = $this->createMock('Psr\Log\LoggerInterface');
    $this->fileSystem = new FileSystem($this->streamWrapperManager, $settings$this->logger);
  }

  /** * @covers ::chmod */
  public function testChmodFile() {
    vfsStream::setup('dir');
    vfsStream::create(['test.txt' => 'asdf']);
    $uri = 'vfs://dir/test.txt';

    $this->assertTrue($this->fileSystem->chmod($uri));
    $this->assertFilePermissions(FileSystem::CHMOD_FILE, $uri);
    $this->assertTrue($this->fileSystem->chmod($uri, 0444));
    $this->assertFilePermissions(0444, $uri);
  }

  /** * @covers ::chmod */
$container->getDefinition('extension.list.theme')
      ->setClass(VfsThemeExtensionList::class);
  }

  /** * {@inheritdoc} */
  protected function setUpFilesystem() {
    parent::setUpFilesystem();

    $vfs_root = vfsStream::setup('core');
    vfsStream::create([
      'themes' => [
        'test_missing_base_theme' => [
          'test_missing_base_theme.info.yml' => file_get_contents(DRUPAL_ROOT . '/core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.info.yml'),
          'test_missing_base_theme.theme' => file_get_contents(DRUPAL_ROOT . '/core/tests/fixtures/test_missing_base_theme/test_missing_base_theme.theme'),
        ],
      ],
    ]$vfs_root);
  }

  /** * Tests exception is thrown. */

class VendorHardeningPluginTest extends TestCase {

  use PhpUnitWarnings;
  use ProphecyTrait;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    vfsStream::setup('vendor', NULL, [
      'drupal' => [
        'package' => [
          'tests' => [
            'SomeTest.php' => '<?php',
          ],
        ],
      ],
    ]);
  }

  /** * @covers ::cleanPackage */
$field = FieldConfig::create([
      'field_name' => 'field_test_file',
      'entity_type' => 'entity_test',
      'bundle' => 'entity_test',
      'settings' => [
        'max_filesize' => '2k',
        'file_extensions' => 'jpg|png',
      ],
    ]);
    $field->save();

    vfsStream::setup('drupal_root');
    vfsStream::create([
      'sites' => [
        'default' => [
          'files' => [
            'test.txt' => str_repeat('a', 3000),
          ],
        ],
      ],
    ]);

    // Test for max filesize.
public function testItCanSendAMessageViaTheSender()
    {
        $envelope = new Envelope(new \stdClass());
        $this->sender->expects($this->once())->method('send')->with($envelope)->willReturn($envelope);
        $this->assertSame($envelope$this->transport->send($envelope));
    }

    public function testItCanSetUpTheConnection()
    {
        $this->connection->expects($this->once())->method('setup');
        $this->transport->setup();
    }

    public function testItConvertsHttpExceptionDuringSetupIntoTransportException()
    {
        $this->connection
            ->expects($this->once())
            ->method('setup')
            ->willThrowException($this->createHttpException());

        $this->expectException(TransportException::class);

        
if (!getenv('MESSENGER_AMQP_DSN')) {
            $this->markTestSkipped('The "MESSENGER_AMQP_DSN" environment variable is required.');
        }
    }

    public function testItSendsAndReceivesMessages()
    {
        $serializer = $this->createSerializer();

        $connection = Connection::fromDsn(getenv('MESSENGER_AMQP_DSN'));
        $connection->setup();
        $connection->purgeQueues();

        $sender = new AmqpSender($connection$serializer);
        $receiver = new AmqpReceiver($connection$serializer);

        $sender->send($first = new Envelope(new DummyMessage('First')));
        $sender->send($second = new Envelope(new DummyMessage('Second')));

        $envelopes = iterator_to_array($receiver->get());
        $this->assertCount(1, $envelopes);
        /** @var Envelope $envelope */
        
/** * @coversDefaultClass \Drupal\Core\Test\EnvironmentCleaner * @group Test */
class EnvironmentCleanerTest extends KernelTestBase {

  /** * @covers ::doCleanTemporaryDirectories */
  public function testDoCleanTemporaryDirectories() {
    vfsStream::setup('cleanup_test', NULL, [
      'sites' => [
        'simpletest' => [
          'delete_dir' => [
            'delete.me' => 'I am gone.',
          ],
          'delete_me.too' => 'delete this file.',
        ],
      ],
    ]);

    $connection = $this->prophesize(Connection::class);
    
 {
            usleep(1000);

            return null;
        }

        return parent::get();
    }

    public function setup(): void
    {
        parent::setup();

        $this->executeStatement(implode("\n", $this->getTriggerSql()));
    }

    /** * @return string[] */
    public function getExtraSetupSqlForTable(Table $createdTable): array
    {
        if (!$createdTable->hasOption(self::TABLE_OPTION_NAME)) {
            return [];
        }
protected function setUp(): void {
    // Ensure that FileCacheFactory has a prefix.     FileCacheFactory::setPrefix('prefix');
  }

  /** * Tests YAML directory discovery. * * @covers ::findAll */
  public function testDiscovery() {
    vfsStream::setup('modules', NULL, [
      'test_1' => [
        'subdir1' => [
          'item_1.test.yml' => "id: item1\nname: 'test1 item 1'",
        ],
        'subdir2' => [
          'item_2.test.yml' => "id: item2\nname: 'test1 item 2'",
        ],
      ],
      'test_2' => [
        'subdir1' => [
          'item_3.test.yml' => "id: item3\nname: 'test2 item 3'",
        ],
'@see \\Drupal\\Core\\Something',
      ],
    ];
  }

  /** * @covers \Drupal\Tests\Component\DrupalComponentTest::assertNoCoreUsage * @dataProvider providerAssertNoCoreUsage */
  public function testAssertNoCoreUsage($expected_pass$file_data) {
    // Set up a virtual file to read.     $vfs_root = vfsStream::setup('root');
    vfsStream::newFile('Test.php')->at($vfs_root)->setContent($file_data);
    $file_uri = vfsStream::url('root/Test.php');

    try {
      $pass = TRUE;
      $this->assertNoCoreUsage($file_uri);
    }
    catch (AssertionFailedError $e) {
      $pass = FALSE;
    }
    $this->assertEquals($expected_pass$pass$expected_pass ?
      
parent::setUp();
    // Use a fake DRUPAL_ROOT.     $this->infoParser = new InfoParser('vfs:/');
  }

  /** * Tests the functionality of the infoParser object. * * @covers ::parse */
  public function testInfoParserNonExisting() {
    vfsStream::setup('modules');
    $info = $this->infoParser->parse(vfsStream::url('modules') . '/does_not_exist.info.txt');
    $this->assertEmpty($info, 'Non existing info.yml returns empty array.');
  }

  /** * Tests if correct exception is thrown for a broken info file. * * @covers ::parse */
  public function testInfoParserBroken() {
    $broken_info = <<<BROKEN_INFO
Home | Imprint | This part of the site doesn't use cookies.