BarcodeTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
eloc 22
c 3
b 0
f 1
dl 0
loc 36
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testBarcodeMessageIsString() 0 17 1
A testBarcode() 0 15 1
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