Esempio n. 1
0
 public function testExecuteOKMultiple()
 {
     $plugin = $this->prophesize(PluginInterface::class);
     $plugin->configureOptionsResolver(Argument::type(OptionsResolver::class))->will(function ($args) {
         $args[0]->setRequired(['chmod', 'directory']);
     });
     $this->plugins->has('my-plugin')->willReturn(true);
     $this->plugins->getPlugin('my-plugin')->willReturn($plugin->reveal());
     $commandTester = $this->getCommandTester(true, ['test-1' => ['plugin' => 'my-plugin', 'parameter' => ['directory' => '/test', 'chmod' => 0777]], 'test-2' => ['plugin' => 'my-plugin', 'parameter' => ['directory' => '/test', 'chmod' => 0777]]]);
     $commandTester->execute([]);
     $this->assertRegExp('/test-1([-\\s]*)([^-]*)OK/', $commandTester->getDisplay());
     $this->assertRegExp('/test-2([-\\s]*)([^-]*)OK/', $commandTester->getDisplay());
 }
Esempio n. 2
0
 /**
  * Check single backup-configuration.
  *
  * @param PluginRegistry $plugins
  * @param SymfonyStyle $io
  * @param string $name
  * @param array $backup
  *
  * @return bool
  */
 private function checkBackup(PluginRegistry $plugins, SymfonyStyle $io, $name, array $backup)
 {
     $io->section('Backup: ' . $name);
     if (!$plugins->has($backup['plugin'])) {
         $io->warning(sprintf('Plugin "%s" not found', $backup['plugin']));
         return false;
     }
     $optionsResolver = new OptionsResolver();
     $plugins->getPlugin($backup['plugin'])->configureOptionsResolver($optionsResolver);
     try {
         $parameter = $optionsResolver->resolve($backup['parameter']);
     } catch (InvalidArgumentException $e) {
         $io->warning(sprintf('Parameter not valid' . PHP_EOL . PHP_EOL . 'Message: "%s"', $e->getMessage()));
         return false;
     }
     $io->write('Parameter:');
     $messages = array_filter(explode("\r\n", Yaml::dump($parameter)));
     $io->block($messages, null, null, '  ');
     $io->writeln('OK');
     return true;
 }
Esempio n. 3
0
 /**
  * @dataProvider provideHasData
  */
 public function testHas($name, $expected)
 {
     $plugin = $this->prophesize(PluginInterface::class);
     $registry = new PluginRegistry(['directory' => $plugin->reveal()]);
     $this->assertEquals($expected, $registry->has($name));
 }