mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-30 19:50:12 +02:00
26 lines
761 B
PHP
26 lines
761 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\More\EAV\Tests;
|
|
|
|
use DesignPatterns\More\EAV\Attribute;
|
|
use DesignPatterns\More\EAV\Entity;
|
|
use DesignPatterns\More\EAV\Value;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class EAVTest extends TestCase
|
|
{
|
|
public function testCanAddAttributeToEntity()
|
|
{
|
|
$colorAttribute = new Attribute('color');
|
|
$colorSilver = new Value($colorAttribute, 'silver');
|
|
$colorBlack = new Value($colorAttribute, 'black');
|
|
|
|
$memoryAttribute = new Attribute('memory');
|
|
$memory8Gb = new Value($memoryAttribute, '8GB');
|
|
|
|
$entity = new Entity('MacBook Pro', [$colorSilver, $colorBlack, $memory8Gb]);
|
|
|
|
$this->assertEquals('MacBook Pro, color: silver, color: black, memory: 8GB', (string) $entity);
|
|
}
|
|
}
|