示例#1
0
 /**
  * Write information from event to database..
  *
  * @param BackupEvent $event
  */
 public function onBackupFinished(BackupEvent $event)
 {
     $database = $event->getDatabase();
     $database->set('finished', (new \DateTime())->format(\DateTime::RFC3339));
     $database->set('state', $event->getStatus());
     if (BackupStatus::STATE_FAILED === $event->getStatus()) {
         $database->set('exception', $this->serializeException($event->getException()));
     }
 }
示例#2
0
 public function testOnBackupException()
 {
     $this->event->getOption('parameter')->willReturn(['directory' => '/test']);
     $this->event->getOption('plugin')->willReturn('test');
     $source = $this->prophesize(Filesystem::class);
     $destination = $this->prophesize(Filesystem::class);
     $database = $this->prophesize(Database::class);
     $this->event->getSource()->willReturn($source->reveal());
     $this->event->getDestination()->willReturn($destination->reveal());
     $this->event->getDatabase()->willReturn($database->reveal());
     $exception = $this->prophesize(\Exception::class);
     $this->event->setStatus(BackupStatus::STATE_FAILED)->shouldBeCalled();
     $this->event->setException($exception->reveal())->shouldBeCalled();
     $plugin = $this->prophesize(PluginInterface::class);
     $plugin->configureOptionsResolver(Argument::type(OptionsResolver::class))->will(function ($arguments) {
         /** @var OptionsResolver $optionResolver */
         $optionsResolver = $arguments[0];
         $optionsResolver->setRequired('directory');
     });
     $plugin->backup($source->reveal(), $destination->reveal(), $database->reveal(), ['directory' => '/test'])->shouldBeCalled()->willThrow($exception->reveal());
     $this->pluginRegistry->getPlugin('test')->willReturn($plugin->reveal());
     $this->listener->onBackup($this->event->reveal());
 }