From 6643e8e7dd44da18724aadd52160fda3a3b82c59 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 16 Jan 2016 10:45:28 +0000 Subject: [PATCH 1/4] Fixed lumen support --- src/AwsServiceProvider.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/AwsServiceProvider.php b/src/AwsServiceProvider.php index 1eb8e73..27fbe21 100644 --- a/src/AwsServiceProvider.php +++ b/src/AwsServiceProvider.php @@ -1,7 +1,9 @@ app instanceof LaravelApplication && $app->runningInConsole()) { $this->publishes([$source => config_path('aws.php')]); + } elseif ($this->app instanceof LumenApplication) { + $app->configure('aws'); } $this->mergeConfigFrom($source, 'aws'); @@ -41,7 +45,8 @@ public function boot() public function register() { $this->app->singleton('aws', function ($app) { - $config = $app['config']->get('aws'); + $config = $app->make('config')->get('aws'); + return new Sdk($config); }); From 11fd1a77cf4108bf53ed044ac6c1ec92867d1307 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 16 Jan 2016 20:31:01 +0000 Subject: [PATCH 2/4] Fixed typos --- src/AwsServiceProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AwsServiceProvider.php b/src/AwsServiceProvider.php index 27fbe21..3167d17 100644 --- a/src/AwsServiceProvider.php +++ b/src/AwsServiceProvider.php @@ -28,10 +28,10 @@ public function boot() { $source = realpath(__DIR__ . '/../config/aws.php'); - if ($this->app instanceof LaravelApplication && $app->runningInConsole()) { + if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) { $this->publishes([$source => config_path('aws.php')]); } elseif ($this->app instanceof LumenApplication) { - $app->configure('aws'); + $this->app->configure('aws'); } $this->mergeConfigFrom($source, 'aws'); From 684c1e528d61d7b7935acdde5ad3585032464d6a Mon Sep 17 00:00:00 2001 From: Jonathan Eskew Date: Sat, 16 Jan 2016 14:17:34 -0800 Subject: [PATCH 3/4] Add test for using service provider in Lumen --- composer.json | 5 +++-- tests/AwsServiceProviderTest.php | 22 ++++++---------------- tests/LaravelAwsServiceProviderTest.php | 17 +++++++++++++++++ tests/LumenAwsServiceProviderTest.php | 17 +++++++++++++++++ 4 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 tests/LaravelAwsServiceProviderTest.php create mode 100644 tests/LumenAwsServiceProviderTest.php diff --git a/composer.json b/composer.json index 5f4e83d..97ced0c 100644 --- a/composer.json +++ b/composer.json @@ -17,8 +17,9 @@ "illuminate/support": "~5.1" }, "require-dev": { - "laravel/framework": "~5.1", - "phpunit/phpunit": "~4.0" + "laravel/framework": "~5.2", + "phpunit/phpunit": "~4.0", + "laravel/lumen-framework": "~5.2" }, "autoload": { "psr-4": { "Aws\\Laravel\\": "src/" } diff --git a/tests/AwsServiceProviderTest.php b/tests/AwsServiceProviderTest.php index 2216f4d..3686345 100644 --- a/tests/AwsServiceProviderTest.php +++ b/tests/AwsServiceProviderTest.php @@ -2,10 +2,9 @@ use Aws\Laravel\AwsFacade as AWS; use Aws\Laravel\AwsServiceProvider; -use Illuminate\Config\Repository; -use Illuminate\Foundation\Application; +use Illuminate\Container\Container; -class AwsServiceProviderTest extends \PHPUnit_Framework_TestCase +abstract class AwsServiceProviderTest extends \PHPUnit_Framework_TestCase { public function testFacadeCanBeResolvedToServiceInstance() @@ -61,24 +60,16 @@ public function testVersionInformationIsProvidedToSdkUserAgent() } /** - * @return Application + * @return Container */ - private function setupApplication() - { - // Create the application such that the config is loaded. - $app = new Application(); - $app->setBasePath(sys_get_temp_dir()); - $app->instance('config', new Repository()); - - return $app; - } + abstract protected function setupApplication(); /** - * @param Application $app + * @param Container $app * * @return AwsServiceProvider */ - private function setupServiceProvider(Application $app) + private function setupServiceProvider(Container $app) { // Create and register the provider. $provider = new AwsServiceProvider($app); @@ -87,5 +78,4 @@ private function setupServiceProvider(Application $app) return $provider; } - } diff --git a/tests/LaravelAwsServiceProviderTest.php b/tests/LaravelAwsServiceProviderTest.php new file mode 100644 index 0000000..0fbd7f9 --- /dev/null +++ b/tests/LaravelAwsServiceProviderTest.php @@ -0,0 +1,17 @@ +setBasePath(sys_get_temp_dir()); + $app->instance('config', new Repository()); + + return $app; + } +} diff --git a/tests/LumenAwsServiceProviderTest.php b/tests/LumenAwsServiceProviderTest.php new file mode 100644 index 0000000..cb10ed4 --- /dev/null +++ b/tests/LumenAwsServiceProviderTest.php @@ -0,0 +1,17 @@ +instance('config', new Repository()); + + return $app; + } +} From f6b2bbf72f9890b23f17a9669859cdca8b50e6d8 Mon Sep 17 00:00:00 2001 From: Jonathan Eskew Date: Sun, 17 Jan 2016 22:31:42 -0800 Subject: [PATCH 4/4] Test both Laravel and Lumen without requiring either --- .travis.yml | 4 +- CHANGELOG.md | 74 +++++++++++++++++++++++++ Makefile | 41 ++++++++++++++ composer.json | 8 ++- tests/LaravelAwsServiceProviderTest.php | 9 +++ tests/LumenAwsServiceProviderTest.php | 9 +++ 6 files changed, 140 insertions(+), 5 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 Makefile diff --git a/.travis.yml b/.travis.yml index 9bcf7bc..20a49ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ matrix: allow_failures: - php: hhvm -install: travis_retry composer install --no-interaction --prefer-source +install: travis_retry composer install --no-interaction -script: vendor/bin/phpunit +script: make test diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0a4c633 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,74 @@ +# CHANGELOG + +## next release + +* Added test coverage for version 5.2 of both Lumen and Laravel. + +## 3.0.3 - 2015-09-18 + +* Added support for configuring credentials with environmental variables, a ini + file at `~/.aws/credentials`, or with Ec2 instance profiles instead of + requiring their inclusion in the `aws.php` config file. + +## 3.0.3 - 2015-08-10 + +* Removed usage of a dev dependency + +## 3.0.1 - 2015-08-05 + +* Provide version information to SDK user agent + +## 3.0.0 - 2015-06-10 + +* Service provider is now compatible with Laravel 5.1 and Version 3 of the AWS + SDK for PHP. + +## 2.0.1 - 2015-06-10 + +* Service provider is now compatible with Lumen + +## 2.0.0 - 2015-03-12 + +* Updated the service provider to work with Laravel 5. + +## 1.1.2 - 2015-02-13 + +* Added alias to support DI from container. + +## 1.1.1 - 2014-05-12 + +* Updated default module config file to make it more compatible with environment + credentials + +## 1.1.0 - 2013-09-03 + +* Added package-level config that can be published with Artisan +* Updated config loading logic to support package-level config +* Updated config loading logic to support AWS SDK for PHP config files via the + `config_file` key +* Updated code, tests, and the README to support the config refactoring +* This module is now following [semver](http://semver.org/) + +## 1.0.4 - 2013-06-20 + +* Added support for the AWS facade +* Updated `composer.json` to require only specific components of Laravel +* Updated `composer.json` to require version 2.2+ of the AWS SDK for PHP + +## 1.0.3 - 2013-04-25 + +* Update Composer dependencies to work with newer version of the AWS SDK for PHP + and Laravel + +## 1.0.2 - 2013-03-11 + +* Fixed an issue with config retrieval + +## 1.0.1 - 2013-03-07 + +* Improved usage instructions in the README +* Fixed logic for retrieving Laravel version + +## 1.0.0 - 2013-02-13 + +* Initial release. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..327cf0f --- /dev/null +++ b/Makefile @@ -0,0 +1,41 @@ +test: test-laravel test-lumen + +test-laravel: + composer require laravel/framework + vendor/bin/phpunit + make uninstall-laravel + +test-lumen: + composer require laravel/lumen-framework + vendor/bin/phpunit + make uninstall-lumen + +uninstall-illuminate: + rm -rf vendor/laravel + rm -rf vendor/illuminate + +uninstall-laravel: uninstall-illuminate + composer remove laravel/framework + +uninstall-lumen: uninstall-illuminate + composer remove laravel/lumen-framework + +# Ensures that the TAG variable was passed to the make command +check-tag: + $(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=4.2.1")) + +# Creates a release but does not push it. This task updates the changelog +# with the TAG environment variable, replaces the VERSION constant, ensures +# that the source is still valid after updating, commits the changelog and +# updated VERSION constant, creates an annotated git tag using chag, and +# prints out a diff of the last commit. +tag: check-tag test + @echo Tagging $(TAG) + chag update $(TAG) + sed -i '' -e "s/VERSION = '.*'/VERSION = '$(TAG)'/" src/AwsServiceProvider.php + php -l src/AwsBundle.php + git commit -a -m '$(TAG) release' + chag tag + @echo "Release has been created. Push using 'make release'" + @echo "Changes made in the release commit" + git diff HEAD~1 HEAD diff --git a/composer.json b/composer.json index 97ced0c..35d20ee 100644 --- a/composer.json +++ b/composer.json @@ -17,9 +17,11 @@ "illuminate/support": "~5.1" }, "require-dev": { - "laravel/framework": "~5.2", - "phpunit/phpunit": "~4.0", - "laravel/lumen-framework": "~5.2" + "phpunit/phpunit": "~4.0|~5.0" + }, + "suggest": { + "laravel/framework": "To test the Laravel bindings", + "laravel/lumen-framework": "To test the Lumen bindings" }, "autoload": { "psr-4": { "Aws\\Laravel\\": "src/" } diff --git a/tests/LaravelAwsServiceProviderTest.php b/tests/LaravelAwsServiceProviderTest.php index 0fbd7f9..85f24d6 100644 --- a/tests/LaravelAwsServiceProviderTest.php +++ b/tests/LaravelAwsServiceProviderTest.php @@ -5,6 +5,15 @@ class LaravelAwsServiceProviderTest extends AwsServiceProviderTest { + public function setUp() + { + if (!class_exists(Application::class)) { + $this->markTestSkipped(); + } + + parent::setUp(); + } + protected function setupApplication() { // Create the application such that the config is loaded. diff --git a/tests/LumenAwsServiceProviderTest.php b/tests/LumenAwsServiceProviderTest.php index cb10ed4..ff301c4 100644 --- a/tests/LumenAwsServiceProviderTest.php +++ b/tests/LumenAwsServiceProviderTest.php @@ -6,6 +6,15 @@ class LumenAwsServiceProviderTest extends AwsServiceProviderTest { + public function setUp() + { + if (!class_exists(Application::class)) { + $this->markTestSkipped(); + } + + parent::setUp(); + } + protected function setupApplication() { // Create the application such that the config is loaded.