Skip to content

Commit 7ea963d

Browse files
authored
Merge pull request #173 from PHPJasper/master
master into develop
2 parents 94a427d + c315036 commit 7ea963d

File tree

5 files changed

+111
-7
lines changed

5 files changed

+111
-7
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
5+
---
6+
7+
**Describe the bug**
8+
A clear and concise description of what the bug is.
9+
10+
**To Reproduce**
11+
Steps to reproduce the behavior:
12+
1. Go to '...'
13+
2. Click on '....'
14+
3. Scroll down to '....'
15+
4. See error
16+
17+
**Expected behavior**
18+
A clear and concise description of what you expected to happen.
19+
20+
**Screenshots**
21+
If applicable, add screenshots to help explain your problem.
22+
23+
**Desktop (please complete the following information):**
24+
- OS: [e.g. iOS]
25+
- Browser [e.g. chrome, safari]
26+
- Version [e.g. 22]
27+
28+
**Additional context**
29+
Add any other context about the problem here.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
5+
---
6+
7+
**Is your feature request related to a problem? Please describe.**
8+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9+
10+
**Describe the solution you'd like**
11+
A clear and concise description of what you want to happen.
12+
13+
**Describe alternatives you've considered**
14+
A clear and concise description of any alternative solutions or features you've considered.
15+
16+
**Additional context**
17+
Add any other context or screenshots about the feature request here.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/vendor
22
tests/*.jasper
3+
tests/fixture
34
tests/codeCoverage
45

56
# IDE
@@ -8,4 +9,4 @@ tests/codeCoverage
89
.project
910
.settings
1011
## PHPStorm
11-
.idea/
12+
.idea/

docs/pt_BR/LEIA-ME_pt_BR.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Apresento para vocês **JasperReports** a melhor solução open source que exist
3333

3434
**Texto extraido do site JasperSoft:**
3535

36-
> A biblioteca JasperReports é o mecanismo de geração de relatórios de código aberto mais popular do mundo. É inteiramente escrito em Java e é capaz de usar dados provenientes de qualquer tipo de fonte de dados e gerar documentos perfeitos que podem ser visualizado, impressom ou exportadom em uma variedade de formatos de documentos, incluindo HTML, PDF, Excel, OpenOffice e Word .
36+
> A biblioteca JasperReports é o mecanismo de geração de relatórios de código aberto mais popular do mundo. É inteiramente escrito em Java e é capaz de usar dados provenientes de qualquer tipo de fonte de dados e gerar documentos perfeitos que podem ser visualizado, impresso ou exportado em uma variedade de formatos de documentos, incluindo HTML, PDF, Excel, OpenOffice e Word .
3737
3838
*Exemplos do que você pode fazer:*
3939

@@ -339,4 +339,4 @@ MIT
339339

340340
## [Contribuição](https://github.com/PHPJasper/phpjasper/blob/master/CONTRIBUTING.md)
341341

342-
Contribua com a comunidade PHP, faça um fork !!
342+
Contribua com a comunidade PHP, faça um fork !!

tests/PHPJasperTest.php

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testCompile()
4545

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

48-
$this->assertRegExp('/'.$expected.'/', $result->output());
48+
$this->expectOutputRegex('/'.$expected.'/', $result->output());
4949
}
5050

5151
public function testProcess()
@@ -54,15 +54,42 @@ public function testProcess()
5454

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

57-
$this->assertRegExp('/'.$expected.'/', $result->output());
57+
$this->expectOutputRegex('/'.$expected.'/', $result->output());
58+
}
5859

60+
public function testProcessWithOptions()
61+
{
62+
$options = [
63+
'locale' => 'en_US',
64+
'params' => [
65+
'param_1' => 'value_1',
66+
'param_2' => 'value_2',
67+
],
68+
'db_connection' => [
69+
'driver' => 'driver',
70+
'username' => 'user',
71+
'password' => '12345678',
72+
'database' => 'db'
73+
],
74+
'resources' => 'foo',
75+
];
76+
77+
$result = $this->instance->process('examples/hello_world.jrxml', '{output_file}', $options);
78+
79+
$expected = '.*jasperstarter --locale en_US process ".*hello_world.jrxml" -o "{output_file}" ';
80+
$expected .= '-f pdf -P param_1="value_1" param_2="value_2" -t driver -u user -p 12345678 -n db -r foo';
81+
82+
$this->expectOutputRegex(
83+
'/'.$expected.'/',
84+
$result->output()
85+
);
5986
}
6087

6188
public function testListParameters()
6289
{
6390
$result = $this->instance->listParameters('examples/hello_world.jrxml');
6491

65-
$this->assertRegExp(
92+
$this->expectOutputRegex(
6693
'/.*jasperstarter list_parameters ".*hello_world.jrxml"/',
6794
$result->output()
6895
);
@@ -79,7 +106,18 @@ public function testCompileHelloWorld()
79106
{
80107
$result = $this->instance->compile('examples/hello_world.jrxml');
81108

82-
$this->assertRegExp('/.*jasperstarter compile ".*hello_world.jrxml"/', $result->output());
109+
$this->expectOutputRegex('/.*jasperstarter compile ".*hello_world.jrxml"/', $result->output());
110+
}
111+
112+
public function testOutputWithUserOnExecute()
113+
{
114+
$this->expectException(Exception\ErrorCommandExecutable::class);
115+
116+
$this->instance->compile(__DIR__ . '/test.jrxml', __DIR__ . '/test')->execute('phpjasper');
117+
118+
$expected = 'su -u 1000 -c "./jasperstarter compile "/var/www/app/tests/test.jrxml" -o "/var/www/app/tests/test""';
119+
120+
$this->expectOutputRegex('/' . $expected . '/', $this->instance->output());
83121
}
84122

85123
public function testExecuteWithoutCompile()
@@ -103,6 +141,25 @@ public function testExecute()
103141
$this->assertInternalType('array', $actual);
104142
}
105143

144+
public function testExecuteWithOutput()
145+
{
146+
$actual = $this->instance->compile(__DIR__ . '/test.jrxml', __DIR__ . '/test')->execute();
147+
148+
$this->assertInternalType('array', $actual);
149+
}
150+
151+
public function testExecuteThrowsInvalidResourceDirectory()
152+
{
153+
$reflectionObject = new \ReflectionObject($this->instance);
154+
$reflectionProperty = $reflectionObject->getProperty('pathExecutable');
155+
$reflectionProperty->setAccessible(true);
156+
$reflectionProperty->setValue($this->instance, '');
157+
158+
$this->expectException(Exception\InvalidResourceDirectory::class);
159+
160+
$this->instance->compile(__DIR__ . '/test.jrxml', __DIR__ . '/test')->execute();
161+
}
162+
106163
public function testListParametersWithWrongInput()
107164
{
108165
$this->expectException(Exception\InvalidInputFile::class);

0 commit comments

Comments
 (0)