mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-31 12:10:10 +02:00
start a restructure
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace DesignPatterns\ChainOfResponsibilities;
|
namespace DesignPatterns\Behavioral\ChainOfResponsibilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler is a generic handler in the chain of responsibilities
|
* Handler is a generic handler in the chain of responsibilities
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace DesignPatterns\ChainOfResponsibilities;
|
namespace DesignPatterns\Behavioral\ChainOfResponsibilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request is a request which goes through the chain of responsibilities.
|
* Request is a request which goes through the chain of responsibilities.
|
@@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace DesignPatterns\ChainOfResponsibilities\Responsible;
|
namespace DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible;
|
||||||
|
|
||||||
use DesignPatterns\ChainOfResponsibilities\Handler;
|
use DesignPatterns\Behavioral\ChainOfResponsibilities\Handler;
|
||||||
use DesignPatterns\ChainOfResponsibilities\Request;
|
use DesignPatterns\Behavioral\ChainOfResponsibilities\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class FastStorage
|
* Class FastStorage
|
@@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace DesignPatterns\ChainOfResponsibilities\Responsible;
|
namespace DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible;
|
||||||
|
|
||||||
use DesignPatterns\ChainOfResponsibilities\Handler;
|
use DesignPatterns\Behavioral\ChainOfResponsibilities\Handler;
|
||||||
use DesignPatterns\ChainOfResponsibilities\Request;
|
use DesignPatterns\Behavioral\ChainOfResponsibilities\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is mostly the same code as FastStorage but in fact, it may greatly differs
|
* This is mostly the same code as FastStorage but in fact, it may greatly differs
|
@@ -1,9 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace DesignPatterns\Tests\ChainOfResponsibilities;
|
namespace DesignPatterns\Behavioral\Tests\ChainOfResponsibilities;
|
||||||
|
|
||||||
use DesignPatterns\ChainOfResponsibilities\Request;
|
use DesignPatterns\Behavioral\ChainOfResponsibilities\Request;
|
||||||
use DesignPatterns\ChainOfResponsibilities\Responsible;
|
use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\FastStorage;
|
||||||
|
use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\SlowStorage;
|
||||||
|
use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ChainTest tests the CoR
|
* ChainTest tests the CoR
|
||||||
@@ -11,12 +13,15 @@ use DesignPatterns\ChainOfResponsibilities\Responsible;
|
|||||||
class ChainTest extends \PHPUnit_Framework_TestCase
|
class ChainTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var FastStorage
|
||||||
|
*/
|
||||||
protected $chain;
|
protected $chain;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->chain = new Responsible\FastStorage(array('bar' => 'baz'));
|
$this->chain = new FastStorage(array('bar' => 'baz'));
|
||||||
$this->chain->append(new Responsible\SlowStorage(array('bar' => 'baz', 'foo' => 'bar')));
|
$this->chain->append(new SlowStorage(array('bar' => 'baz', 'foo' => 'bar')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function makeRequest()
|
public function makeRequest()
|
||||||
@@ -40,7 +45,7 @@ class ChainTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertObjectHasAttribute('response', $request);
|
$this->assertObjectHasAttribute('response', $request);
|
||||||
$this->assertEquals('baz', $request->response);
|
$this->assertEquals('baz', $request->response);
|
||||||
// despite both handle owns the 'bar' key, the FastStorage is responding first
|
// despite both handle owns the 'bar' key, the FastStorage is responding first
|
||||||
$this->assertEquals('DesignPatterns\ChainOfResponsibilities\Responsible\FastStorage', $request->forDebugOnly);
|
$this->assertEquals('DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\FastStorage', $request->forDebugOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,7 +60,7 @@ class ChainTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertObjectHasAttribute('response', $request);
|
$this->assertObjectHasAttribute('response', $request);
|
||||||
$this->assertEquals('bar', $request->response);
|
$this->assertEquals('bar', $request->response);
|
||||||
// FastStorage has no 'foo' key, the SlowStorage is responding
|
// FastStorage has no 'foo' key, the SlowStorage is responding
|
||||||
$this->assertEquals('DesignPatterns\ChainOfResponsibilities\Responsible\SlowStorage', $request->forDebugOnly);
|
$this->assertEquals('DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\SlowStorage', $request->forDebugOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,6 +73,6 @@ class ChainTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertFalse($ret);
|
$this->assertFalse($ret);
|
||||||
// the last responsible :
|
// the last responsible :
|
||||||
$this->assertEquals('DesignPatterns\ChainOfResponsibilities\Responsible\SlowStorage', $request->forDebugOnly);
|
$this->assertEquals('DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\SlowStorage', $request->forDebugOnly);
|
||||||
}
|
}
|
||||||
}
|
}
|
0
Specification/AbstractSpecification.php → Behavioral/Specification/AbstractSpecification.php
Executable file → Normal file
0
Specification/AbstractSpecification.php → Behavioral/Specification/AbstractSpecification.php
Executable file → Normal file
0
Specification/Either.php → Behavioral/Specification/Either.php
Executable file → Normal file
0
Specification/Either.php → Behavioral/Specification/Either.php
Executable file → Normal file
0
Specification/Not.php → Behavioral/Specification/Not.php
Executable file → Normal file
0
Specification/Not.php → Behavioral/Specification/Not.php
Executable file → Normal file
0
Specification/Plus.php → Behavioral/Specification/Plus.php
Executable file → Normal file
0
Specification/Plus.php → Behavioral/Specification/Plus.php
Executable file → Normal file
0
Specification/SpecificationInterface.php → Behavioral/Specification/SpecificationInterface.php
Executable file → Normal file
0
Specification/SpecificationInterface.php → Behavioral/Specification/SpecificationInterface.php
Executable file → Normal file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user