mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-25 17:21:19 +02:00
45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace DesignPatterns\Behavioral\State\Tests;
|
|
|
|
use DesignPatterns\Behavioral\State\OrderContext;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class StateTest extends TestCase
|
|
{
|
|
public function testIsCreatedWithStateCreated()
|
|
{
|
|
$orderContext = OrderContext::create();
|
|
|
|
$this->assertSame('created', $orderContext->toString());
|
|
}
|
|
|
|
public function testCanProceedToStateShipped()
|
|
{
|
|
$contextOrder = OrderContext::create();
|
|
$contextOrder->proceedToNext();
|
|
|
|
$this->assertSame('shipped', $contextOrder->toString());
|
|
}
|
|
|
|
public function testCanProceedToStateDone()
|
|
{
|
|
$contextOrder = OrderContext::create();
|
|
$contextOrder->proceedToNext();
|
|
$contextOrder->proceedToNext();
|
|
|
|
$this->assertSame('done', $contextOrder->toString());
|
|
}
|
|
|
|
public function testStateDoneIsTheLastPossibleState()
|
|
{
|
|
$contextOrder = OrderContext::create();
|
|
$contextOrder->proceedToNext();
|
|
$contextOrder->proceedToNext();
|
|
$contextOrder->proceedToNext();
|
|
|
|
$this->assertSame('done', $contextOrder->toString());
|
|
}
|
|
}
|