Skip to content

Increase test coverage #70

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 5 commits into from
Oct 9, 2017
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

<filter>
<whitelist>
<directory>src/PHPJasper</directory>
<directory>src/JasperStarter</directory>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>

Expand Down
36 changes: 32 additions & 4 deletions tests/PHPJasper/PHPJasperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,23 @@ 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()
{
$result = $this->PHPJasper->listParameters('{input_fille}');

$this->assertInstanceOf(PHPJasper::class, $result);
$this->assertEquals('jasperstarter list_parameters "{input_fille}"', $result->output());

$expected = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? '' : './';
$expected .= 'jasperstarter list_parameters "{input_fille}"';

$this->assertEquals($expected, $result->output());
}

public function testCompileWithWrongInput()
Expand Down Expand Up @@ -95,6 +103,27 @@ public function testExecuteWithCompile()
$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()
{
Expand All @@ -121,11 +150,10 @@ public function testProcessWithWrongFormat()
'format' => 'mp3'
]);
}

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

}
Loading