Skip to content

Commit ac11aa1

Browse files
authored
Merge pull request #194 from PHPJasper/develop
minor updates, printOutput() method
2 parents 0dea327 + e2b3664 commit ac11aa1

File tree

3 files changed

+33
-25
lines changed

3 files changed

+33
-25
lines changed

CHANGES.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
Release Notes - PHPJasper - Version 3.0.1
1+
Release Notes - PHPJasper - Version 3.1.0
22
========================================================
33
* Improvement
4+
* added printOutput() method
5+
* Refactoring
46
* output() method
57
________________________________________________________
68
Release Notes - PHPJasper - Version 3.0.0

src/PHPJasper.php

+16-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,21 @@ class PHPJasper
4141
/**
4242
* @var array
4343
*/
44-
protected $formats = ['pdf', 'rtf', 'xls', 'xlsx', 'docx', 'odt', 'ods', 'pptx', 'csv', 'html', 'xhtml', 'xml', 'jrprint'];
44+
protected $formats = [
45+
'pdf',
46+
'rtf',
47+
'xls',
48+
'xlsx',
49+
'docx',
50+
'odt',
51+
'ods',
52+
'pptx',
53+
'csv',
54+
'html',
55+
'xhtml',
56+
'xml',
57+
'jrprint'
58+
];
4559

4660
/**
4761
* PHPJasper constructor
@@ -239,7 +253,7 @@ public function output()
239253
*/
240254
public function printOutput()
241255
{
242-
print $this->output() . "\n";
256+
print $this->command . "\n";
243257
}
244258

245259
/**

tests/PHPJasperTest.php

+14-22
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ public function setUp()
3030
$this->instance = new PHPJasper();
3131
}
3232

33-
public function tearDown()
34-
{
35-
unset($this->instance);
36-
}
37-
3833
/** @test */
3934
public function constructor()
4035
{
@@ -44,22 +39,19 @@ public function constructor()
4439
/** @test */
4540
public function compile()
4641
{
47-
$result = $this->instance->compile('examples/hello_world.jrxml', '{output_file}');
48-
49-
$expected = '.*jasperstarter compile ".*hello_world.jrxml" -o "{output_file}"';
42+
$result = $this->instance->compile('examples/hello_world.jrxml');
5043

51-
$this->expectOutputRegex('/' . $expected . '/', $result->output());
44+
$this->expectOutputRegex('/.*jasperstarter compile ".*hello_world.jrxml"/', $result->printOutput());
5245
}
5346

54-
5547
/** @test */
5648
public function process()
5749
{
5850
$result = $this->instance->process('examples/hello_world.jrxml', '{output_file}');
5951

6052
$expected = '.*jasperstarter process ".*hello_world.jrxml" -o "{output_file}"';
6153

62-
$this->expectOutputRegex('/' . $expected . '/', $result->output());
54+
$this->expectOutputRegex('/' . $expected . '/', $result->printOutput());
6355
}
6456

6557
/** @test */
@@ -85,15 +77,15 @@ public function processWithOptions()
8577
$expected = '.*jasperstarter --locale en_US process ".*hello_world.jrxml" -o "{output_file}" ';
8678
$expected .= '-f pdf -P param_1="value_1" param_2="value_2" -t driver -u user -p 12345678 -n db -r foo';
8779

88-
$this->expectOutputRegex('/' . $expected . '/', $result->output());
80+
$this->expectOutputRegex('/' . $expected . '/', $result->printOutput());
8981
}
9082

9183
/** @test */
9284
public function listParameters()
9385
{
9486
$result = $this->instance->listParameters('examples/hello_world.jrxml');
9587

96-
$this->expectOutputRegex('/.*jasperstarter list_parameters ".*hello_world.jrxml"/', $result->output());
88+
$this->expectOutputRegex('/.*jasperstarter list_parameters ".*hello_world.jrxml"/', $result->printOutput());
9789
}
9890

9991
/** @test */
@@ -104,14 +96,6 @@ public function compileWithWrongInput()
10496
$this->instance->compile('');
10597
}
10698

107-
/** @test */
108-
public function compileHelloWorld()
109-
{
110-
$result = $this->instance->compile('examples/hello_world.jrxml');
111-
112-
$this->expectOutputRegex('/.*jasperstarter compile ".*hello_world.jrxml"/', $result->output());
113-
}
114-
11599
/** @test */
116100
public function outputWithUserOnExecute()
117101
{
@@ -121,7 +105,7 @@ public function outputWithUserOnExecute()
121105

122106
$expected = 'su -u 1000 -c "./jasperstarter compile "/var/www/app/tests/test.jrxml" -o "/var/www/app/tests/test""';
123107

124-
$this->expectOutputRegex('/' . $expected . '/', $this->instance->output());
108+
$this->expectOutputRegex('/' . $expected . '/', $this->instance->printOutput());
125109
}
126110

127111
/** @test */
@@ -204,4 +188,12 @@ public function processWithWrongFormat()
204188
]
205189
);
206190
}
191+
192+
/** @test */
193+
public function output()
194+
{
195+
$result = $this->instance->listParameters('examples/hello_world.jrxml');
196+
197+
$this->expectOutputRegex('/.*jasperstarter list_parameters ".*hello_world.jrxml' . '/', $result->output() . "\n");
198+
}
207199
}

0 commit comments

Comments
 (0)