Skip to content

Commit b0bb4f6

Browse files
authored
Merge pull request #185 from PHPJasper/develop
update: tests, add: phpcs.xml
2 parents 942c895 + 4d43ea8 commit b0bb4f6

File tree

4 files changed

+74
-36
lines changed

4 files changed

+74
-36
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/vendor
22
tests/*.jasper
33
tests/fixture
4-
tests/codeCoverage
4+
/tests/logs
5+
.phpcs-cache
56

67
# IDE
78
## Eclipse

phpcs.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<ruleset>
3+
<arg name="basepath" value="."/>
4+
<arg name="extensions" value="php"/>
5+
<arg name="parallel" value="80"/>
6+
<arg name="cache" value=".phpcs-cache"/>
7+
<arg name="colors"/>
8+
9+
<arg value="p"/>
10+
11+
<exclude-pattern type="relative">^/tests/*</exclude-pattern>
12+
13+
<file>src</file>
14+
15+
<rule ref="PSR12"/>
16+
</ruleset>

phpunit.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
</filter>
1818

1919
<testsuites>
20-
<testsuite name="Test Suite">
20+
<testsuite name="PHPJasper Test Suite">
2121
<directory>tests</directory>
2222
</testsuite>
2323
</testsuites>
2424

2525
<logging>
26-
<log type="coverage-html" target="tests/codeCoverage/html"
26+
<log type="coverage-html" target="tests/logs/coverage"
2727
lowUpperBound="50" highLowerBound="80" charset="UTF-8"/>
28+
<log type="testdox-html" target="tests/logs/testdox/testdox.html"/>
2829
</logging>
2930
</phpunit>

tests/PHPJasperTest.php

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use PHPUnit\Framework\TestCase;
1717
use PHPJasper\PHPJasper;
1818
use PHPJasper\Exception;
19+
use ReflectionObject;
1920

2021
/**
2122
* @author Rafael Queiroz <rafaelfqf@gmail.com>
@@ -34,30 +35,35 @@ public function tearDown()
3435
unset($this->instance);
3536
}
3637

37-
public function testConstructor()
38+
/** @test */
39+
public function constructor()
3840
{
3941
$this->assertInstanceOf(PHPJasper::class, new PHPJasper());
4042
}
4143

42-
public function testCompile()
44+
/** @test */
45+
public function compile()
4346
{
4447
$result = $this->instance->compile('examples/hello_world.jrxml', '{output_file}');
4548

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

48-
$this->expectOutputRegex('/'.$expected.'/', $result->output());
51+
$this->expectOutputRegex('/' . $expected . '/', $result->output());
4952
}
5053

51-
public function testProcess()
54+
55+
/** @test */
56+
public function process()
5257
{
5358
$result = $this->instance->process('examples/hello_world.jrxml', '{output_file}');
5459

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

57-
$this->expectOutputRegex('/'.$expected.'/', $result->output());
62+
$this->expectOutputRegex('/' . $expected . '/', $result->output());
5863
}
5964

60-
public function testProcessWithOptions()
65+
/** @test */
66+
public function processWithOptions()
6167
{
6268
$options = [
6369
'locale' => 'en_US',
@@ -79,37 +85,35 @@ public function testProcessWithOptions()
7985
$expected = '.*jasperstarter --locale en_US process ".*hello_world.jrxml" -o "{output_file}" ';
8086
$expected .= '-f pdf -P param_1="value_1" param_2="value_2" -t driver -u user -p 12345678 -n db -r foo';
8187

82-
$this->expectOutputRegex(
83-
'/'.$expected.'/',
84-
$result->output()
85-
);
88+
$this->expectOutputRegex('/' . $expected . '/', $result->output());
8689
}
8790

88-
public function testListParameters()
91+
/** @test */
92+
public function listParameters()
8993
{
9094
$result = $this->instance->listParameters('examples/hello_world.jrxml');
9195

92-
$this->expectOutputRegex(
93-
'/.*jasperstarter list_parameters ".*hello_world.jrxml"/',
94-
$result->output()
95-
);
96+
$this->expectOutputRegex('/.*jasperstarter list_parameters ".*hello_world.jrxml"/', $result->output());
9697
}
9798

98-
public function testCompileWithWrongInput()
99+
/** @test */
100+
public function compileWithWrongInput()
99101
{
100102
$this->expectException(Exception\InvalidInputFile::class);
101103

102104
$this->instance->compile('');
103105
}
104106

105-
public function testCompileHelloWorld()
107+
/** @test */
108+
public function compileHelloWorld()
106109
{
107110
$result = $this->instance->compile('examples/hello_world.jrxml');
108111

109112
$this->expectOutputRegex('/.*jasperstarter compile ".*hello_world.jrxml"/', $result->output());
110113
}
111114

112-
public function testOutputWithUserOnExecute()
115+
/** @test */
116+
public function outputWithUserOnExecute()
113117
{
114118
$this->expectException(Exception\ErrorCommandExecutable::class);
115119

@@ -120,37 +124,42 @@ public function testOutputWithUserOnExecute()
120124
$this->expectOutputRegex('/' . $expected . '/', $this->instance->output());
121125
}
122126

123-
public function testExecuteWithoutCompile()
127+
/** @test */
128+
public function executeWithoutCompile()
124129
{
125130
$this->expectException(Exception\InvalidCommandExecutable::class);
126131

127132
$this->instance->execute();
128133
}
129134

130-
public function testInvalidInputFile()
135+
/** @test */
136+
public function invalidInputFile()
131137
{
132138
$this->expectException(Exception\InvalidInputFile::class);
133139

134140
$this->instance->compile('{invalid}')->execute();
135141
}
136142

137-
public function testExecute()
143+
/** @test */
144+
public function execute()
138145
{
139146
$actual = $this->instance->compile(__DIR__ . '/test.jrxml')->execute();
140147

141148
$this->assertInternalType('array', $actual);
142149
}
143150

144-
public function testExecuteWithOutput()
151+
/** @test */
152+
public function executeWithOutput()
145153
{
146154
$actual = $this->instance->compile(__DIR__ . '/test.jrxml', __DIR__ . '/test')->execute();
147155

148156
$this->assertInternalType('array', $actual);
149157
}
150158

151-
public function testExecuteThrowsInvalidResourceDirectory()
159+
/** @test */
160+
public function executeThrowsInvalidResourceDirectory()
152161
{
153-
$reflectionObject = new \ReflectionObject($this->instance);
162+
$reflectionObject = new ReflectionObject($this->instance);
154163
$reflectionProperty = $reflectionObject->getProperty('pathExecutable');
155164
$reflectionProperty->setAccessible(true);
156165
$reflectionProperty->setValue($this->instance, '');
@@ -160,28 +169,39 @@ public function testExecuteThrowsInvalidResourceDirectory()
160169
$this->instance->compile(__DIR__ . '/test.jrxml', __DIR__ . '/test')->execute();
161170
}
162171

163-
public function testListParametersWithWrongInput()
172+
/** @test */
173+
public function listParametersWithWrongInput()
164174
{
165175
$this->expectException(Exception\InvalidInputFile::class);
166176

167177
$this->instance->listParameters('');
168178
}
169179

170-
public function testProcessWithWrongInput()
180+
/** @test */
181+
public function processWithWrongInput()
171182
{
172183
$this->expectException(Exception\InvalidInputFile::class);
173184

174-
$this->instance->process('', '', [
175-
'format' => 'mp3'
176-
]);
185+
$this->instance->process(
186+
'',
187+
'',
188+
[
189+
'format' => 'mp3'
190+
]
191+
);
177192
}
178193

179-
public function testProcessWithWrongFormat()
194+
/** @test */
195+
public function processWithWrongFormat()
180196
{
181197
$this->expectException(Exception\InvalidFormat::class);
182198

183-
$this->instance->process('hello_world.jrxml', '', [
184-
'format' => 'mp3'
185-
]);
199+
$this->instance->process(
200+
'hello_world.jrxml',
201+
'',
202+
[
203+
'format' => 'mp3'
204+
]
205+
);
186206
}
187207
}

0 commit comments

Comments
 (0)