mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-09 16:36:37 +02:00
PHP7 Prototype
This commit is contained in:
27
Creational/Prototype/Tests/PrototypeTest.php
Normal file
27
Creational/Prototype/Tests/PrototypeTest.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Creational\Pool\Tests;
|
||||
|
||||
use DesignPatterns\Creational\Prototype\BarBookPrototype;
|
||||
use DesignPatterns\Creational\Prototype\FooBookPrototype;
|
||||
|
||||
class PrototypeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testCanGetFooBook()
|
||||
{
|
||||
$fooPrototype = new FooBookPrototype();
|
||||
$barPrototype = new BarBookPrototype();
|
||||
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$book = clone $fooPrototype;
|
||||
$book->setTitle('Foo Book No ' . $i);
|
||||
$this->assertInstanceOf('DesignPatterns\Creational\Prototype\FooBookPrototype', $book);
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$book = clone $barPrototype;
|
||||
$book->setTitle('Bar Book No ' . $i);
|
||||
$this->assertInstanceOf('DesignPatterns\Creational\Prototype\BarBookPrototype', $book);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user