/**
  * 
  */
 public function testCreateWithTwoOperands()
 {
     $options = array('firstOperand' => array(2), 'otherOperands' => array(array('operator' => 'add', 'value' => array('3'))));
     $expected = new OperationCommand(new OperationCommandFactoryTest_FakeCommand(array(2)));
     $expected->addOperand('add', new OperationCommandFactoryTest_FakeCommand(array(3)));
     $this->assertEquals($this->factory->create($options), $expected);
 }
 /**
  *
  */
 public function testRunWithThreeOperands()
 {
     $firstOperand = $this->createMockCommand(5);
     $command = new OperationCommand($firstOperand);
     $operand = $this->createMockCommand(10);
     $command->addOperand(OperationCommand::ADD_OPERATOR, $operand);
     $operand = $this->createMockCommand(1);
     $command->addOperand(OperationCommand::SUBTRACT_OPERATOR, $operand);
     $this->assertEquals($command->run(), 14);
 }
 public function create($options)
 {
     if (!isset($options['firstOperand'])) {
         throw new CommandFactoryException();
     }
     $firstOperand = $this->operandCommandFactory->create($options['firstOperand']);
     $command = new OperationCommand($firstOperand);
     if (isset($options['otherOperands'])) {
         foreach ($options['otherOperands'] as $option) {
             if (isset($option['operator']) && isset($option['value'])) {
                 $command->addOperand($option['operator'], $this->operandCommandFactory->create($option['value']));
             }
         }
     }
     return $command;
 }