Skip to content

Commit

Permalink
Merge pull request #194 from PHPJasper/develop
Browse files Browse the repository at this point in the history
minor updates, printOutput() method
  • Loading branch information
geekcom committed Dec 10, 2019
2 parents 0dea327 + e2b3664 commit ac11aa1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 16 additions & 2 deletions src/PHPJasper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -239,7 +253,7 @@ public function output()
*/
public function printOutput()
{
print $this->output() . "\n";
print $this->command . "\n";
}

/**
Expand Down
36 changes: 14 additions & 22 deletions tests/PHPJasperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ public function setUp()
$this->instance = new PHPJasper();
}

public function tearDown()
{
unset($this->instance);
}

/** @test */
public function constructor()
{
Expand All @@ -44,22 +39,19 @@ 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()
{
$result = $this->instance->process('examples/hello_world.jrxml', '{output_file}');

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

$this->expectOutputRegex('/' . $expected . '/', $result->output());
$this->expectOutputRegex('/' . $expected . '/', $result->printOutput());
}

/** @test */
Expand All @@ -85,15 +77,15 @@ 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 */
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 */
Expand All @@ -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()
{
Expand All @@ -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 */
Expand Down Expand Up @@ -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");
}
}

0 comments on commit ac11aa1

Please sign in to comment.