-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b603713
commit 9563d42
Showing
7 changed files
with
281 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/* | ||
* This file is part of the Calculation package. | ||
* | ||
* (c) bibi.nu <bibi@bibi.nu> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Tests\Report; | ||
|
||
use App\Controller\AbstractController; | ||
use App\Entity\CalculationState; | ||
use App\Report\CalculationStatesReport; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\MockObject\Exception; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
#[CoversClass(CalculationStatesReport::class)] | ||
class CalculationStatesReportTest extends TestCase | ||
{ | ||
/** | ||
* @throws Exception | ||
*/ | ||
public function testRender(): void | ||
{ | ||
$controller = $this->createMock(AbstractController::class); | ||
|
||
$state1 = new CalculationState(); | ||
$state1->setCode('Code1'); | ||
|
||
$state2 = new CalculationState(); | ||
$state2->setCode('Code2') | ||
->setColor(''); | ||
|
||
$report = new CalculationStatesReport($controller, [$state1, $state2]); | ||
$actual = $report->render(); | ||
self::assertTrue($actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
/* | ||
* This file is part of the Calculation package. | ||
* | ||
* (c) bibi.nu <bibi@bibi.nu> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Tests\Report; | ||
|
||
use App\Controller\AbstractController; | ||
use App\Report\CommandsReport; | ||
use App\Service\CommandService; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\MockObject\Exception; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @psalm-import-type CommandType from CommandService | ||
*/ | ||
#[CoversClass(CommandsReport::class)] | ||
class CommandsReportTest extends TestCase | ||
{ | ||
/** | ||
* @throws Exception | ||
* | ||
* @psalm-suppress InvalidArgument | ||
*/ | ||
public function testRender(): void | ||
{ | ||
$controller = $this->createMock(AbstractController::class); | ||
|
||
$argument1 = [ | ||
'name' => 'Argument', | ||
'is_required' => false, | ||
'is_array' => false, | ||
'description' => 'Description', | ||
'display' => 'Display', | ||
'arguments' => 'Arguments', | ||
]; | ||
$argument2 = [ | ||
'name' => 'Argument', | ||
'is_required' => false, | ||
'is_array' => false, | ||
'description' => '', | ||
'display' => '', | ||
'arguments' => '', | ||
]; | ||
$option = [ | ||
'name' => 'Option', | ||
'shortcut' => 'Shortcut', | ||
'name_shortcut' => 'Name Shortcut', | ||
'accept_value' => true, | ||
'is_value_required' => true, | ||
'is_multiple' => true, | ||
'description' => 'Description', | ||
'default' => 'Default', | ||
'display' => 'Display', | ||
'arguments' => 'Arguments', | ||
]; | ||
$command1 = [ | ||
'name' => 'Command1', | ||
'description' => 'Description', | ||
'usage' => ['Usage 1', 'Usage 2'], | ||
'help' => '<a href="https://symfony.com>storing-uuids-in-databases">database</a>. The <span class="info">list</span>.', | ||
'hidden' => false, | ||
'definition' => [ | ||
'arguments' => [ | ||
'Argument1' => $argument1, | ||
'Argument2' => $argument2, | ||
], | ||
'options' => ['Option' => $option], | ||
], | ||
]; | ||
$command2 = [ | ||
'name' => 'Command2', | ||
'description' => '', | ||
'usage' => [], | ||
'help' => '', | ||
'hidden' => false, | ||
'definition' => [ | ||
'arguments' => [], | ||
'options' => [], | ||
], | ||
]; | ||
$commands = [$command1, $command2]; | ||
$report = new CommandsReport($controller, ['Group' => $commands]); | ||
$actual = $report->render(); | ||
self::assertTrue($actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/* | ||
* This file is part of the Calculation package. | ||
* | ||
* (c) bibi.nu <bibi@bibi.nu> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Tests\Report; | ||
|
||
use App\Controller\AbstractController; | ||
use App\Entity\Customer; | ||
use App\Report\CustomersReport; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\MockObject\Exception; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
#[CoversClass(CustomersReport::class)] | ||
class CustomersReportTest extends TestCase | ||
{ | ||
/** | ||
* @throws Exception | ||
*/ | ||
public function testRenderGrouped(): void | ||
{ | ||
$controller = $this->createMock(AbstractController::class); | ||
$customer1 = new Customer(); | ||
$customer1->setFirstName('First Name') | ||
->setLastName('A Last Name') | ||
->setEmail('email@email.com'); | ||
|
||
$customer2 = new Customer(); | ||
$customer2->setFirstName('First Name') | ||
->setLastName('B Last Name') | ||
->setEmail('email@email.com'); | ||
|
||
$customer3 = new Customer(); | ||
$customer3->setFirstName('') | ||
->setLastName('') | ||
->setEmail('email@email.com'); | ||
|
||
$report = new CustomersReport($controller, [$customer1, $customer2, $customer3]); | ||
$actual = $report->render(); | ||
self::assertTrue($actual); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
public function testRenderNotGrouped(): void | ||
{ | ||
$controller = $this->createMock(AbstractController::class); | ||
$customer = new Customer(); | ||
$customer->setFirstName('First Name') | ||
->setLastName('Last Name') | ||
->setEmail('email@email.com'); | ||
|
||
$report = new CustomersReport($controller, [$customer], false); | ||
$actual = $report->render(); | ||
self::assertTrue($actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
/* | ||
* This file is part of the Calculation package. | ||
* | ||
* (c) bibi.nu <bibi@bibi.nu> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Tests\Report; | ||
|
||
use App\Controller\AbstractController; | ||
use App\Report\MemoryImageReport; | ||
use fpdf\PdfException; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\MockObject\Exception; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
#[CoversClass(MemoryImageReport::class)] | ||
class MemoryImageReportTest extends TestCase | ||
{ | ||
/** | ||
* @throws Exception | ||
*/ | ||
public function testEmptyImage(): void | ||
{ | ||
self::expectException(PdfException::class); | ||
$controller = $this->createMock(AbstractController::class); | ||
$image = __DIR__ . '/../Data/empty.txt'; | ||
$report = new MemoryImageReport($controller, $image); | ||
$report->render(); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
public function testInvalidImage(): void | ||
{ | ||
self::expectException(PdfException::class); | ||
$controller = $this->createMock(AbstractController::class); | ||
$report = new MemoryImageReport($controller, __FILE__); | ||
$report->render(); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
public function testRender(): void | ||
{ | ||
$controller = $this->createMock(AbstractController::class); | ||
$image = __DIR__ . '/../Data/images/example.png'; | ||
$report = new MemoryImageReport($controller, $image); | ||
$actual = $report->render(); | ||
self::assertTrue($actual); | ||
} | ||
} |