protected function execute(InputInterface $input, OutputInterface $output)
 {
     $decorator = new Decorator(new TestService(), 'test_service', new TestEventDispatcher());
     $lock = new Lock();
     $lock->setDriver(new File(new \Symfony\Component\Filesystem\Filesystem(), 'lock'))->setMethod('sleep');
     $decorator->addLock($lock);
     $decorator->sleep((int) $input->getOption('seconds'));
     $output->write('done');
 }
 public function testLogger()
 {
     $decorator = new Decorator(new TestService(), 'test_service');
     $lock = new Lock();
     $lock->setDriver(new Debug())->setMethod('doNothing');
     $decorator->addLock($lock);
     $logger = new TestLogger();
     $decorator->setLogger($logger);
     $decorator->doNothing();
     $this->assertEquals($this->expectedLogs, $logger->getLogs());
 }
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage something exception
  */
 public function testLockedMethodThatThrowsException()
 {
     $decorator = new Decorator(new TestService(), 'test_service');
     $lock = new Lock();
     $lock->setDriver(new Debug())->setMethod('doSomething');
     $decorator->addLock($lock);
     $decorator->doSomething(function () {
         throw new \Exception('something exception');
     });
 }