Open Journal Systems  3.3.0
ItemBagTest.php
1 <?php
2 
3 namespace Omnipay\Common;
4 
5 use Omnipay\Tests\TestCase;
6 
7 class ItemBagTest extends TestCase
8 {
9  public function setUp()
10  {
11  $this->bag = new ItemBag;
12  }
13 
14  public function testConstruct()
15  {
16  $bag = new ItemBag(array(array('name' => 'Floppy Disk')));
17  $this->assertCount(1, $bag);
18  }
19 
20  public function testAll()
21  {
22  $items = array(new Item, new Item);
23  $bag = new ItemBag($items);
24 
25  $this->assertSame($items, $bag->all());
26  }
27 
28  public function testReplace()
29  {
30  $items = array(new Item, new Item);
31  $this->bag->replace($items);
32 
33  $this->assertSame($items, $this->bag->all());
34  }
35 
36  public function testAddWithItem()
37  {
38  $item = new Item;
39  $item->setName('CD-ROM');
40  $this->bag->add($item);
41 
42  $contents = $this->bag->all();
43  $this->assertSame($item, $contents[0]);
44  }
45 
46  public function testAddWithArray()
47  {
48  $item = array('name' => 'CD-ROM');
49  $this->bag->add($item);
50 
51  $contents = $this->bag->all();
52  $this->assertInstanceOf('\Omnipay\Common\Item', $contents[0]);
53  $this->assertSame('CD-ROM', $contents[0]->getName());
54  }
55 
56  public function testGetIterator()
57  {
58  $item = new Item;
59  $item->setName('CD-ROM');
60  $this->bag->add($item);
61 
62  foreach ($this->bag as $bagItem) {
63  $this->assertSame($item, $bagItem);
64  }
65  }
66 
67  public function testCount()
68  {
69  $this->bag->add(new Item);
70  $this->bag->add(new Item);
71  $this->bag->add(new Item);
72 
73  $this->assertSame(3, count($this->bag));
74  }
75 }
Omnipay\Common\ItemBagTest\testAll
testAll()
Definition: ItemBagTest.php:20
Omnipay\Common\ItemBagTest\testReplace
testReplace()
Definition: ItemBagTest.php:28
Omnipay\Common\Item
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/Item.php:17
Omnipay\Common\ItemBagTest\testConstruct
testConstruct()
Definition: ItemBagTest.php:14
Omnipay\Common\ItemBagTest\setUp
setUp()
Definition: ItemBagTest.php:9
Omnipay\Common\ItemBagTest\testAddWithArray
testAddWithArray()
Definition: ItemBagTest.php:46
Omnipay\Common\ItemBagTest\testGetIterator
testGetIterator()
Definition: ItemBagTest.php:56
Omnipay\Common\ItemBagTest
Definition: ItemBagTest.php:7
Omnipay\Common\Item\setName
setName($value)
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/Item.php:80
Omnipay\Common\ItemBagTest\testCount
testCount()
Definition: ItemBagTest.php:67
Omnipay\Common\ItemBagTest\testAddWithItem
testAddWithItem()
Definition: ItemBagTest.php:36
Omnipay\Common
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/AbstractGateway.php:6
Omnipay\Common\ItemBag
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/ItemBag.php:16