1<?php
2
3use jucksearm\barcode\PDF417;
4
5class PDF417Test extends PHPUnit_Framework_TestCase {
6
7 	private $class;
8 	private $tmpDir;
9
10    function setUp() {
11        $this->class = new PDF417;
12        $this->tmpDir = dirname(dirname(__FILE__)).'/tmp';
13    }
14
15    function testHasTmpDirectory()
16    {
17    	$this->assertTrue(is_dir($this->tmpDir));
18    }
19
20    function testPDF417Factory() {
21    	$data = $this->class->factory()->setCode('https://github.com/jucksearm/php-barcode')
22		  ->setFile(null)
23		  ->setSize(null)
24		  ->setMargin(null)
25		  ->setColor(null)
26		  ->getBarcode()
27		  ->getBarcodeArray();
28
29		$this->assertNotEmpty($data);
30    }
31
32    function testCreateHtmlPDF417() {
33    	$data = $this->class->factory()->setCode('https://github.com/jucksearm/php-barcode')
34		  ->getPDF417HtmlData();
35
36		$this->assertNotEmpty($data);
37    }
38
39    function testCreatePngPDF417() {
40    	$data = $this->class->factory()->setCode('https://github.com/jucksearm/php-barcode')
41    	  ->getPDF417PngData();
42
43		$this->assertNotEmpty($data);
44    }
45
46    function testCreatePngPDF417AndSave() {
47    	$file = 'testPng.png';
48    	$data = $this->class->factory()->setCode('https://github.com/jucksearm/php-barcode')
49		  ->setFile($file)
50		  ->getPDF417PngData();
51
52		$this->assertTrue(is_file($this->tmpDir.DIRECTORY_SEPARATOR.$file));
53
54		unlink($this->tmpDir.DIRECTORY_SEPARATOR.$file);
55    }
56
57    function testCreateSvgPDF417() {
58    	$data = $this->class->factory()->setCode('https://github.com/jucksearm/php-barcode')
59		  ->getPDF417SvgData();
60
61		$this->assertNotEmpty($data);
62    }
63
64    function testCreateSvgPDF417AndSave() {
65    	$file = 'testSvg.svg';
66    	$data = $this->class->factory()->setCode('https://github.com/jucksearm/php-barcode')
67		  ->setFile($file)
68		  ->getPDF417SvgData();
69
70		$this->assertTrue(is_file($this->tmpDir.DIRECTORY_SEPARATOR.$file));
71
72		unlink($this->tmpDir.DIRECTORY_SEPARATOR.$file);
73    }
74}