BarcodeTest::testBarcodeMessageIsString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 17
rs 9.9
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();
0 ignored issues
show
Unused Code introduced by
The assignment to $array is dead and can be removed.
Loading history...
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
}
46