PaymentACKTest::testPayment()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.568
c 0
b 0
f 0
cc 1
nc 1
nop 0
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