@@ -17,10 +17,12 @@ final class PHPJasperTest extends TestCase
17
17
private $ PHPJasper ;
18
18
private $ input ;
19
19
private $ output ;
20
+ protected $ windows ;
20
21
21
22
public function setUp ()
22
23
{
23
24
$ this ->PHPJasper = new PHPJasper ();
25
+ $ this ->windows = strtoupper (substr (PHP_OS , 0 , 3 )) === 'WIN ' ? true : false ;
24
26
}
25
27
26
28
public function tearDown ()
@@ -49,76 +51,81 @@ public function testListParameters()
49
51
$ this ->assertEquals ('jasperstarter list_parameters "{input_fille}" ' , $ result ->output ());
50
52
}
51
53
52
- /* public function testCompileWithWrongInput()
54
+ public function testCompileWithWrongInput ()
53
55
{
54
- $this->setExpectedExceptionFromAnnotation(\PHPJasper\Exception\InvalidInputFile::class);
55
-
56
- $jasper = new PHPJasper();
57
- $jasper->compile(null);
58
- }*/
59
- /*public function testCompileWithWrongInput()
60
- {
61
- $this->setExpectedException(\PHPJasper\Exception\InvalidInputFile::class);
56
+ $ this ->expectException (\PHPJasper \Exception \InvalidInputFile::class);
62
57
63
58
$ jasper = new PHPJasper ();
59
+
64
60
$ jasper ->compile (null );
65
61
}
66
62
67
- public function testCompile ()
63
+ public function testCompileHelloWorld ()
68
64
{
69
65
$ jasper = new PHPJasper ();
66
+
70
67
$ result = $ jasper ->compile ('hello_world.jrxml ' );
71
68
72
69
$ this ->assertInstanceOf (PHPJasper::class, $ result );
73
- $this->assertEquals('./jasperstarter compile "hello_world.jrxml"', $result->output());
74
- }
75
70
71
+ if ($ this ->windows ) {
72
+
73
+ $ this ->assertEquals ('jasperstarter compile "hello_world.jrxml" ' , $ result ->output ());
74
+
75
+ }
76
+ else {
77
+
78
+ $ this ->assertEquals ('./jasperstarter compile "hello_world.jrxml" ' , $ result ->output ());
79
+ }
80
+
81
+ }
82
+
76
83
public function testExecuteWithoutCompile ()
77
84
{
78
- $this->setExpectedException (\PHPJasper\Exception\InvalidCommandExecutable::class);
85
+ $ this ->expectException (\PHPJasper \Exception \InvalidCommandExecutable::class);
79
86
80
87
$ jasper = new PHPJasper ();
81
88
$ jasper ->execute ();
82
89
}
83
-
90
+
84
91
public function testExecuteWithCompile ()
85
92
{
86
- $this->setExpectedException (\PHPJasper\Exception\ErrorCommandExecutable::class);
93
+ $ this ->expectException (\PHPJasper \Exception \ErrorCommandExecutable::class);
87
94
88
95
$ jasper = new PHPJasper ();
89
96
$ jasper ->compile ('hello_world.jrxml ' )->execute ();
90
97
}
91
-
98
+
92
99
public function testListParametersWithWrongInput ()
93
100
{
94
- $this->setExpectedException (\PHPJasper\Exception\InvalidInputFile::class);
101
+ $ this ->expectException (\PHPJasper \Exception \InvalidInputFile::class);
95
102
96
103
$ jasper = new PHPJasper ();
97
104
$ jasper ->listParameters ('' );
98
105
}
99
-
106
+
100
107
public function testProcessWithWrongInput ()
101
108
{
102
- $this->setExpectedException (\PHPJasper\Exception\InvalidInputFile::class);
109
+ $ this ->expectException (\PHPJasper \Exception \InvalidInputFile::class);
103
110
104
111
$ jasper = new PHPJasper ();
105
- $jasper->process(0);
112
+ $ jasper ->process (0 , "" );
106
113
}
107
-
114
+
108
115
public function testProcessWithWrongFormat ()
109
116
{
110
- $this->setExpectedException (\PHPJasper\Exception\InvalidFormat::class);
117
+ $ this ->expectException (\PHPJasper \Exception \InvalidFormat::class);
111
118
112
119
$ jasper = new PHPJasper ();
113
120
$ jasper ->process ('hello_world.jrxml ' , false , [
114
121
'format ' => 'mp3 '
115
122
]);
116
123
}
117
-
124
+
118
125
public function testProcess ()
119
126
{
120
127
$ jasper = new PHPJasper ();
121
- $this->assertInstanceOf(PHPJasper::class, $jasper->process('hello_world.jrxml'));
122
- }*/
128
+ $ this ->assertInstanceOf (PHPJasper::class, $ jasper ->process ('hello_world.jrxml ' , "" ));
129
+ }
123
130
124
131
}
0 commit comments