@@ -45,7 +45,7 @@ public function testCompile()
45
45
46
46
$ expected = '.*jasperstarter compile ".*hello_world.jrxml" -o "{output_file}" ' ;
47
47
48
- $ this ->assertRegExp ('/ ' .$ expected .'/ ' , $ result ->output ());
48
+ $ this ->expectOutputRegex ('/ ' .$ expected .'/ ' , $ result ->output ());
49
49
}
50
50
51
51
public function testProcess ()
@@ -54,15 +54,42 @@ public function testProcess()
54
54
55
55
$ expected = '.*jasperstarter process ".*hello_world.jrxml" -o "{output_file}" ' ;
56
56
57
- $ this ->assertRegExp ('/ ' .$ expected .'/ ' , $ result ->output ());
57
+ $ this ->expectOutputRegex ('/ ' .$ expected .'/ ' , $ result ->output ());
58
+ }
58
59
60
+ public function testProcessWithOptions ()
61
+ {
62
+ $ options = [
63
+ 'locale ' => 'en_US ' ,
64
+ 'params ' => [
65
+ 'param_1 ' => 'value_1 ' ,
66
+ 'param_2 ' => 'value_2 ' ,
67
+ ],
68
+ 'db_connection ' => [
69
+ 'driver ' => 'driver ' ,
70
+ 'username ' => 'user ' ,
71
+ 'password ' => '12345678 ' ,
72
+ 'database ' => 'db '
73
+ ],
74
+ 'resources ' => 'foo ' ,
75
+ ];
76
+
77
+ $ result = $ this ->instance ->process ('examples/hello_world.jrxml ' , '{output_file} ' , $ options );
78
+
79
+ $ expected = '.*jasperstarter --locale en_US process ".*hello_world.jrxml" -o "{output_file}" ' ;
80
+ $ expected .= '-f pdf -P param_1="value_1" param_2="value_2" -t driver -u user -p 12345678 -n db -r foo ' ;
81
+
82
+ $ this ->expectOutputRegex (
83
+ '/ ' .$ expected .'/ ' ,
84
+ $ result ->output ()
85
+ );
59
86
}
60
87
61
88
public function testListParameters ()
62
89
{
63
90
$ result = $ this ->instance ->listParameters ('examples/hello_world.jrxml ' );
64
91
65
- $ this ->assertRegExp (
92
+ $ this ->expectOutputRegex (
66
93
'/.*jasperstarter list_parameters ".*hello_world.jrxml"/ ' ,
67
94
$ result ->output ()
68
95
);
@@ -79,7 +106,18 @@ public function testCompileHelloWorld()
79
106
{
80
107
$ result = $ this ->instance ->compile ('examples/hello_world.jrxml ' );
81
108
82
- $ this ->assertRegExp ('/.*jasperstarter compile ".*hello_world.jrxml"/ ' , $ result ->output ());
109
+ $ this ->expectOutputRegex ('/.*jasperstarter compile ".*hello_world.jrxml"/ ' , $ result ->output ());
110
+ }
111
+
112
+ public function testOutputWithUserOnExecute ()
113
+ {
114
+ $ this ->expectException (Exception \ErrorCommandExecutable::class);
115
+
116
+ $ this ->instance ->compile (__DIR__ . '/test.jrxml ' , __DIR__ . '/test ' )->execute ('phpjasper ' );
117
+
118
+ $ expected = 'su -u 1000 -c "./jasperstarter compile "/var/www/app/tests/test.jrxml" -o "/var/www/app/tests/test"" ' ;
119
+
120
+ $ this ->expectOutputRegex ('/ ' . $ expected . '/ ' , $ this ->instance ->output ());
83
121
}
84
122
85
123
public function testExecuteWithoutCompile ()
@@ -103,6 +141,25 @@ public function testExecute()
103
141
$ this ->assertInternalType ('array ' , $ actual );
104
142
}
105
143
144
+ public function testExecuteWithOutput ()
145
+ {
146
+ $ actual = $ this ->instance ->compile (__DIR__ . '/test.jrxml ' , __DIR__ . '/test ' )->execute ();
147
+
148
+ $ this ->assertInternalType ('array ' , $ actual );
149
+ }
150
+
151
+ public function testExecuteThrowsInvalidResourceDirectory ()
152
+ {
153
+ $ reflectionObject = new \ReflectionObject ($ this ->instance );
154
+ $ reflectionProperty = $ reflectionObject ->getProperty ('pathExecutable ' );
155
+ $ reflectionProperty ->setAccessible (true );
156
+ $ reflectionProperty ->setValue ($ this ->instance , '' );
157
+
158
+ $ this ->expectException (Exception \InvalidResourceDirectory::class);
159
+
160
+ $ this ->instance ->compile (__DIR__ . '/test.jrxml ' , __DIR__ . '/test ' )->execute ();
161
+ }
162
+
106
163
public function testListParametersWithWrongInput ()
107
164
{
108
165
$ this ->expectException (Exception \InvalidInputFile::class);
0 commit comments