Example #1
0
 /**
  * @test
  */
 public function canAddStrategy()
 {
     $filelib = new FileLibrary(new MemoryStorageAdapter(), new MemoryBackendAdapter());
     $asynchrony = new Asynchrony($filelib);
     $strategy = $this->prophesize('Xi\\Filelib\\Asynchrony\\ExecutionStrategy\\ExecutionStrategy');
     $strategy->getIdentifier()->willReturn('xooxoxx');
     $strategy->attachTo($filelib)->shouldBeCalled();
     $asynchrony->addStrategy($strategy->reveal());
 }
Example #2
0
 /**
  * @test
  */
 public function setsStrategy()
 {
     $strategy = $this->prophesize('Xi\\Filelib\\Asynchrony\\ExecutionStrategy\\ExecutionStrategy');
     $strategy->attachTo($this->filelib)->shouldBeCalled();
     $strategy->getIdentifier()->shouldBeCalled()->willReturn('xooxer');
     $this->asynchrony->addStrategy($strategy->reveal());
     $this->assertSame($this->filelib->getFileRepository(), $this->filelib->getFileRepository()->setExecutionStrategy(FileRepository::COMMAND_AFTERUPLOAD, 'xooxer'));
     $this->assertEquals('xooxer', $this->filelib->getFileRepository()->getExecutionStrategy(FileRepository::COMMAND_AFTERUPLOAD));
 }
Example #3
0
 /**
  * @param string $command
  * @param array $callback
  * @param array $params
  * @return mixed
  */
 private function execute($command, $callback, $params)
 {
     $strategy = $this->asynchrony->getStrategy($this->getExecutionStrategy($command));
     return $strategy->execute($callback, $params);
 }