mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-04 05:57:25 +02:00
it was created the Creational namespace and append its patterns
This commit is contained in:
30
Creational/Pool/PoolTest.php
Normal file
30
Creational/Pool/PoolTest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Creational\Pool;
|
||||
|
||||
use DesignPatterns\Creational\Pool\Pool;
|
||||
|
||||
class TestWorker
|
||||
{
|
||||
|
||||
public $id = 1;
|
||||
}
|
||||
|
||||
class PoolTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testPool()
|
||||
{
|
||||
$pool = new Pool('DesignPatterns\Creational\Pool\TestWorker');
|
||||
$worker = $pool->get();
|
||||
|
||||
$this->assertEquals(1, $worker->id);
|
||||
|
||||
$worker->id = 5;
|
||||
$pool->dispose($worker);
|
||||
|
||||
$this->assertEquals(5, $pool->get()->id);
|
||||
$this->assertEquals(1, $pool->get()->id);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user