Files
DesignPatternsPHP/Creational/AbstractFactory/Tests/AbstractFactoryTest.php
2019-02-25 21:48:29 +01:00

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());
}
}