Skip to content

Commit

Permalink
general improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
geekcom committed Oct 10, 2017
1 parent 96f7d14 commit 2e5dbab
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 52 deletions.
11 changes: 10 additions & 1 deletion src/PHPJasper.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the PHPJasper.
*
* (c) Daniel Rodrigues (geekcom)
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace PHPJasper;
Expand Down Expand Up @@ -52,7 +61,7 @@ public function __construct()
* @return $this
* @throws Exception\InvalidInputFile
*/
public function compile($input, string $output = '')
public function compile(string $input, string $output = '')
{
if ( !$input ) {
throw new \PHPJasper\Exception\InvalidInputFile();
Expand Down
13 changes: 0 additions & 13 deletions tests/PHPJasper/PHPJasperCommandTest.php

This file was deleted.

67 changes: 29 additions & 38 deletions tests/PHPJasper/PHPJasperTest.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
<?php

/*
* This file is part of the PHPJasper.
*
* (c) Daniel Rodrigues (geekcom)
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace PHPJasper\Test;

use PHPUnit\Framework\TestCase;
use PHPJasper\PHPJasper;

final class PHPJasperTest extends TestCase
/**
* Class PHPJasperTest
*
* @author Rafael Queiroz <[email protected]>
* @author Daniel Rodrigues Lima ( geekcom ) <[email protected]>
* @package PHPJasper
*/
{
private $PHPJasper;
private $input;
private $output;
protected $windows;
/**
* @author Rafael Queiroz <[email protected]>
*/
class PHPJasperTest extends TestCase

{
public function setUp()
{
$this->PHPJasper = new PHPJasper();
Expand Down Expand Up @@ -64,8 +67,8 @@ public function testCompileWithWrongInput()
$this->expectException(\PHPJasper\Exception\InvalidInputFile::class);

$jasper = new PHPJasper();
$jasper->compile(null);

$jasper->compile('');
}

public function testCompileHelloWorld()
Expand All @@ -76,26 +79,25 @@ public function testCompileHelloWorld()

$this->assertInstanceOf(PHPJasper::class, $result);

if($this->windows) {
if ($this->windows) {

$this->assertEquals('jasperstarter compile "hello_world.jrxml"', $result->output());

}
else {

} else {

$this->assertEquals('./jasperstarter compile "hello_world.jrxml"', $result->output());
}

}

public function testExecuteWithoutCompile()
{
$this->expectException(\PHPJasper\Exception\InvalidCommandExecutable::class);

$jasper = new PHPJasper();
$jasper->execute();
}

public function testExecuteWithCompile()
{
$this->expectException(\PHPJasper\Exception\ErrorCommandExecutable::class);
Expand All @@ -112,41 +114,30 @@ public function testExecute()
$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->expectException(\PHPJasper\Exception\InvalidInputFile::class);

$jasper = new PHPJasper();
$jasper->listParameters('');
}

public function testProcessWithWrongInput()
{
$this->expectException(\PHPJasper\Exception\InvalidInputFile::class);

$jasper = new PHPJasper();
$jasper->process(0, "");
$jasper->process('', '', [
'format' => 'mp3'
]);
}

public function testProcessWithWrongFormat()
{
$this->expectException(\PHPJasper\Exception\InvalidFormat::class);

$jasper = new PHPJasper();
$jasper->process('hello_world.jrxml', false, [
$jasper->process('hello_world.jrxml', '', [
'format' => 'mp3'
]);
}
Expand Down

0 comments on commit 2e5dbab

Please sign in to comment.