PaymentACKTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 45
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testMemo() 0 19 1
A testPayment() 0 22 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Bip70\Test\Protobuf\Proto;
6
7
use Bip70\Protobuf\Proto\Payment;
8
use Bip70\Protobuf\Proto\PaymentACK;
9
use PHPUnit\Framework\TestCase;
10
11
class PaymentACKTest extends TestCase
12
{
13
    public function testMemo()
14
    {
15
        $blob = "So long, and thanks for all the pizza!";
16
17
        $ack = new PaymentACK();
18
        $ack->setPayment(new Payment());
19
        $this->assertFalse($ack->hasMemo());
20
        $ack->setMemo($blob);
21
        $this->assertTrue($ack->hasMemo());
22
23
        $serialized = $ack->serialize();
24
        $p1 = new PaymentACK();
25
        $p1->parse($serialized);
26
27
        $this->assertEquals($blob, $p1->getMemo());
28
29
        $ack->clearMemo();
30
        $this->assertFalse($ack->hasMemo());
31
    }
32
33
    public function testPayment()
34
    {
35
        $tx1 = "abcd";
36
        $payment = new Payment();
37
        $payment->addTransactions($tx1);
38
39
        $ack = new PaymentACK();
40
        $this->assertFalse($ack->hasPayment());
41
        $ack->setPayment($payment);
42
        $this->assertTrue($ack->hasPayment());
43
44
        $serialized = $ack->serialize();
45
        $p1 = new PaymentACK();
46
        $p1->parse($serialized);
47
48
        $this->assertTrue($p1->hasPayment());
49
        $this->assertTrue($p1->getPayment()->hasTransactions());
50
        $this->assertEquals($tx1, $p1->getPayment()->getTransactions(0));
51
52
        $ack->clearPayment();
53
        $this->assertFalse($ack->hasPayment());
54
    }
55
}
56