Skip to content

Commit

Permalink
Merge pull request #98 from PHPJasper/develop
Browse files Browse the repository at this point in the history
fix tests
  • Loading branch information
geekcom authored Mar 15, 2018
2 parents 674aca0 + 90d2b37 commit 3062cd7
Showing 1 changed file with 27 additions and 34 deletions.
61 changes: 27 additions & 34 deletions tests/PHPJasper/PHPJasperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@
*/
class PHPJasperTest extends TestCase
{
/**
* @var
*/
private $instance;

public function setUp()
{
$this->PHPJasper = new PHPJasper();
$this->instance = new PHPJasper();
}

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

public function testConstructor()
Expand All @@ -38,20 +43,26 @@ public function testConstructor()

public function testCompile()
{
$result = $this->PHPJasper->compile('examples/hello_world.jrxml', '{output_file}');

$this->assertInstanceOf(PHPJasper::class, $result);
$result = $this->instance->compile('examples/hello_world.jrxml', '{output_file}');

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

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

public function testListParameters()
public function testProcess()
{
$result = $this->PHPJasper->listParameters('examples/hello_world.jrxml');
$result = $this->instance->process('examples/hello_world.jrxml', '{output_file}');

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

$this->assertRegExp('/'.$expected.'/', $result->output());

}

$this->assertInstanceOf(PHPJasper::class, $result);
public function testListParameters()
{
$result = $this->instance->listParameters('examples/hello_world.jrxml');

$this->assertRegExp(
'/.*jasperstarter list_parameters ".*hello_world.jrxml"/',
Expand All @@ -63,18 +74,12 @@ public function testCompileWithWrongInput()
{
$this->expectException(\PHPJasper\Exception\InvalidInputFile::class);

$jasper = new PHPJasper();

$jasper->compile('');
$this->instance->compile('');
}

public function testCompileHelloWorld()
{
$jasper = new PHPJasper();

$result = $jasper->compile('examples/hello_world.jrxml');

$this->assertInstanceOf(PHPJasper::class, $result);
$result = $this->instance->compile('examples/hello_world.jrxml');

$this->assertRegExp('/.*jasperstarter compile ".*hello_world.jrxml"/', $result->output());
}
Expand All @@ -83,22 +88,19 @@ public function testExecuteWithoutCompile()
{
$this->expectException(\PHPJasper\Exception\InvalidCommandExecutable::class);

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

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

$jasper = new PHPJasper();
$jasper->compile('{invalid}')->execute();
$this->instance->compile('{invalid}')->execute();
}

public function testExecute()
{
$jasper = new PHPJasper();
$actual = $jasper->compile(__DIR__ . '/test.jrxml')->execute();
$actual = $this->instance->compile(__DIR__ . '/test.jrxml')->execute();

$this->assertInternalType('array', $actual);
}
Expand All @@ -107,16 +109,14 @@ public function testListParametersWithWrongInput()
{
$this->expectException(\PHPJasper\Exception\InvalidInputFile::class);

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

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

$jasper = new PHPJasper();
$jasper->process('', '', [
$this->instance->process('', '', [
'format' => 'mp3'
]);
}
Expand All @@ -125,15 +125,8 @@ public function testProcessWithWrongFormat()
{
$this->expectException(\PHPJasper\Exception\InvalidFormat::class);

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

public function testProcess()
{
$jasper = new PHPJasper();
$this->assertInstanceOf(PHPJasper::class, $jasper->process('hello_world.jrxml', ""));
}
}

0 comments on commit 3062cd7

Please sign in to comment.