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::getReceipt
  *  @covers Cilex\Store\Transaction::addProduct
  */
 public function testGetValidReceipt()
 {
     $this->object->addProduct('test', 1.0);
     $result = $this->object->getReceipt();
     $this->assertEquals(9, count($result));
 }