From 22b5cd4273c3f6e2fcf3abef20004202f0211380 Mon Sep 17 00:00:00 2001 From: Eric Hough Date: Fri, 22 Mar 2013 13:55:42 -0400 Subject: [PATCH 01/15] Updating README.md, .travis.yml, and composer.json --- .travis.yml | 4 ++-- README.md | 49 ++++++++++++++++++++++++++----------------------- composer.json | 4 ++-- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5b3b1e2..cab7701 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: php php: - 5.3 - 5.4 + - 5.5 before_script: - - wget http://getcomposer.org/composer.phar - - php composer.phar install --dev + - composer install --dev --prefer-source script: "phpunit -c src/test/resources/phpunit.xml" diff --git a/README.md b/README.md index 8c014c2..4a2911a 100644 --- a/README.md +++ b/README.md @@ -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); \ No newline at end of file +/* + * Build the execution context. + */ +$context = new ehough_chaingang_impl_StandardContext(); +$context->put('foo', 'bar'); + +/* + * Execute the chain. + */ +$successfullyHandled = $chain->execute($context); +``` \ No newline at end of file diff --git a/composer.json b/composer.json index 6938ce2..bcda705 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "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", @@ -17,7 +17,7 @@ "require": { - "php": ">=5.1.0" + "php": ">=5.2.0" }, "require-dev": { From 63832674a0f76982d040a4ce7cd551f7b77d3784 Mon Sep 17 00:00:00 2001 From: Eric Hough Date: Tue, 26 Mar 2013 19:19:33 -0400 Subject: [PATCH 02/15] Updating .travis.yml config --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index cab7701..4e04e1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: php php: + - 5.2 - 5.3 - 5.4 - 5.5 -before_script: - - composer install --dev --prefer-source +before_script: "src/test/bash/travis-setup.sh" script: "phpunit -c src/test/resources/phpunit.xml" From 3de214b1ecc137b3a3792cf6156ea0aaf6f1c46d Mon Sep 17 00:00:00 2001 From: Eric Hough Date: Tue, 26 Mar 2013 19:22:30 -0400 Subject: [PATCH 03/15] Forgot to include travis-setup.sh --- src/test/bash/travis-setup.sh | 7 +++++++ src/test/php/throwback.php | 9 +++++++++ 2 files changed, 16 insertions(+) create mode 100755 src/test/bash/travis-setup.sh create mode 100644 src/test/php/throwback.php diff --git a/src/test/bash/travis-setup.sh b/src/test/bash/travis-setup.sh new file mode 100755 index 0000000..b87202e --- /dev/null +++ b/src/test/bash/travis-setup.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +cd $TRAVIS_BUILD_DIR + +wget https://raw.github.com/ehough/throwback/develop/throwback.php + +php throwback.php \ No newline at end of file diff --git a/src/test/php/throwback.php b/src/test/php/throwback.php new file mode 100644 index 0000000..fc87d1a --- /dev/null +++ b/src/test/php/throwback.php @@ -0,0 +1,9 @@ + 'ehough_chaingang', + 'autoload' => dirname(__FILE__) . '/../../main/php', + 'dependencies' => array( + ) +); From a0ccfd37a5fb4e58a16387e4d2548f5213fb09e5 Mon Sep 17 00:00:00 2001 From: Eric Hough Date: Tue, 26 Mar 2013 19:26:14 -0400 Subject: [PATCH 04/15] Typo in phpunit.xml --- src/test/php/bootstrap.php | 16 ---------------- src/test/resources/phpunit.xml | 2 +- 2 files changed, 1 insertion(+), 17 deletions(-) delete mode 100644 src/test/php/bootstrap.php diff --git a/src/test/php/bootstrap.php b/src/test/php/bootstrap.php deleted file mode 100644 index de88a30..0000000 --- a/src/test/php/bootstrap.php +++ /dev/null @@ -1,16 +0,0 @@ -registerDirectory('ehough_chaingang', __DIR__ . '/../../main/php/'); -$loader->register(); \ No newline at end of file diff --git a/src/test/resources/phpunit.xml b/src/test/resources/phpunit.xml index bf3b610..3c0b6c3 100644 --- a/src/test/resources/phpunit.xml +++ b/src/test/resources/phpunit.xml @@ -6,7 +6,7 @@ stopOnSkipped="true" strict="true" processIsolation="false" - bootstrap="../php/bootstrap.php"> + bootstrap="../../../vendor/autoload.php"> ../php/ From de9780a3160d52d2b6ebb2a56435cd91cf6613e4 Mon Sep 17 00:00:00 2001 From: Eric Hough Date: Tue, 26 Mar 2013 19:28:12 -0400 Subject: [PATCH 05/15] Fixing tests for PHP 5.2 --- src/test/php/ehough/chaingang/impl/StandardChainTest.php | 2 +- src/test/php/ehough/chaingang/impl/StandardContextTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/php/ehough/chaingang/impl/StandardChainTest.php b/src/test/php/ehough/chaingang/impl/StandardChainTest.php index f27848d..30081d3 100644 --- a/src/test/php/ehough/chaingang/impl/StandardChainTest.php +++ b/src/test/php/ehough/chaingang/impl/StandardChainTest.php @@ -9,7 +9,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use \Mockery as m; +use Mockery as m; final class ehough_chaingang_impl_StandardChainTest extends PHPUnit_Framework_TestCase { diff --git a/src/test/php/ehough/chaingang/impl/StandardContextTest.php b/src/test/php/ehough/chaingang/impl/StandardContextTest.php index 5029c39..ddf7e00 100644 --- a/src/test/php/ehough/chaingang/impl/StandardContextTest.php +++ b/src/test/php/ehough/chaingang/impl/StandardContextTest.php @@ -9,7 +9,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use \Mockery as m; +use Mockery as m; final class ehough_chaingang_impl_StandardContextTest extends PHPUnit_Framework_TestCase { From 94cdcbfb150ca9fccb986e6978c7d805f5601c9b Mon Sep 17 00:00:00 2001 From: Eric Hough Date: Tue, 26 Mar 2013 19:31:30 -0400 Subject: [PATCH 06/15] More bug fixes for PHP 5.2 --- src/test/php/ehough/chaingang/impl/StandardChainTest.php | 8 +++----- .../php/ehough/chaingang/impl/StandardContextTest.php | 4 +--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/test/php/ehough/chaingang/impl/StandardChainTest.php b/src/test/php/ehough/chaingang/impl/StandardChainTest.php index 30081d3..765adef 100644 --- a/src/test/php/ehough/chaingang/impl/StandardChainTest.php +++ b/src/test/php/ehough/chaingang/impl/StandardChainTest.php @@ -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; @@ -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 = Mockery::mock('ehough_chaingang_api_Context'); + $command = Mockery::mock('ehough_chaingang_api_Command'); $command->shouldReceive('execute')->with($context)->once()->andReturn(true); @@ -38,7 +36,7 @@ public function testCommandCanHandle() public function tearDown() { - m::close(); + Mockery::close(); } } \ No newline at end of file diff --git a/src/test/php/ehough/chaingang/impl/StandardContextTest.php b/src/test/php/ehough/chaingang/impl/StandardContextTest.php index ddf7e00..b8b39fa 100644 --- a/src/test/php/ehough/chaingang/impl/StandardContextTest.php +++ b/src/test/php/ehough/chaingang/impl/StandardContextTest.php @@ -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 { /** @@ -77,7 +75,7 @@ public function testContextNotSet() public function tearDown() { - m::close(); + Mockery::close(); } } \ No newline at end of file From 2653fb7c14c18f850e967157280dc41882c7cc59 Mon Sep 17 00:00:00 2001 From: Eric Hough Date: Tue, 26 Mar 2013 19:57:11 -0400 Subject: [PATCH 07/15] Including Mockery in throwback build --- src/test/php/throwback.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/php/throwback.php b/src/test/php/throwback.php index fc87d1a..0197227 100644 --- a/src/test/php/throwback.php +++ b/src/test/php/throwback.php @@ -5,5 +5,7 @@ 'name' => 'ehough_chaingang', 'autoload' => dirname(__FILE__) . '/../../main/php', 'dependencies' => array( + + 'mockery/mockery' => 'https://github.com/padraic/mockery.git' ) ); From 51240056c9535cbe909810a618131d7e54e0edd5 Mon Sep 17 00:00:00 2001 From: Eric Hough Date: Tue, 26 Mar 2013 20:00:46 -0400 Subject: [PATCH 08/15] Fixing bug in throwback.php --- src/test/php/throwback.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/php/throwback.php b/src/test/php/throwback.php index 0197227..e7e4781 100644 --- a/src/test/php/throwback.php +++ b/src/test/php/throwback.php @@ -6,6 +6,6 @@ 'autoload' => dirname(__FILE__) . '/../../main/php', 'dependencies' => array( - 'mockery/mockery' => 'https://github.com/padraic/mockery.git' + 'mockery/mockery', 'https://github.com/padraic/mockery.git', 'src/main/php' ) ); From 1addfd2f889c6d5edde8a17766f1362fb24ee37e Mon Sep 17 00:00:00 2001 From: Eric Hough Date: Tue, 26 Mar 2013 20:10:27 -0400 Subject: [PATCH 09/15] Another bugfix for Mockery under PHP 5.2 --- src/test/php/throwback.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/php/throwback.php b/src/test/php/throwback.php index e7e4781..ab42a31 100644 --- a/src/test/php/throwback.php +++ b/src/test/php/throwback.php @@ -6,6 +6,6 @@ 'autoload' => dirname(__FILE__) . '/../../main/php', 'dependencies' => array( - 'mockery/mockery', 'https://github.com/padraic/mockery.git', 'src/main/php' + 'mockery/mockery', 'https://github.com/padraic/mockery.git', 'library' ) ); From 80ece0e9ae3d2a66aa2a5ed60439ded9e7ecb55c Mon Sep 17 00:00:00 2001 From: Eric Hough Date: Wed, 27 Mar 2013 21:36:12 -0400 Subject: [PATCH 10/15] Switching from padraic/mockery to ehough/mockery --- .gitignore | 1 + composer.json | 2 +- src/test/php/ehough/chaingang/impl/StandardChainTest.php | 6 +++--- src/test/php/ehough/chaingang/impl/StandardContextTest.php | 2 +- src/test/php/throwback.php | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 029b0ab..75ee139 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ vendor target .idea composer.lock +.DS_Store diff --git a/composer.json b/composer.json index bcda705..7db6c3d 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "require-dev": { "ehough/pulsar": "1.*", - "mockery/mockery": ">=0.7.2" + "ehough/mockery": "~1.0.0" }, "autoload": { diff --git a/src/test/php/ehough/chaingang/impl/StandardChainTest.php b/src/test/php/ehough/chaingang/impl/StandardChainTest.php index 765adef..7f74903 100644 --- a/src/test/php/ehough/chaingang/impl/StandardChainTest.php +++ b/src/test/php/ehough/chaingang/impl/StandardChainTest.php @@ -22,8 +22,8 @@ public function setUp() public function testCommandCanHandle() { - $context = Mockery::mock('ehough_chaingang_api_Context'); - $command = Mockery::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); @@ -36,7 +36,7 @@ public function testCommandCanHandle() public function tearDown() { - Mockery::close(); + ehough_mockery_Mockery::close(); } } \ No newline at end of file diff --git a/src/test/php/ehough/chaingang/impl/StandardContextTest.php b/src/test/php/ehough/chaingang/impl/StandardContextTest.php index b8b39fa..e20093a 100644 --- a/src/test/php/ehough/chaingang/impl/StandardContextTest.php +++ b/src/test/php/ehough/chaingang/impl/StandardContextTest.php @@ -75,7 +75,7 @@ public function testContextNotSet() public function tearDown() { - Mockery::close(); + ehough_mockery_Mockery::close(); } } \ No newline at end of file diff --git a/src/test/php/throwback.php b/src/test/php/throwback.php index ab42a31..053797c 100644 --- a/src/test/php/throwback.php +++ b/src/test/php/throwback.php @@ -6,6 +6,6 @@ 'autoload' => dirname(__FILE__) . '/../../main/php', 'dependencies' => array( - 'mockery/mockery', 'https://github.com/padraic/mockery.git', 'library' + array('ehough/mockery', 'https://github.com/ehough/mockery.git', 'src/main/php') ) ); From 4254bc27870ba0bc27b4a809170145f4c50b7367 Mon Sep 17 00:00:00 2001 From: Eric Hough Date: Thu, 28 Mar 2013 00:10:49 -0400 Subject: [PATCH 11/15] Removing pulsar from composer --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 7db6c3d..b140720 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,6 @@ "require-dev": { - "ehough/pulsar": "1.*", "ehough/mockery": "~1.0.0" }, From 556f401f644e9e1dc4b751d2b37b8187abcd0be8 Mon Sep 17 00:00:00 2001 From: Eric Hough Date: Thu, 28 Mar 2013 13:13:47 -0400 Subject: [PATCH 12/15] Triggering travis --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b140720..03103ab 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ }, "require-dev": { - + "ehough/mockery": "~1.0.0" }, @@ -32,4 +32,5 @@ "ehough_chaingang": "src/main/php" } } -} \ No newline at end of file +} + From 3807edea1939159dfa81b4503a28b7cde283c7c6 Mon Sep 17 00:00:00 2001 From: Eric Hough Date: Thu, 28 Mar 2013 13:34:35 -0400 Subject: [PATCH 13/15] Testing out new throwback build method --- .travis.yml | 5 ++++- composer.json | 19 ++++--------------- src/test/bash/travis-setup.sh | 7 ------- 3 files changed, 8 insertions(+), 23 deletions(-) delete mode 100755 src/test/bash/travis-setup.sh diff --git a/.travis.yml b/.travis.yml index 4e04e1e..a40b2bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,5 +4,8 @@ php: - 5.3 - 5.4 - 5.5 -before_script: "src/test/bash/travis-setup.sh" +before_script: + - 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" diff --git a/composer.json b/composer.json index 03103ab..f52a4b1 100644 --- a/composer.json +++ b/composer.json @@ -1,12 +1,9 @@ { "name": "ehough/chaingang", - - "description": "Chain-of-Responsibility/Chain-of-Command 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", @@ -14,23 +11,15 @@ "homepage": "http://ehough.com" } ], - "require": { - "php": ">=5.2.0" }, - "require-dev": { - "ehough/mockery": "~1.0.0" }, - "autoload": { - "psr-0": { - "ehough_chaingang": "src/main/php" } } -} - +} \ No newline at end of file diff --git a/src/test/bash/travis-setup.sh b/src/test/bash/travis-setup.sh deleted file mode 100755 index b87202e..0000000 --- a/src/test/bash/travis-setup.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -cd $TRAVIS_BUILD_DIR - -wget https://raw.github.com/ehough/throwback/develop/throwback.php - -php throwback.php \ No newline at end of file From ef7882bdc08006fe58f399363a60cc1a70b24453 Mon Sep 17 00:00:00 2001 From: Eric Hough Date: Thu, 28 Mar 2013 13:50:27 -0400 Subject: [PATCH 14/15] Triggering travis --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a2911a..610897d 100644 --- a/README.md +++ b/README.md @@ -28,4 +28,4 @@ $context->put('foo', 'bar'); * Execute the chain. */ $successfullyHandled = $chain->execute($context); -``` \ No newline at end of file +``` From ceb2365d7f47263e9f9a743face1110ffdf26fa3 Mon Sep 17 00:00:00 2001 From: Eric Hough Date: Thu, 28 Mar 2013 14:22:41 -0400 Subject: [PATCH 15/15] Triggering Travis --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f52a4b1..158338c 100644 --- a/composer.json +++ b/composer.json @@ -22,4 +22,5 @@ "ehough_chaingang": "src/main/php" } } -} \ No newline at end of file +} +