1 | <?php |
||
11 | class ChargeBuilderTest extends \PHPUnit_Framework_TestCase |
||
12 | { |
||
13 | private $charge; |
||
14 | |||
15 | protected function setUp() |
||
16 | { |
||
17 | $this->charge = $this->createMock(Charge::class); |
||
18 | |||
19 | $this->charge->expects($this->once()) |
||
20 | ->method('setSubscriptionCode') |
||
21 | ->with('123456'); |
||
22 | } |
||
23 | |||
24 | public function testConstructShouldDoCallSetSubscription() |
||
25 | { |
||
26 | $builder = new ChargeBuilder('123456', $this->charge); |
||
27 | |||
28 | $this->assertInstanceOf(ChargeBuilderInterface::class, $builder); |
||
29 | $this->assertEquals($this->charge, $builder->getCharge()); |
||
30 | |||
31 | } |
||
32 | |||
33 | public function testAddItemShouldDoCallAddInChargeAndReturnSelfObject() |
||
34 | { |
||
35 | $item = new Item(99, 'Produto 03', 1.77, 8, 12.9, 360); |
||
36 | $items = $this->createMock(Items::class); |
||
37 | $items->expects($this->once())->method('add')->with($item); |
||
38 | $this->charge->expects($this->once()) |
||
39 | ->method('getItems') |
||
40 | ->willReturn($items); |
||
41 | |||
42 | $builder = new ChargeBuilder('123456', $this->charge); |
||
43 | |||
44 | $this->assertEquals($builder, $builder->addItem($item)); |
||
45 | } |
||
46 | |||
47 | public function testsetReferenceShouldDoCallInChargeAndReturnSelfObject() |
||
48 | { |
||
49 | $this->charge->expects($this->once()) |
||
58 |