42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Tests\Entity;
|
||
|
|
|
||
|
|
use App\Entity\Options;
|
||
|
|
use Cocur\Slugify\Slugify; // Not needed for entity test
|
||
|
|
use PHPUnit\Framework\TestCase;
|
||
|
|
|
||
|
|
class OptionsTest extends TestCase
|
||
|
|
{
|
||
|
|
public function testGettersAndSetters()
|
||
|
|
{
|
||
|
|
$options = new Options();
|
||
|
|
$now = new \DateTimeImmutable();
|
||
|
|
|
||
|
|
$options->setName('Test Option');
|
||
|
|
$options->setPriceHt(25.0);
|
||
|
|
$options->setStripeId('opt_123');
|
||
|
|
$options->setImageName('option.jpg');
|
||
|
|
$options->setImageSize(512);
|
||
|
|
$options->setUpdatedAt($now);
|
||
|
|
|
||
|
|
$this->assertEquals('Test Option', $options->getName());
|
||
|
|
$this->assertEquals(25.0, $options->getPriceHt());
|
||
|
|
$this->assertEquals('opt_123', $options->getStripeId());
|
||
|
|
$this->assertEquals('option.jpg', $options->getImageName());
|
||
|
|
$this->assertEquals(512, $options->getImageSize());
|
||
|
|
$this->assertSame($now, $options->getUpdatedAt());
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testSlug()
|
||
|
|
{
|
||
|
|
$options = new Options();
|
||
|
|
// ID is auto-generated, cannot be set directly in unit test
|
||
|
|
// For slug test, we will assume ID is null, or set it via reflection if absolutely needed.
|
||
|
|
// For simplicity, we will test the slug with a null ID.
|
||
|
|
$options->setName('Test Option');
|
||
|
|
|
||
|
|
$this->assertEquals('test-option', $options->slug());
|
||
|
|
}
|
||
|
|
}
|