Files
myep/tests/Service/ServiceLabelFormatterTest.php
T

64 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Service;
use App\BusProNet\Model\Service;
use App\Service\ServiceLabelFormatter;
use PHPUnit\Framework\TestCase;
class ServiceLabelFormatterTest extends TestCase
{
private ServiceLabelFormatter $formatter;
protected function setUp(): void
{
$this->formatter = new ServiceLabelFormatter();
}
public function testFormatServiceLabelReturnsLabelWithoutPrice(): void
{
$service = new Service();
$service->label = 'Skipass';
$service->price = null;
$this->assertSame('Skipass', $this->formatter->formatServiceLabel($service));
}
public function testFormatServiceLabelFormatsIncludedService(): void
{
$service = new Service();
$service->label = 'Ortstaxe';
$service->price = 0.0;
$this->assertSame('Ortstaxe (inkl.)', $this->formatter->formatServiceLabel($service));
}
public function testFormatServiceLabelFormatsPositivePrice(): void
{
$service = new Service();
$service->label = 'Parkplatz';
$service->price = 12.5;
$this->assertSame('Parkplatz (€12,50)', $this->formatter->formatServiceLabel($service));
}
public function testFormatServiceLabelFormatsNegativePrice(): void
{
$service = new Service();
$service->label = 'Rabatt';
$service->price = -8.0;
$this->assertSame('Rabatt (-8,00€ Rabatt)', $this->formatter->formatServiceLabel($service));
}
public function testFormatServiceLabelForServicesFallsBackWhenEmpty(): void
{
$this->assertSame(
'Verpflegung',
$this->formatter->formatServiceLabelForServices('Verpflegung', [])
);
}
}