From e2b3664d4d4fed7acbf2d4c53c7e0ad9ba120ae2 Mon Sep 17 00:00:00 2001 From: geekcom Date: Tue, 10 Dec 2019 12:36:27 -0300 Subject: [PATCH] minor updates, printOutput() method --- CHANGES.md | 4 +++- src/PHPJasper.php | 18 ++++++++++++++++-- tests/PHPJasperTest.php | 36 ++++++++++++++---------------------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2f318cb..20141ff 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,8 @@ -Release Notes - PHPJasper - Version 3.0.1 +Release Notes - PHPJasper - Version 3.1.0 ======================================================== * Improvement + * added printOutput() method +* Refactoring * output() method ________________________________________________________ Release Notes - PHPJasper - Version 3.0.0 diff --git a/src/PHPJasper.php b/src/PHPJasper.php index f4b3ec8..6b3e68e 100644 --- a/src/PHPJasper.php +++ b/src/PHPJasper.php @@ -41,7 +41,21 @@ class PHPJasper /** * @var array */ - protected $formats = ['pdf', 'rtf', 'xls', 'xlsx', 'docx', 'odt', 'ods', 'pptx', 'csv', 'html', 'xhtml', 'xml', 'jrprint']; + protected $formats = [ + 'pdf', + 'rtf', + 'xls', + 'xlsx', + 'docx', + 'odt', + 'ods', + 'pptx', + 'csv', + 'html', + 'xhtml', + 'xml', + 'jrprint' + ]; /** * PHPJasper constructor @@ -239,7 +253,7 @@ public function output() */ public function printOutput() { - print $this->output() . "\n"; + print $this->command . "\n"; } /** diff --git a/tests/PHPJasperTest.php b/tests/PHPJasperTest.php index 2a00412..bca8afd 100644 --- a/tests/PHPJasperTest.php +++ b/tests/PHPJasperTest.php @@ -30,11 +30,6 @@ public function setUp() $this->instance = new PHPJasper(); } - public function tearDown() - { - unset($this->instance); - } - /** @test */ public function constructor() { @@ -44,14 +39,11 @@ public function constructor() /** @test */ public function compile() { - $result = $this->instance->compile('examples/hello_world.jrxml', '{output_file}'); - - $expected = '.*jasperstarter compile ".*hello_world.jrxml" -o "{output_file}"'; + $result = $this->instance->compile('examples/hello_world.jrxml'); - $this->expectOutputRegex('/' . $expected . '/', $result->output()); + $this->expectOutputRegex('/.*jasperstarter compile ".*hello_world.jrxml"/', $result->printOutput()); } - /** @test */ public function process() { @@ -59,7 +51,7 @@ public function process() $expected = '.*jasperstarter process ".*hello_world.jrxml" -o "{output_file}"'; - $this->expectOutputRegex('/' . $expected . '/', $result->output()); + $this->expectOutputRegex('/' . $expected . '/', $result->printOutput()); } /** @test */ @@ -85,7 +77,7 @@ public function processWithOptions() $expected = '.*jasperstarter --locale en_US process ".*hello_world.jrxml" -o "{output_file}" '; $expected .= '-f pdf -P param_1="value_1" param_2="value_2" -t driver -u user -p 12345678 -n db -r foo'; - $this->expectOutputRegex('/' . $expected . '/', $result->output()); + $this->expectOutputRegex('/' . $expected . '/', $result->printOutput()); } /** @test */ @@ -93,7 +85,7 @@ public function listParameters() { $result = $this->instance->listParameters('examples/hello_world.jrxml'); - $this->expectOutputRegex('/.*jasperstarter list_parameters ".*hello_world.jrxml"/', $result->output()); + $this->expectOutputRegex('/.*jasperstarter list_parameters ".*hello_world.jrxml"/', $result->printOutput()); } /** @test */ @@ -104,14 +96,6 @@ public function compileWithWrongInput() $this->instance->compile(''); } - /** @test */ - public function compileHelloWorld() - { - $result = $this->instance->compile('examples/hello_world.jrxml'); - - $this->expectOutputRegex('/.*jasperstarter compile ".*hello_world.jrxml"/', $result->output()); - } - /** @test */ public function outputWithUserOnExecute() { @@ -121,7 +105,7 @@ public function outputWithUserOnExecute() $expected = 'su -u 1000 -c "./jasperstarter compile "/var/www/app/tests/test.jrxml" -o "/var/www/app/tests/test""'; - $this->expectOutputRegex('/' . $expected . '/', $this->instance->output()); + $this->expectOutputRegex('/' . $expected . '/', $this->instance->printOutput()); } /** @test */ @@ -204,4 +188,12 @@ public function processWithWrongFormat() ] ); } + + /** @test */ + public function output() + { + $result = $this->instance->listParameters('examples/hello_world.jrxml'); + + $this->expectOutputRegex('/.*jasperstarter list_parameters ".*hello_world.jrxml' . '/', $result->output() . "\n"); + } }