for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace ApplicationTest\Model;
use Application\Model\Product;
use PHPUnit\Framework\TestCase;
class ProductTest extends TestCase
{
public function testRelatedProducts(): void
$product1 = new Product();
$product2 = new Product();
self::assertCount(0, $product1->getRelatedProducts());
self::assertCount(0, $product2->getRelatedProducts());
$product1->addRelatedProduct($product2);
self::assertCount(1, $product1->getRelatedProducts());
self::assertSame($product2, $product1->getRelatedProducts()->first());
self::assertFalse($product2->getRelatedProducts()->first());
$product1->removeRelatedProduct($product2);
}
public function testRelatedProductWithSelf(): void
$this->expectExceptionMessage('A product cannot be related to itself');
$product = new Product();
$product->addRelatedProduct($product);