Esempio n. 1
0
 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $productsToBuy = $input->getArgument(self::ARGUMENT_PRODUCTS_TO_BUY);
     $discount = $input->getArgument(self::ARGUMENT_DISCOUNT);
     $locale = $input->getArgument(self::ARGUMENT_LOCALE);
     //create a new transaction
     $transaction = new \Cilex\Store\Transaction(new \Cilex\Store\Products());
     //set locale
     $locale ? setlocale(LC_MONETARY, $locale) : false;
     if ($productsToBuy) {
         foreach ($productsToBuy as $product) {
             //add products
             $transaction->addProduct($product, $this->products[$product]);
         }
     }
     //if a deposit has been made
     if ($discount && $discount > 0) {
         $transaction->addDiscount((int) $discount, (double) $transaction->getSubTotal());
     }
     //output
     $output->writeln($transaction->getReceipt());
 }
Esempio n. 2
0
 /**
  * @covers Cilex\Store\Transaction::getSubTotal
  * @covers Cilex\Store\Transaction::add
  */
 public function testGetSubTotal()
 {
     $this->object->add(1.5);
     $this->object->add(1.25);
     $this->assertEquals(2.75, $this->object->getSubTotal());
 }