Skip to content

Commit 3062cd7

Browse files
authored
Merge pull request #98 from PHPJasper/develop
fix tests
2 parents 674aca0 + 90d2b37 commit 3062cd7

File tree

1 file changed

+27
-34
lines changed

1 file changed

+27
-34
lines changed

tests/PHPJasper/PHPJasperTest.php

+27-34
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,19 @@
2121
*/
2222
class PHPJasperTest extends TestCase
2323
{
24+
/**
25+
* @var
26+
*/
27+
private $instance;
28+
2429
public function setUp()
2530
{
26-
$this->PHPJasper = new PHPJasper();
31+
$this->instance = new PHPJasper();
2732
}
2833

2934
public function tearDown()
3035
{
31-
unset($this->PHPJasper);
36+
unset($this->instance);
3237
}
3338

3439
public function testConstructor()
@@ -38,20 +43,26 @@ public function testConstructor()
3843

3944
public function testCompile()
4045
{
41-
$result = $this->PHPJasper->compile('examples/hello_world.jrxml', '{output_file}');
42-
43-
$this->assertInstanceOf(PHPJasper::class, $result);
46+
$result = $this->instance->compile('examples/hello_world.jrxml', '{output_file}');
4447

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

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

50-
public function testListParameters()
53+
public function testProcess()
5154
{
52-
$result = $this->PHPJasper->listParameters('examples/hello_world.jrxml');
55+
$result = $this->instance->process('examples/hello_world.jrxml', '{output_file}');
56+
57+
$expected = '.*jasperstarter process ".*hello_world.jrxml" -o "{output_file}"';
58+
59+
$this->assertRegExp('/'.$expected.'/', $result->output());
60+
61+
}
5362

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

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

66-
$jasper = new PHPJasper();
67-
68-
$jasper->compile('');
77+
$this->instance->compile('');
6978
}
7079

7180
public function testCompileHelloWorld()
7281
{
73-
$jasper = new PHPJasper();
74-
75-
$result = $jasper->compile('examples/hello_world.jrxml');
76-
77-
$this->assertInstanceOf(PHPJasper::class, $result);
82+
$result = $this->instance->compile('examples/hello_world.jrxml');
7883

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

86-
$jasper = new PHPJasper();
87-
$jasper->execute();
91+
$this->instance->execute();
8892
}
8993

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

94-
$jasper = new PHPJasper();
95-
$jasper->compile('{invalid}')->execute();
98+
$this->instance->compile('{invalid}')->execute();
9699
}
97100

98101
public function testExecute()
99102
{
100-
$jasper = new PHPJasper();
101-
$actual = $jasper->compile(__DIR__ . '/test.jrxml')->execute();
103+
$actual = $this->instance->compile(__DIR__ . '/test.jrxml')->execute();
102104

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

110-
$jasper = new PHPJasper();
111-
$jasper->listParameters('');
112+
$this->instance->listParameters('');
112113
}
113114

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

118-
$jasper = new PHPJasper();
119-
$jasper->process('', '', [
119+
$this->instance->process('', '', [
120120
'format' => 'mp3'
121121
]);
122122
}
@@ -125,15 +125,8 @@ public function testProcessWithWrongFormat()
125125
{
126126
$this->expectException(\PHPJasper\Exception\InvalidFormat::class);
127127

128-
$jasper = new PHPJasper();
129-
$jasper->process('hello_world.jrxml', '', [
128+
$this->instance->process('hello_world.jrxml', '', [
130129
'format' => 'mp3'
131130
]);
132131
}
133-
134-
public function testProcess()
135-
{
136-
$jasper = new PHPJasper();
137-
$this->assertInstanceOf(PHPJasper::class, $jasper->process('hello_world.jrxml', ""));
138-
}
139132
}

0 commit comments

Comments
 (0)