it was created the Structural namespace and append its patterns

This commit is contained in:
Antonio Spinelli
2014-04-15 23:14:39 -03:00
parent 7bf6593e3f
commit 113f63a54f
37 changed files with 77 additions and 69 deletions

View File

@@ -1,11 +1,11 @@
<?php <?php
namespace DesignPatterns\Tests\Adapter; namespace DesignPatterns\Structural\Adapter;
use DesignPatterns\Adapter\EBookAdapter; use DesignPatterns\Structural\Adapter\EBookAdapter;
use DesignPatterns\Adapter\Kindle; use DesignPatterns\Structural\Adapter\Kindle;
use DesignPatterns\Adapter\PaperBookInterface; use DesignPatterns\Structural\Adapter\PaperBookInterface;
use DesignPatterns\Adapter\Book; use DesignPatterns\Structural\Adapter\Book;
/** /**
* AdapterTest shows the use of an adapted e-book that behave like a book * AdapterTest shows the use of an adapted e-book that behave like a book

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Adapter; namespace DesignPatterns\Structural\Adapter;
/** /**
* Book is a concrete and standard paper book * Book is a concrete and standard paper book

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Adapter; namespace DesignPatterns\Structural\Adapter;
/** /**
* EBookAdapter is an adapter to fit an e-book like a paper book * EBookAdapter is an adapter to fit an e-book like a paper book

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Adapter; namespace DesignPatterns\Structural\Adapter;
/** /**
* EBookInterface is a contract for an electronic book * EBookInterface is a contract for an electronic book

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Adapter; namespace DesignPatterns\Structural\Adapter;
/** /**
* Kindle is a concrete electronic book * Kindle is a concrete electronic book

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Adapter; namespace DesignPatterns\Structural\Adapter;
/** /**
* PaperBookInterface is a contract for a book * PaperBookInterface is a contract for a book

View File

@@ -2,12 +2,12 @@
namespace DesignPatterns\Test\Composite; namespace DesignPatterns\Test\Composite;
use DesignPatterns\Composite; use DesignPatterns\Structural\Composite;
/** /**
* FormTest tests the composite pattern on Form * FormTest tests the composite pattern on Form
*/ */
class FormTest extends \PHPUnit_Framework_TestCase class CompositeTest extends \PHPUnit_Framework_TestCase
{ {
public function testRender() public function testRender()
@@ -29,6 +29,6 @@ class FormTest extends \PHPUnit_Framework_TestCase
*/ */
public function testFormImplementsFormEelement() public function testFormImplementsFormEelement()
{ {
$this->assertTrue(is_subclass_of('DesignPatterns\Composite\Form', 'DesignPatterns\Composite\FormElement')); $this->assertTrue(is_subclass_of('DesignPatterns\Structural\Composite\Form', 'DesignPatterns\Structural\Composite\FormElement'));
} }
} }

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Composite; namespace DesignPatterns\Structural\Composite;
/** /**
* The composite node MUST extend the component contract. This is mandatory for building * The composite node MUST extend the component contract. This is mandatory for building

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Composite; namespace DesignPatterns\Structural\Composite;
/** /**
* Class FormElement * Class FormElement

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Composite; namespace DesignPatterns\Structural\Composite;
/** /**
* Class InputElement * Class InputElement

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Composite; namespace DesignPatterns\Structural\Composite;
/** /**
* Class TextElement * Class TextElement

View File

@@ -1,14 +1,14 @@
<?php <?php
namespace DesignPatterns\Test\DataMapper; namespace DesignPatterns\Structural\DataMapper;
use DesignPatterns\DataMapper\UserMapper; use DesignPatterns\Structural\DataMapper\UserMapper;
use DesignPatterns\DataMapper\User; use DesignPatterns\Structural\DataMapper\User;
/** /**
* UserMapperTest tests the datamapper pattern * UserMapperTest tests the datamapper pattern
*/ */
class UserMapperTest extends \PHPUnit_Framework_TestCase class DataMapperTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var UserMapper * @var UserMapper
@@ -22,7 +22,7 @@ class UserMapperTest extends \PHPUnit_Framework_TestCase
protected function setUp() protected function setUp()
{ {
$this->dbal = $this->getMockBuilder('DesignPatterns\DataMapper\DBAL') $this->dbal = $this->getMockBuilder('DesignPatterns\Structural\DataMapper\DBAL')
->disableAutoload() ->disableAutoload()
->setMethods(array('insert', 'update', 'find', 'findAll')) ->setMethods(array('insert', 'update', 'find', 'findAll'))
->getMock(); ->getMock();
@@ -90,7 +90,7 @@ class UserMapperTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* @expectedException InvalidArgumentException * @expectedException \InvalidArgumentException
* @expectedExceptionMessage User #404 not found * @expectedExceptionMessage User #404 not found
*/ */
public function testNotFound() public function testNotFound()

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\DataMapper; namespace DesignPatterns\Structural\DataMapper;
/** /**
* DataMapper pattern * DataMapper pattern

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\DataMapper; namespace DesignPatterns\Structural\DataMapper;
/** /**
* class UserMapper * class UserMapper

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Decorator; namespace DesignPatterns\Structural\Decorator;
/** /**
* the Decorator MUST implement the RendererInterface contract, this is the key-feature * the Decorator MUST implement the RendererInterface contract, this is the key-feature

View File

@@ -1,8 +1,8 @@
<?php <?php
namespace DesignPatterns\Tests\Decorator; namespace DesignPatterns\Structural\Decorator;
use DesignPatterns\Decorator; use DesignPatterns\Structural\Decorator;
/** /**
* DecoratorTest tests the decorator pattern * DecoratorTest tests the decorator pattern
@@ -38,7 +38,7 @@ class DecoratorTest extends \PHPUnit_Framework_TestCase
*/ */
public function testDecoratorMustImplementsRenderer() public function testDecoratorMustImplementsRenderer()
{ {
$this->assertTrue(is_subclass_of('DesignPatterns\Decorator\Decorator', 'DesignPatterns\Decorator\RendererInterface')); $this->assertTrue(is_subclass_of('DesignPatterns\Structural\Decorator\Decorator', 'DesignPatterns\Structural\Decorator\RendererInterface'));
} }
/** /**
@@ -48,7 +48,7 @@ class DecoratorTest extends \PHPUnit_Framework_TestCase
*/ */
public function testDecoratorTypeHinted() public function testDecoratorTypeHinted()
{ {
$this->getMockForAbstractClass('DesignPatterns\Decorator\Decorator', array(new \stdClass())); $this->getMockForAbstractClass('DesignPatterns\Structural\Decorator\Decorator', array(new \stdClass()));
} }
/** /**
@@ -56,8 +56,8 @@ class DecoratorTest extends \PHPUnit_Framework_TestCase
*/ */
public function testDecoratorOnlyAcceptRenderer() public function testDecoratorOnlyAcceptRenderer()
{ {
$mock = $this->getMock('DesignPatterns\Decorator\RendererInterface'); $mock = $this->getMock('DesignPatterns\Structural\Decorator\RendererInterface');
$dec = $this->getMockForAbstractClass('DesignPatterns\Decorator\Decorator', array($mock)); $dec = $this->getMockForAbstractClass('DesignPatterns\Structural\Decorator\Decorator', array($mock));
$this->assertNotNull($dec); $this->assertNotNull($dec);
} }
} }

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Decorator; namespace DesignPatterns\Structural\Decorator;
/** /**
* Class RenderInJson * Class RenderInJson

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Decorator; namespace DesignPatterns\Structural\Decorator;
/** /**
* Class RenderInXml * Class RenderInXml

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Decorator; namespace DesignPatterns\Structural\Decorator;
/** /**
* Class RendererInterface * Class RendererInterface

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Decorator; namespace DesignPatterns\Structural\Decorator;
/** /**
* Class Webservice * Class Webservice

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\DependencyInjection; namespace DesignPatterns\Structural\DependencyInjection;
/** /**
* class AbstractConfig * class AbstractConfig

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\DependencyInjection; namespace DesignPatterns\Structural\DependencyInjection;
/** /**
* class ArrayConfig * class ArrayConfig

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\DependencyInjection; namespace DesignPatterns\Structural\DependencyInjection;
/** /**
* Class Connection * Class Connection

View File

@@ -1,11 +1,11 @@
<?php <?php
namespace DesignPatterns\Tests\DependencyInjection; namespace DesignPatterns\Structural\DependencyInjection;
use DesignPatterns\DependencyInjection\Parameters; use DesignPatterns\Structural\DependencyInjection\Parameters;
use DesignPatterns\DependencyInjection\AbstractConfig; use DesignPatterns\Structural\DependencyInjection\AbstractConfig;
use DesignPatterns\DependencyInjection\ArrayConfig; use DesignPatterns\Structural\DependencyInjection\ArrayConfig;
use DesignPatterns\DependencyInjection\Connection; use DesignPatterns\Structural\DependencyInjection\Connection;
class DependencyInjectionTest extends \PHPUnit_Framework_TestCase class DependencyInjectionTest extends \PHPUnit_Framework_TestCase
{ {

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\DependencyInjection; namespace DesignPatterns\Structural\DependencyInjection;
/** /**
* Parameters interface * Parameters interface

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Facade; namespace DesignPatterns\Structural\Facade;
/** /**
* Class BiosInterface * Class BiosInterface

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Facade; namespace DesignPatterns\Structural\Facade;
/** /**
* *

View File

@@ -1,8 +1,8 @@
<?php <?php
namespace DesignPatterns\Tests\Facade; namespace DesignPatterns\Structural\Facade;
use DesignPatterns\Facade\Facade as Computer; use DesignPatterns\Structural\Facade\Facade as Computer;
/** /**
* FacadeTest shows example of facades * FacadeTest shows example of facades
@@ -12,11 +12,11 @@ class FacadeTest extends \PHPUnit_Framework_TestCase
public function getComputer() public function getComputer()
{ {
$bios = $this->getMockBuilder('DesignPatterns\Facade\BiosInterface') $bios = $this->getMockBuilder('DesignPatterns\Structural\Facade\BiosInterface')
->setMethods(array('launch', 'execute', 'waitForKeyPress')) ->setMethods(array('launch', 'execute', 'waitForKeyPress'))
->disableAutoload() ->disableAutoload()
->getMock(); ->getMock();
$operatingSys = $this->getMockBuilder('DesignPatterns\Facade\OsInterface') $operatingSys = $this->getMockBuilder('DesignPatterns\Structural\Facade\OsInterface')
->setMethods(array('getName')) ->setMethods(array('getName'))
->disableAutoload() ->disableAutoload()
->getMock(); ->getMock();

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Facade; namespace DesignPatterns\Structural\Facade;
/** /**
* Class OsInterface * Class OsInterface

View File

@@ -1,8 +1,8 @@
<?php <?php
namespace DesignPatterns\Tests\FluentInterface; namespace DesignPatterns\Structural\FluentInterface;
use DesignPatterns\FluentInterface\SQL; use DesignPatterns\Structural\FluentInterface\Sql;
/** /**
* FluentInterfaceTest tests the fluent interface SQL * FluentInterfaceTest tests the fluent interface SQL
@@ -12,7 +12,7 @@ class FluentInterfaceTest extends \PHPUnit_Framework_TestCase
public function testBuildSQL() public function testBuildSQL()
{ {
$instance = new SQL(); $instance = new Sql();
$query = $instance->select(array('foo', 'bar')) $query = $instance->select(array('foo', 'bar'))
->from('foobar', 'f') ->from('foobar', 'f')
->where('f.bar = ?') ->where('f.bar = ?')

View File

@@ -1,11 +1,11 @@
<?php <?php
namespace DesignPatterns\FluentInterface; namespace DesignPatterns\Structural\FluentInterface;
/** /**
* class SQL * class SQL
*/ */
class SQL class Sql
{ {
/** /**
* @var array * @var array

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Proxy; namespace DesignPatterns\Structural\Proxy;
/** /**
* class Record * class Record

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Proxy; namespace DesignPatterns\Structural\Proxy;
/** /**
* Class RecordProxy * Class RecordProxy

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace DesignPatterns\Registry; namespace DesignPatterns\Structural\Registry;
/** /**
* class Registry * class Registry

View File

@@ -0,0 +1,17 @@
<?php
namespace DesignPatterns\Structural\Registry;
use DesignPatterns\Structural\Registry\Registry;
class RegistryTest extends \PHPUnit_Framework_TestCase
{
public function testSetAndGetLogger()
{
Registry::set(Registry::LOGGER, new \StdClass());
$logger = Registry::get(Registry::LOGGER);
$this->assertInstanceOf('StdClass', $logger);
}
}

View File

@@ -1,9 +0,0 @@
<?php
use DesignPatterns\Registry\Registry;
// while bootstrapping the application
Registry::set(Registry::LOGGER, new \StdClass());
// throughout the application
Registry::get(Registry::LOGGER)->log('foo');