Пример #1
0
 public function testGetIterator()
 {
     $item = new Item();
     $item->setName('CD-ROM');
     $this->bag->add($item);
     foreach ($this->bag as $bagItem) {
         $this->assertSame($item, $bagItem);
     }
 }
 public function testItems()
 {
     // backward compatibity test using \Omnipay\Common\Item
     $item = new OmnipayItem();
     $item->setName('Foo 1');
     $item->setDescription('Bar description.');
     $item->setPrice(5.0);
     $item->setQuantity(2);
     $bag = new ItemBag(array($item));
     $this->request->setItems($bag);
     $data = $this->request->getData();
     foreach ($bag->all() as $key => $value) {
         /** @var Item $value */
         $index = $key + 1;
         $this->assertSame($data["ITEMNAME{$index}"], $value->getName());
         $this->assertSame($data["ITEMDESC{$index}"], $value->getDescription());
         $this->assertSame($data["ITEMQUANT{$index}"], $value->getQuantity());
         $this->assertSame($data["ITEMPRICE{$index}"], $this->request->formatCurrency($value->getPrice()));
     }
 }
Пример #3
0
 /**
  * {@inheritDoc}
  *
  * In addition, enforces price is integer value
  */
 public function setPrice($value)
 {
     // @todo would be nicer if this could be done with AbstractRequest currency functions (or similar)
     if (is_float($value) || is_string($value) && strpos($value, '.') !== false) {
         $value = (int) round($value * 100);
     } else {
         $value = (int) $value;
     }
     return parent::setPrice($value);
 }
Пример #4
0
 /**
  * @param string $value Max length of 40.
  * @return $this
  */
 public function setName($value)
 {
     return parent::setName(substr($value, 0, 40));
 }
Пример #5
0
 public function testConstructWithParams()
 {
     $item = new Item(['name' => 'Floppy Disk']);
     $this->assertSame('Floppy Disk', $item->getName());
 }