feat: voucher purchase flow
This commit is contained in:
1 parent
a628e96d06
commit
f3dd122678
70 files changed
+3672
-122
No files matched your search
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Service;
|
||||
|
||||
use App\BusProNet\Model\VoucherTemplate;
|
||||
use App\Service\VoucherThumbnailResolver;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class VoucherThumbnailResolverTest extends TestCase
|
||||
{
|
||||
private string $manifestPath;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->manifestPath = tempnam(sys_get_temp_dir(), 'manifest');
|
||||
file_put_contents($this->manifestPath, json_encode([
|
||||
'build/images/vouchers/muster_3.jpg' => '/build/images/vouchers/muster_3.0a1b2c3d.jpg',
|
||||
]));
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
@unlink($this->manifestPath);
|
||||
}
|
||||
|
||||
public function testAThumbnailIsFoundByTheTemplateId(): void
|
||||
{
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$logger->expects(self::never())->method('warning');
|
||||
|
||||
$resolver = new VoucherThumbnailResolver($this->manifestPath, $logger);
|
||||
|
||||
self::assertSame('build/images/vouchers/muster_3.jpg', $resolver->resolve(new VoucherTemplate(3, 'K', 'Allgemein')));
|
||||
}
|
||||
|
||||
public function testANewDesignWithoutAThumbnailRendersWithoutOneAndIsReported(): void
|
||||
{
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$logger->expects(self::once())->method('warning')->with('No thumbnail for voucher template', self::callback(
|
||||
static fn (array $context) => 6 === $context['template_id'] && 'assets/vouchers/muster_6.jpg' === $context['expected_source']
|
||||
));
|
||||
|
||||
$resolver = new VoucherThumbnailResolver($this->manifestPath, $logger);
|
||||
|
||||
self::assertSame(
|
||||
[3 => 'build/images/vouchers/muster_3.jpg', 6 => null],
|
||||
$resolver->resolveAll([new VoucherTemplate(3, 'K', 'Allgemein'), new VoucherTemplate(6, 'K', 'Ostern')]),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user