21
21
*/
22
22
class PHPJasperTest extends TestCase
23
23
{
24
+ /**
25
+ * @var
26
+ */
27
+ private $ instance ;
28
+
24
29
public function setUp ()
25
30
{
26
- $ this ->PHPJasper = new PHPJasper ();
31
+ $ this ->instance = new PHPJasper ();
27
32
}
28
33
29
34
public function tearDown ()
30
35
{
31
- unset($ this ->PHPJasper );
36
+ unset($ this ->instance );
32
37
}
33
38
34
39
public function testConstructor ()
@@ -38,20 +43,26 @@ public function testConstructor()
38
43
39
44
public function testCompile ()
40
45
{
41
- $ result = $ this ->PHPJasper ->compile ('examples/hello_world.jrxml ' , '{output_file} ' );
42
-
43
- $ this ->assertInstanceOf (PHPJasper::class, $ result );
46
+ $ result = $ this ->instance ->compile ('examples/hello_world.jrxml ' , '{output_file} ' );
44
47
45
48
$ expected = '.*jasperstarter compile ".*hello_world.jrxml" -o "{output_file}" ' ;
46
49
47
50
$ this ->assertRegExp ('/ ' .$ expected .'/ ' , $ result ->output ());
48
51
}
49
52
50
- public function testListParameters ()
53
+ public function testProcess ()
51
54
{
52
- $ result = $ this ->PHPJasper ->listParameters ('examples/hello_world.jrxml ' );
55
+ $ result = $ this ->instance ->process ('examples/hello_world.jrxml ' , '{output_file} ' );
56
+
57
+ $ expected = '.*jasperstarter process ".*hello_world.jrxml" -o "{output_file}" ' ;
58
+
59
+ $ this ->assertRegExp ('/ ' .$ expected .'/ ' , $ result ->output ());
60
+
61
+ }
53
62
54
- $ this ->assertInstanceOf (PHPJasper::class, $ result );
63
+ public function testListParameters ()
64
+ {
65
+ $ result = $ this ->instance ->listParameters ('examples/hello_world.jrxml ' );
55
66
56
67
$ this ->assertRegExp (
57
68
'/.*jasperstarter list_parameters ".*hello_world.jrxml"/ ' ,
@@ -63,18 +74,12 @@ public function testCompileWithWrongInput()
63
74
{
64
75
$ this ->expectException (\PHPJasper \Exception \InvalidInputFile::class);
65
76
66
- $ jasper = new PHPJasper ();
67
-
68
- $ jasper ->compile ('' );
77
+ $ this ->instance ->compile ('' );
69
78
}
70
79
71
80
public function testCompileHelloWorld ()
72
81
{
73
- $ jasper = new PHPJasper ();
74
-
75
- $ result = $ jasper ->compile ('examples/hello_world.jrxml ' );
76
-
77
- $ this ->assertInstanceOf (PHPJasper::class, $ result );
82
+ $ result = $ this ->instance ->compile ('examples/hello_world.jrxml ' );
78
83
79
84
$ this ->assertRegExp ('/.*jasperstarter compile ".*hello_world.jrxml"/ ' , $ result ->output ());
80
85
}
@@ -83,22 +88,19 @@ public function testExecuteWithoutCompile()
83
88
{
84
89
$ this ->expectException (\PHPJasper \Exception \InvalidCommandExecutable::class);
85
90
86
- $ jasper = new PHPJasper ();
87
- $ jasper ->execute ();
91
+ $ this ->instance ->execute ();
88
92
}
89
93
90
94
public function testInvalidInputFile ()
91
95
{
92
96
$ this ->expectException (\PHPJasper \Exception \InvalidInputFile::class);
93
97
94
- $ jasper = new PHPJasper ();
95
- $ jasper ->compile ('{invalid} ' )->execute ();
98
+ $ this ->instance ->compile ('{invalid} ' )->execute ();
96
99
}
97
100
98
101
public function testExecute ()
99
102
{
100
- $ jasper = new PHPJasper ();
101
- $ actual = $ jasper ->compile (__DIR__ . '/test.jrxml ' )->execute ();
103
+ $ actual = $ this ->instance ->compile (__DIR__ . '/test.jrxml ' )->execute ();
102
104
103
105
$ this ->assertInternalType ('array ' , $ actual );
104
106
}
@@ -107,16 +109,14 @@ public function testListParametersWithWrongInput()
107
109
{
108
110
$ this ->expectException (\PHPJasper \Exception \InvalidInputFile::class);
109
111
110
- $ jasper = new PHPJasper ();
111
- $ jasper ->listParameters ('' );
112
+ $ this ->instance ->listParameters ('' );
112
113
}
113
114
114
115
public function testProcessWithWrongInput ()
115
116
{
116
117
$ this ->expectException (\PHPJasper \Exception \InvalidInputFile::class);
117
118
118
- $ jasper = new PHPJasper ();
119
- $ jasper ->process ('' , '' , [
119
+ $ this ->instance ->process ('' , '' , [
120
120
'format ' => 'mp3 '
121
121
]);
122
122
}
@@ -125,15 +125,8 @@ public function testProcessWithWrongFormat()
125
125
{
126
126
$ this ->expectException (\PHPJasper \Exception \InvalidFormat::class);
127
127
128
- $ jasper = new PHPJasper ();
129
- $ jasper ->process ('hello_world.jrxml ' , '' , [
128
+ $ this ->instance ->process ('hello_world.jrxml ' , '' , [
130
129
'format ' => 'mp3 '
131
130
]);
132
131
}
133
-
134
- public function testProcess ()
135
- {
136
- $ jasper = new PHPJasper ();
137
- $ this ->assertInstanceOf (PHPJasper::class, $ jasper ->process ('hello_world.jrxml ' , "" ));
138
- }
139
132
}
0 commit comments