Skip to content

fix tests #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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', ""));
}
}