it was created the Behavioral namespace and append its patterns

This commit is contained in:
Antonio Spinelli
2014-04-15 22:25:48 -03:00
parent 2f7837927f
commit 646e0e2fd9
47 changed files with 88 additions and 77 deletions

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Behavioral\Tests\ChainOfResponsibilities;
namespace DesignPatterns\Behavioral\ChainOfResponsibilities;
use DesignPatterns\Behavioral\ChainOfResponsibilities\Request;
use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\FastStorage;

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Behavioral\Command\Tests;
namespace DesignPatterns\Behavioral\Command;
use DesignPatterns\Behavioral\Command\Invoker;
use DesignPatterns\Behavioral\Command\Receiver;

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Behavioral\Iterator\Tests;
namespace DesignPatterns\Behavioral\Iterator;
use DesignPatterns\Behavioral\Iterator\Book;
use DesignPatterns\Behavioral\Iterator\BookList;

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Mediator;
namespace DesignPatterns\Behavioral\Mediator;
/**
* Colleague is an abstract colleague who works together but he only knows

View File

@@ -1,20 +1,29 @@
<?php
namespace DesignPatterns\Mediator;
namespace DesignPatterns\Behavioral\Mediator;
use DesignPatterns\Mediator\Subsystem;
use DesignPatterns\Behavioral\Mediator\Subsystem;
/**
* Mediator is the concrete Mediator for this design pattern.
*
* In this example, I have made a "Hello World" with the Mediator Pattern.
*/
class Mediator implements MediatorInterface
{
// you could have an array
/**
* @var Subsystem\Server
*/
protected $server;
/**
* @var Subsystem\Database
*/
protected $database;
/**
* @var Subsystem\Client
*/
protected $client;
/**
@@ -39,7 +48,6 @@ class Mediator implements MediatorInterface
/**
* query db
*
* @return mixed
*/
public function queryDb()

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Mediator;
namespace DesignPatterns\Behavioral\Mediator;
/**
* MediatorInterface is a contract for the Mediator

View File

@@ -2,10 +2,10 @@
namespace DesignPatterns\Tests\Mediator;
use DesignPatterns\Mediator\Mediator;
use DesignPatterns\Mediator\Subsystem\Database;
use DesignPatterns\Mediator\Subsystem\Client;
use DesignPatterns\Mediator\Subsystem\Server;
use DesignPatterns\Behavioral\Mediator\Mediator;
use DesignPatterns\Behavioral\Mediator\Subsystem\Database;
use DesignPatterns\Behavioral\Mediator\Subsystem\Client;
use DesignPatterns\Behavioral\Mediator\Subsystem\Server;
/**
* MediatorTest tests hello world

View File

@@ -1,8 +1,8 @@
<?php
namespace DesignPatterns\Mediator\Subsystem;
namespace DesignPatterns\Behavioral\Mediator\Subsystem;
use DesignPatterns\Mediator\Colleague;
use DesignPatterns\Behavioral\Mediator\Colleague;
/**
* Client is a client that make request et get response

View File

@@ -1,8 +1,8 @@
<?php
namespace DesignPatterns\Mediator\Subsystem;
namespace DesignPatterns\Behavioral\Mediator\Subsystem;
use DesignPatterns\Mediator\Colleague;
use DesignPatterns\Behavioral\Mediator\Colleague;
/**
* Database is a database service

View File

@@ -1,8 +1,8 @@
<?php
namespace DesignPatterns\Mediator\Subsystem;
namespace DesignPatterns\Behavioral\Mediator\Subsystem;
use DesignPatterns\Mediator\Colleague;
use DesignPatterns\Behavioral\Mediator\Colleague;
/**
* Server serves responses

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\NullObject;
namespace DesignPatterns\Behavioral\NullObject;
/**
* LoggerInterface is a contract for logging something

View File

@@ -1,10 +1,10 @@
<?php
namespace DesignPatterns\Tests\NullObject;
namespace DesignPatterns\Behavioral\NullObject;
use DesignPatterns\NullObject\NullLogger;
use DesignPatterns\NullObject\Service;
use DesignPatterns\NullObject\PrintLogger;
use DesignPatterns\Behavioral\NullObject\NullLogger;
use DesignPatterns\Behavioral\NullObject\Service;
use DesignPatterns\Behavioral\NullObject\PrintLogger;
/**
* LoggerTest tests for different loggers
@@ -24,7 +24,7 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
public function testStandardLogger()
{
$service = new Service(new PrintLogger());
$this->expectOutputString('We are in DesignPatterns\NullObject\Service::doSomething');
$this->expectOutputString('We are in DesignPatterns\Behavioral\NullObject\Service::doSomething');
$service->doSomething();
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\NullObject;
namespace DesignPatterns\Behavioral\NullObject;
/**
* Performance concerns : ok there is a call for nothing but we spare an "if is_null"

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\NullObject;
namespace DesignPatterns\Behavioral\NullObject;
/**
* PrintLogger is a logger that prints the log entry to standard output

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\NullObject;
namespace DesignPatterns\Behavioral\NullObject;
/**
* Service is dummy service that uses a logger

View File

@@ -1,9 +1,9 @@
<?php
namespace DesignPatterns\Tests\Observer;
namespace DesignPatterns\Behavioral\Observer;
use DesignPatterns\Observer\UserObserver;
use DesignPatterns\Observer\User;
use DesignPatterns\Behavioral\Observer\UserObserver;
use DesignPatterns\Behavioral\Observer\User;
/**
* ObserverTest tests the Observer pattern
@@ -23,7 +23,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
*/
public function testNotify()
{
$this->expectOutputString('DesignPatterns\Observer\User has been updated');
$this->expectOutputString('DesignPatterns\Behavioral\Observer\User has been updated');
$subject = new User();
$subject->attach($this->observer);

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Observer;
namespace DesignPatterns\Behavioral\Observer;
/**
* Observer pattern : The observed object (the subject)

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Observer;
namespace DesignPatterns\Behavioral\Observer;
/**
* class UserObserver

View File

@@ -1,5 +1,5 @@
<?php
namespace DesignPatterns\Specification;
namespace DesignPatterns\Behavioral\Specification;
/**
* An abstract specification allows the creation of wrapped specifications

View File

@@ -1,5 +1,5 @@
<?php
namespace DesignPatterns\Specification;
namespace DesignPatterns\Behavioral\Specification;
/**
* A logical OR specification

View File

@@ -1,5 +1,5 @@
<?php
namespace DesignPatterns\Specification;
namespace DesignPatterns\Behavioral\Specification;
/**
* An trivial item

View File

@@ -1,5 +1,5 @@
<?php
namespace DesignPatterns\Specification;
namespace DesignPatterns\Behavioral\Specification;
/**
* A logical Not specification

View File

@@ -1,5 +1,5 @@
<?php
namespace DesignPatterns\Specification;
namespace DesignPatterns\Behavioral\Specification;
/**
* A logical AND specification

View File

@@ -1,5 +1,5 @@
<?php
namespace DesignPatterns\Specification;
namespace DesignPatterns\Behavioral\Specification;
/**
* A specification to check an Item is priced between min and max

View File

@@ -1,5 +1,5 @@
<?php
namespace DesignPatterns\Specification;
namespace DesignPatterns\Behavioral\Specification;
/**
* An interface for a specification

View File

@@ -1,9 +1,9 @@
<?php
namespace DesignPatterns\Tests\Specification;
namespace DesignPatterns\Behavioral\Specification;
use DesignPatterns\Specification\PriceSpecification;
use DesignPatterns\Specification\Item;
use DesignPatterns\Behavioral\Specification\PriceSpecification;
use DesignPatterns\Behavioral\Specification\Item;
/**
* SpecificationTest tests the specification pattern

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Status;
namespace DesignPatterns\Behavioral\State;
/**
* Class CreateOrder

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Status;
namespace DesignPatterns\Behavioral\State;
/**
* Class OrderController

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Status;
namespace DesignPatterns\Behavioral\State;
/**
* Class OrderFactory
@@ -9,7 +9,7 @@ class OrderFactory
{
private function __construct()
{
throw Exception('Can not instance the OrderFactory class!');
throw new \Exception('Can not instance the OrderFactory class!');
}
/**

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Status;
namespace DesignPatterns\Behavioral\State;
/**
* Class OrderInterface

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Status;
namespace DesignPatterns\Behavioral\State;
/**
* Class ShippingOrder

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Strategy;
namespace DesignPatterns\Behavioral\Strategy;
/**
* Class ComparatorInterface

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Strategy;
namespace DesignPatterns\Behavioral\Strategy;
/**
* Class DateComparator

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Strategy;
namespace DesignPatterns\Behavioral\Strategy;
/**
* Class IdComparator

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Strategy;
namespace DesignPatterns\Behavioral\Strategy;
/**
* Class ObjectCollection

View File

@@ -1,11 +1,11 @@
<?php
namespace DesignPatterns\Tests\Strategy;
namespace DesignPatterns\Behavioral\Strategy;
use DesignPatterns\Strategy\DateComparator;
use DesignPatterns\Strategy\IdComparator;
use DesignPatterns\Strategy\ObjectCollection;
use DesignPatterns\Strategy\Strategy;
use DesignPatterns\Behavioral\Strategy\DateComparator;
use DesignPatterns\Behavioral\Strategy\IdComparator;
use DesignPatterns\Behavioral\Strategy\ObjectCollection;
use DesignPatterns\Behavioral\Strategy\Strategy;
/**
* Tests for Static Factory pattern

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\TemplateMethod;
namespace DesignPatterns\Behavioral\TemplateMethod;
/**
* BeachJourney is vacation at the beach

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\TemplateMethod;
namespace DesignPatterns\Behavioral\TemplateMethod;
/**
* CityJourney is a journey in a city

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\TemplateMethod;
namespace DesignPatterns\Behavioral\TemplateMethod;
/**
*

View File

@@ -1,8 +1,8 @@
<?php
namespace DesignPatterns\Tests\TemplateMethod;
namespace DesignPatterns\Behavioral\TemplateMethod;
use DesignPatterns\TemplateMethod;
use DesignPatterns\Behavioral\TemplateMethod;
/**
* JourneyTest tests all journeys
@@ -29,7 +29,7 @@ class JourneyTest extends \PHPUnit_Framework_TestCase
*/
public function testLasVegas()
{
$journey = $this->getMockForAbstractClass('DesignPatterns\TemplateMethod\Journey');
$journey = $this->getMockForAbstractClass('DesignPatterns\Behavioral\TemplateMethod\Journey');
$journey->expects($this->once())
->method('enjoyVacation')
->will($this->returnCallback(array($this, 'mockUpVacation')));

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Visitor;
namespace DesignPatterns\Behavioral\Visitor;
/**
* An example of a Visitor: Group

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Visitor;
namespace DesignPatterns\Behavioral\Visitor;
/**
* class Role
@@ -12,7 +12,7 @@ abstract class Role
*
* Feel free to override it if your object must call another visiting behavior
*
* @param \DesignPatterns\Visitor\RoleVisitorInterface $visitor
* @param \DesignPatterns\Behavioral\Visitor\RoleVisitorInterface $visitor
*
* @throws \InvalidArgumentException
*/

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Visitor;
namespace DesignPatterns\Behavioral\Visitor;
/**
* Visitor Pattern

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Visitor;
namespace DesignPatterns\Behavioral\Visitor;
/**
* Visitor Pattern
@@ -18,14 +18,14 @@ interface RoleVisitorInterface
/**
* Visit a User object
*
* @param \DesignPatterns\Visitor\User $role
* @param \DesignPatterns\Behavioral\Visitor\User $role
*/
public function visitUser(User $role);
/**
* Visit a Group object
*
* @param \DesignPatterns\Visitor\Group $role
* @param \DesignPatterns\Behavioral\Visitor\Group $role
*/
public function visitGroup(Group $role);
}

View File

@@ -1,6 +1,6 @@
<?php
namespace DesignPatterns\Visitor;
namespace DesignPatterns\Behavioral\Visitor;
/**
* Visitor Pattern

View File

@@ -2,7 +2,7 @@
namespace DesignPatterns\Tests\Visitor;
use DesignPatterns\Visitor;
use DesignPatterns\Behavioral\Visitor;
/**
* VisitorTest tests the visitor pattern
@@ -40,7 +40,7 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
*/
public function testUnknownObject()
{
$mock = $this->getMockForAbstractClass('DesignPatterns\Visitor\Role');
$mock = $this->getMockForAbstractClass('DesignPatterns\Behavioral\Visitor\Role');
$mock->accept($this->visitor);
}

View File

@@ -3,7 +3,10 @@
<testsuites>
<testsuite name="Design Patterns">
<directory>./Tests</directory>
<directory>./Behavioral/*/*Test.php</directory>
<directory>./Creational/*/*/Test.php</directory>
<directory>./More/*/*/Test.php</directory>
<directory>./Structural/*/*/Test.php</directory>
</testsuite>
</testsuites>