public function testGetCommands()
 {
     CommandRegistry::register('test1', function () {
     });
     CommandRegistry::register('test2', function () {
     });
     $commands = CommandRegistry::getCommands();
     $this->assertArrayHasKey('test1', $commands);
     $this->assertArrayHasKey('test2', $commands);
     $this->assertEquals(2, count($commands));
 }
 /**
  * Run custom command if exists
  * 
  * @param array $command
  * 
  * @return boolean
  */
 protected function runCustomCommand($command)
 {
     if (!CommandRegistry::hasCommand($command['command'])) {
         throw new BadMethodCallException('Command "' . $command['command'] . '" not found');
     }
     $customCommand = CommandRegistry::getCommand($command['command']);
     array_unshift($command['params'], $this->image);
     call_user_func_array($customCommand, $command['params']);
     return true;
 }
 public function testProcessCustomCommand()
 {
     $commands = 'custom';
     $callCheck = false;
     CommandRegistry::register('custom', function () use(&$callCheck) {
         $callCheck = true;
     });
     $source = vfsStream::url('public') . '/img/test.jpg';
     $target = vfsStream::url('public') . '/processed/img/test.$' . $commands . '.jpg';
     $this->imageProcessing->process($source, $target, $commands);
     $this->assertTrue($callCheck);
     $folder = vfsStreamWrapper::getRoot()->getChild('processed')->getChild('img');
     $this->assertTrue($folder->hasChild('test.$' . $commands . '.jpg'));
     $content = $folder->getChild('test.$' . $commands . '.jpg')->getContent();
     $this->assertEquals(pack('H*', 'ffd8ff'), substr($content, 0, 3));
     // ÿØÿ
 }