mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-03 14:43:07 +02:00
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace DesignPatterns\Creational\AbstractFactory\Tests;
|
|
|
|
use DesignPatterns\Creational\AbstractFactory\DigitalProduct;
|
|
use DesignPatterns\Creational\AbstractFactory\ProductFactory;
|
|
use DesignPatterns\Creational\AbstractFactory\ShippableProduct;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class AbstractFactoryTest extends TestCase
|
|
{
|
|
public function testCanCreateDigitalProduct()
|
|
{
|
|
$factory = new ProductFactory();
|
|
$product = $factory->createDigitalProduct(150);
|
|
|
|
$this->assertInstanceOf(DigitalProduct::class, $product);
|
|
}
|
|
|
|
public function testCanCreateShippableProduct()
|
|
{
|
|
$factory = new ProductFactory();
|
|
$product = $factory->createShippableProduct(150);
|
|
|
|
$this->assertInstanceOf(ShippableProduct::class, $product);
|
|
}
|
|
|
|
public function testCanCalculatePriceForDigitalProduct()
|
|
{
|
|
$factory = new ProductFactory();
|
|
$product = $factory->createDigitalProduct(150);
|
|
|
|
$this->assertEquals(150, $product->calculatePrice());
|
|
}
|
|
|
|
public function testCanCalculatePriceForShippableProduct()
|
|
{
|
|
$factory = new ProductFactory();
|
|
$product = $factory->createShippableProduct(150);
|
|
|
|
$this->assertEquals(200, $product->calculatePrice());
|
|
}
|
|
}
|