Passed
Pull Request — master (#103)
by Razvan
15:39 queued 12:47
created

BarcodeTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Passbook\Tests\Pass;
4
5
use Passbook\Pass\Barcode;
6
use PHPUnit\Framework\TestCase;
7
8
class BarcodeTest extends TestCase
9
{
10
    public function testBarcode()
11
    {
12
        $barcode = new Barcode(Barcode::TYPE_QR, 'message');
13
14
        $barcode
15
            ->setFormat(Barcode::TYPE_PDF_417)
16
            ->setMessage('hello')
17
            ->setMessageEncoding('iso-8859-1')
18
            ->setAltText('hello world')
19
        ;
20
21
        $this->assertEquals(Barcode::TYPE_PDF_417, $barcode->getFormat());
22
        $this->assertEquals('hello', $barcode->getMessage());
23
        $this->assertEquals('hello world', $barcode->getAltText());
24
        $array = $barcode->toArray();
25
    }
26
27
    public function testBarcodeMessageIsString()
28
    {
29
        $barcode = new Barcode(Barcode::TYPE_QR, 123);
30
        $barcode->setAltText(456);
31
32
        $this->assertIsString($barcode->getMessage());
33
        $this->assertIsString($barcode->getAltText());
34
35
        $barcodeDetails = $barcode->toArray();
36
        $this->assertIsString($barcodeDetails['message']);
37
        $this->assertIsString($barcodeDetails['altText']);
38
39
        $barcode->setMessage(789);
40
        $this->assertIsString($barcode->getMessage());
41
42
        $barcode->setMessage(null);
43
        $this->assertEquals('', $barcode->getMessage());
44
    }
45
}