diff --git a/README.md b/README.md
index a3d4d87..165598f 100755
--- a/README.md
+++ b/README.md
@@ -350,4 +350,4 @@ MIT
## [Contribute](https://github.com/PHPJasper/phpjasper/blob/master/CONTRIBUTING.md)
-Contribute to the community PHP, make a fork!!
\ No newline at end of file
+Contribute to the community PHP, make a fork!
\ No newline at end of file
diff --git a/phpunit.xml b/phpunit.xml
index 6fb4231..27e98e0 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -12,8 +12,7 @@
- src/PHPJasper
- src/JasperStarter
+ ./src
diff --git a/src/PHPJasper.php b/src/PHPJasper.php
index bfe0fb4..3614000 100644
--- a/src/PHPJasper.php
+++ b/src/PHPJasper.php
@@ -52,9 +52,9 @@ public function __construct()
* @return $this
* @throws Exception\InvalidInputFile
*/
- public function compile(string $input, string $output = '')
+ public function compile($input, string $output = '')
{
- if (!$input) {
+ if ( !$input ) {
throw new \PHPJasper\Exception\InvalidInputFile();
}
diff --git a/tests/PHPJasper/PHPJasperTest.php b/tests/PHPJasper/PHPJasperTest.php
index 6040e74..1bc2f5a 100644
--- a/tests/PHPJasper/PHPJasperTest.php
+++ b/tests/PHPJasper/PHPJasperTest.php
@@ -17,10 +17,12 @@ final class PHPJasperTest extends TestCase
private $PHPJasper;
private $input;
private $output;
+ protected $windows;
public function setUp()
{
$this->PHPJasper = new PHPJasper();
+ $this->windows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? true : false;
}
public function tearDown()
@@ -38,7 +40,11 @@ public function testCompile()
$result = $this->PHPJasper->compile('{input_file}', '{output_file}');
$this->assertInstanceOf(PHPJasper::class, $result);
- $this->assertEquals('jasperstarter compile "{input_file}" -o "{output_file}"', $result->output());
+
+ $expected = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? '' : './';
+ $expected .= 'jasperstarter compile "{input_file}" -o "{output_file}"';
+
+ $this->assertEquals($expected, $result->output());
}
public function testListParameters()
@@ -46,68 +52,98 @@ public function testListParameters()
$result = $this->PHPJasper->listParameters('{input_fille}');
$this->assertInstanceOf(PHPJasper::class, $result);
- $this->assertEquals('jasperstarter list_parameters "{input_fille}"', $result->output());
- }
- /*public function testCompileWithWrongInput()
- {
- $this->setExpectedExceptionFromAnnotation(\PHPJasper\Exception\InvalidInputFile::class);
+ $expected = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? '' : './';
+ $expected .= 'jasperstarter list_parameters "{input_fille}"';
- $jasper = new PHPJasper();
- $jasper->compile(null);
- }*/
- /*public function testCompileWithWrongInput()
+ $this->assertEquals($expected, $result->output());
+ }
+
+ public function testCompileWithWrongInput()
{
- $this->setExpectedException(\PHPJasper\Exception\InvalidInputFile::class);
+ $this->expectException(\PHPJasper\Exception\InvalidInputFile::class);
$jasper = new PHPJasper();
+
$jasper->compile(null);
}
- public function testCompile()
+ public function testCompileHelloWorld()
{
$jasper = new PHPJasper();
+
$result = $jasper->compile('hello_world.jrxml');
$this->assertInstanceOf(PHPJasper::class, $result);
- $this->assertEquals('./jasperstarter compile "hello_world.jrxml"', $result->output());
- }
+ if($this->windows) {
+
+ $this->assertEquals('jasperstarter compile "hello_world.jrxml"', $result->output());
+
+ }
+ else {
+
+ $this->assertEquals('./jasperstarter compile "hello_world.jrxml"', $result->output());
+ }
+
+ }
+
public function testExecuteWithoutCompile()
{
- $this->setExpectedException(\PHPJasper\Exception\InvalidCommandExecutable::class);
+ $this->expectException(\PHPJasper\Exception\InvalidCommandExecutable::class);
$jasper = new PHPJasper();
$jasper->execute();
}
-
+
public function testExecuteWithCompile()
{
- $this->setExpectedException(\PHPJasper\Exception\ErrorCommandExecutable::class);
+ $this->expectException(\PHPJasper\Exception\ErrorCommandExecutable::class);
$jasper = new PHPJasper();
$jasper->compile('hello_world.jrxml')->execute();
}
+ public function testExecute()
+ {
+ $jasper = new PHPJasper();
+ $actual = $jasper->compile(__DIR__ . '/test.jrxml')->execute();
+
+ $this->assertInternalType('array', $actual);
+ }
+
+ public function testResourceDirectoryException()
+ {
+ $this->expectException(\PHPJasper\Exception\InvalidResourceDirectory::class);
+
+ $jasper = new PHPJasper();
+ $jasperReflection = new \ReflectionClass(get_class($jasper));
+ $property = $jasperReflection->getProperty('pathExecutable');
+ $property->setAccessible(true);
+ $property->setValue($jasper,'');
+
+ $jasper->compile(__DIR__ . '/test.jrxml')->execute();
+ }
+
public function testListParametersWithWrongInput()
{
- $this->setExpectedException(\PHPJasper\Exception\InvalidInputFile::class);
+ $this->expectException(\PHPJasper\Exception\InvalidInputFile::class);
$jasper = new PHPJasper();
$jasper->listParameters('');
}
-
+
public function testProcessWithWrongInput()
{
- $this->setExpectedException(\PHPJasper\Exception\InvalidInputFile::class);
+ $this->expectException(\PHPJasper\Exception\InvalidInputFile::class);
$jasper = new PHPJasper();
- $jasper->process(0);
+ $jasper->process(0, "");
}
-
+
public function testProcessWithWrongFormat()
{
- $this->setExpectedException(\PHPJasper\Exception\InvalidFormat::class);
+ $this->expectException(\PHPJasper\Exception\InvalidFormat::class);
$jasper = new PHPJasper();
$jasper->process('hello_world.jrxml', false, [
@@ -118,7 +154,6 @@ public function testProcessWithWrongFormat()
public function testProcess()
{
$jasper = new PHPJasper();
- $this->assertInstanceOf(PHPJasper::class, $jasper->process('hello_world.jrxml'));
- }*/
-
+ $this->assertInstanceOf(PHPJasper::class, $jasper->process('hello_world.jrxml', ""));
+ }
}
\ No newline at end of file
diff --git a/tests/PHPJasper/test.jrxml b/tests/PHPJasper/test.jrxml
new file mode 100644
index 0000000..7e71db3
--- /dev/null
+++ b/tests/PHPJasper/test.jrxml
@@ -0,0 +1,414 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 5)]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+