start a restructure

This commit is contained in:
Antonio Spinelli
2014-03-21 18:03:44 -03:00
parent b0b0d4a1a4
commit e59d70a0ac
180 changed files with 21 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\ChainOfResponsibilities;
namespace DesignPatterns\Behavioral\ChainOfResponsibilities;
/**
* Handler is a generic handler in the chain of responsibilities

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\ChainOfResponsibilities;
namespace DesignPatterns\Behavioral\ChainOfResponsibilities;
/**
* Request is a request which goes through the chain of responsibilities.

View File

@@ -1,9 +1,9 @@
<?php
namespace DesignPatterns\ChainOfResponsibilities\Responsible;
namespace DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible;
use DesignPatterns\ChainOfResponsibilities\Handler;
use DesignPatterns\ChainOfResponsibilities\Request;
use DesignPatterns\Behavioral\ChainOfResponsibilities\Handler;
use DesignPatterns\Behavioral\ChainOfResponsibilities\Request;
/**
* Class FastStorage

View File

@@ -1,9 +1,9 @@
<?php
namespace DesignPatterns\ChainOfResponsibilities\Responsible;
namespace DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible;
use DesignPatterns\ChainOfResponsibilities\Handler;
use DesignPatterns\ChainOfResponsibilities\Request;
use DesignPatterns\Behavioral\ChainOfResponsibilities\Handler;
use DesignPatterns\Behavioral\ChainOfResponsibilities\Request;
/**
* This is mostly the same code as FastStorage but in fact, it may greatly differs

View File

@@ -1,9 +1,11 @@
<?php
namespace DesignPatterns\Tests\ChainOfResponsibilities;
namespace DesignPatterns\Behavioral\Tests\ChainOfResponsibilities;
use DesignPatterns\ChainOfResponsibilities\Request;
use DesignPatterns\ChainOfResponsibilities\Responsible;
use DesignPatterns\Behavioral\ChainOfResponsibilities\Request;
use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\FastStorage;
use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\SlowStorage;
use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible;
/**
* ChainTest tests the CoR
@@ -11,12 +13,15 @@ use DesignPatterns\ChainOfResponsibilities\Responsible;
class ChainTest extends \PHPUnit_Framework_TestCase
{
/**
* @var FastStorage
*/
protected $chain;
protected function setUp()
{
$this->chain = new Responsible\FastStorage(array('bar' => 'baz'));
$this->chain->append(new Responsible\SlowStorage(array('bar' => 'baz', 'foo' => 'bar')));
$this->chain = new FastStorage(array('bar' => 'baz'));
$this->chain->append(new SlowStorage(array('bar' => 'baz', 'foo' => 'bar')));
}
public function makeRequest()
@@ -40,7 +45,7 @@ class ChainTest extends \PHPUnit_Framework_TestCase
$this->assertObjectHasAttribute('response', $request);
$this->assertEquals('baz', $request->response);
// 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->assertEquals('bar', $request->response);
// 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);
// the last responsible :
$this->assertEquals('DesignPatterns\ChainOfResponsibilities\Responsible\SlowStorage', $request->forDebugOnly);
$this->assertEquals('DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\SlowStorage', $request->forDebugOnly);
}
}

View File

View File

View File

Some files were not shown because too many files have changed in this diff Show More