blob: 6cd95d0802228d5069db5ebd323814ab7f7bd0fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
<?php
/**
* Class QROutputTestAbstract
*
* @filesource QROutputTestAbstract.php
* @created 24.12.2017
* @package chillerlan\QRCodeTest\Output
* @author Smiley <[email protected]>
* @copyright 2017 Smiley
* @license MIT
*/
namespace chillerlan\QRCodeTest\Output;
use chillerlan\QRCode\QROptions;
use chillerlan\QRCode\Data\Byte;
use chillerlan\QRCode\Output\{QRCodeOutputException, QROutputInterface};
use chillerlan\QRCodeTest\QRTestAbstract;
use function dirname, file_exists, mkdir;
abstract class QROutputTestAbstract extends QRTestAbstract{
const cachefile = __DIR__.'/../../.build/output_test/test.';
/**
* @var \chillerlan\QRCode\Output\QROutputInterface
*/
protected $outputInterface;
/**
* @var \chillerlan\QRCode\QROptions
*/
protected $options;
/**
* @var \chillerlan\QRCode\Data\QRMatrix
*/
protected $matrix;
protected function setUp():void{
parent::setUp();
$buildDir = dirname($this::cachefile);
if(!file_exists($buildDir)){
mkdir($buildDir, 0777, true);
}
$this->options = new QROptions;
$this->setOutputInterface();
}
protected function setOutputInterface(){
$this->outputInterface = $this->reflection->newInstanceArgs([$this->options, (new Byte($this->options, 'testdata'))->initMatrix(0)]);
return $this->outputInterface;
}
public function testInstance(){
$this->assertInstanceOf(QROutputInterface::class, $this->outputInterface);
}
public function testSaveException(){
$this->expectException(QRCodeOutputException::class);
$this->expectExceptionMessage('Could not write data to cache file: /foo');
$this->options->cachefile = '/foo';
$this->setOutputInterface();
$this->outputInterface->dump();
}
}
|