Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Hough committed Mar 28, 2013
2 parents 44d1a2e + ceb2365 commit a94a458
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 67 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ vendor
target
.idea
composer.lock
.DS_Store
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
language: php
php:
- 5.2
- 5.3
- 5.4
- 5.5
before_script:
- wget http://getcomposer.org/composer.phar
- php composer.phar install --dev
- wget https://raw.github.com/ehough/throwback/develop/src/main/bash/travis-setup.sh
- chmod a+x travis-setup.sh
- ./travis-setup.sh
script: "phpunit -c src/test/resources/phpunit.xml"
49 changes: 26 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
chaingang [![Build Status](https://secure.travis-ci.org/ehough/chaingang.png)](http://travis-ci.org/ehough/chaingang)
=====
# chaingang [![Build Status](https://secure.travis-ci.org/ehough/chaingang.png)](http://travis-ci.org/ehough/chaingang)

[Chain-of-Responsibility pattern](http://en.wikipedia.org/wiki/Chain-of-responsibility_pattern) in PHP.
[Chain-of-Responsibility/Chain-of-Command pattern](http://en.wikipedia.org/wiki/Chain-of-responsibility_pattern) for PHP 5.2+

/*
* Build some commands.
*/
$command1 = new MyCommand1(); //implements ehough_chaingang_api_Command
$command2 = new MyCommand2(); //implements ehough_chaingang_api_Command
### Sample Usage

/*
* Build and assemble the chain.
*/
$chain = new ehough_chaingang_impl_StandardChain();
$chain->addCommand($command1);
$chain->addCommand($command2);
```php
/*
* Build some commands.
*/
$command1 = new MyCommand1(); //implements ehough_chaingang_api_Command
$command2 = new MyCommand2(); //implements ehough_chaingang_api_Command

/*
* Build the execution context.
*/
$context = new ehough_chaingang_impl_StandardContext();
$context->put('foo', 'bar');
/*
* Build and assemble the chain.
*/
$chain = new ehough_chaingang_impl_StandardChain();
$chain->addCommand($command1);
$chain->addCommand($command2);

/*
* Execute the chain.
*/
$successfullyHandled = $chain->execute($context);
/*
* Build the execution context.
*/
$context = new ehough_chaingang_impl_StandardContext();
$context->put('foo', 'bar');

/*
* Execute the chain.
*/
$successfullyHandled = $chain->execute($context);
```
24 changes: 7 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
{
"name": "ehough/chaingang",

"description": "Chain of Responsibility pattern in PHP.",

"description": "Chain-of-Responsibility / Chain-of-Command pattern in PHP.",
"homepage": "https://github.com/ehough/chaingang",

"license": "GPL-3.0+",

"type": "library",
"license": "MPL-2.0",
"authors": [
{
"name": "Eric Hough",
"email": "[email protected]",
"homepage": "http://ehough.com"
}
],

"require": {

"php": ">=5.1.0"
"php": ">=5.2.0"
},

"require-dev": {

"ehough/pulsar": "1.*",
"mockery/mockery": ">=0.7.2"
"ehough/mockery": "~1.0.0"
},

"autoload": {

"psr-0": {

"ehough_chaingang": "src/main/php"
}
}
}
}

16 changes: 0 additions & 16 deletions src/test/php/bootstrap.php

This file was deleted.

8 changes: 3 additions & 5 deletions src/test/php/ehough/chaingang/impl/StandardChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

use \Mockery as m;

final class ehough_chaingang_impl_StandardChainTest extends PHPUnit_Framework_TestCase
{
private $_sut;
Expand All @@ -24,8 +22,8 @@ public function setUp()

public function testCommandCanHandle()
{
$context = m::mock('ehough_chaingang_api_Context');
$command = m::mock('ehough_chaingang_api_Command');
$context = ehough_mockery_Mockery::mock('ehough_chaingang_api_Context');
$command = ehough_mockery_Mockery::mock('ehough_chaingang_api_Command');

$command->shouldReceive('execute')->with($context)->once()->andReturn(true);

Expand All @@ -38,7 +36,7 @@ public function testCommandCanHandle()

public function tearDown()
{
m::close();
ehough_mockery_Mockery::close();
}

}
4 changes: 1 addition & 3 deletions src/test/php/ehough/chaingang/impl/StandardContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

use \Mockery as m;

final class ehough_chaingang_impl_StandardContextTest extends PHPUnit_Framework_TestCase
{
/**
Expand Down Expand Up @@ -77,7 +75,7 @@ public function testContextNotSet()

public function tearDown()
{
m::close();
ehough_mockery_Mockery::close();
}

}
11 changes: 11 additions & 0 deletions src/test/php/throwback.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

__throwback::$config = array(

'name' => 'ehough_chaingang',
'autoload' => dirname(__FILE__) . '/../../main/php',
'dependencies' => array(

array('ehough/mockery', 'https://github.com/ehough/mockery.git', 'src/main/php')
)
);
2 changes: 1 addition & 1 deletion src/test/resources/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
stopOnSkipped="true"
strict="true"
processIsolation="false"
bootstrap="../php/bootstrap.php">
bootstrap="../../../vendor/autoload.php">
<testsuites>
<testsuite name="chaingang tests">
<directory>../php/</directory>
Expand Down

0 comments on commit a94a458

Please sign in to comment.