Skip to content

Commit

Permalink
Migrating to zf3 (#45)
Browse files Browse the repository at this point in the history
* Changing the new use statement for FactoryInterface to all factories

* changing composer.json to require min php version of 5.6

* changing composer

* renaming package name in composer.json

* removing zend-version from composer.json. removing Zend\Version\Version from AwsFactory. adding "zend_framework_version" param in aws_zf2.local.php

* fixing AwsFactory

* refactoring AwsFactory. Adding test for the new zend_framework_version config param

* changing zend-filter version

* bumped the module version

* changed project name in composer.json back to the original aws/aws-sdk-php-zf2

* removed php 5.5 from travis.yml since we are targeting 5.6 and above

* removed custom config parameter from AwsFactory and aws_zf2 local config file. Changed the unit test accordingly. Replaced usage of zend framework version with module version constant. Bumped module version to 4.0.0.
  • Loading branch information
firelike authored and cjyclaire committed Dec 13, 2016
1 parent e0f67ab commit 012ce4c
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 47 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 5.5
- 5.6

sudo: false
Expand Down
2 changes: 1 addition & 1 deletion Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class Module implements ConfigProviderInterface
{
const VERSION = '2.1.0';
const VERSION = '4.0.0';

/**
* {@inheritdoc}
Expand Down
69 changes: 39 additions & 30 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,43 @@
{
"name": "aws/aws-sdk-php-zf2",
"description": "Zend Framework 2 Module that allows easy integration the AWS SDK for PHP",
"type": "library",
"license": "Apache",
"keywords": ["aws", "zf2", "amazon", "zend", "s3", "dynamodb", "ec2", "cloudfront", "sqs"],
"require": {
"php": ">=5.5",
"aws/aws-sdk-php": "3.*",
"zendframework/zend-filter": "2.*",
"zendframework/zend-servicemanager": "2.7.* || 3.*",
"zendframework/zend-session": "2.*",
"zendframework/zend-version": "2.*",
"zendframework/zend-view": "2.*"
"name": "aws/aws-sdk-php-zf2",
"description": "Zend Framework 2 Module that allows easy integration the AWS SDK for PHP",
"type": "library",
"license": "Apache",
"keywords": [
"aws",
"zf2",
"amazon",
"zend",
"s3",
"dynamodb",
"ec2",
"cloudfront",
"sqs"
],
"require": {
"php": "^5.6 || ^7.0",
"aws/aws-sdk-php": "3.*",
"zendframework/zend-filter": "2.7.*",
"zendframework/zend-servicemanager": "2.7.* || 3.*",
"zendframework/zend-session": "2.7.*",
"zendframework/zend-view": "^2.8"
},
"require-dev": {
"phpunit/phpunit": "4.*",
"zendframework/zend-modulemanager": "2.7.*",
"squizlabs/php_codesniffer": "~2.3"
},
"autoload": {
"psr-4": {
"AwsModule\\": "src/"
},
"require-dev": {
"phpunit/phpunit": "4.*",
"zendframework/zend-modulemanager": "2.*",
"squizlabs/php_codesniffer": "~2.3"
},
"autoload": {
"psr-4": {
"AwsModule\\": "src/"
},
"classmap": [
"./Module.php"
]
},
"autoload-dev": {
"psr-4": {
"AwsModule\\Tests\\": "tests/"
}
"classmap": [
"./Module.php"
]
},
"autoload-dev": {
"psr-4": {
"AwsModule\\Tests\\": "tests/"
}
}
}
10 changes: 5 additions & 5 deletions src/Factory/AwsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
use Aws\Sdk as AwsSdk;
use AwsModule\Module;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\Factory\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Version\Version;

/**
* Factory used to instantiate an AWS client
Expand All @@ -16,18 +15,19 @@ class AwsFactory implements FactoryInterface
{
/**
* @param ContainerInterface $container
* @param string $requestedName
* @param array|null $options
* @param string $requestedName
* @param array|null $options
* @return AwsSdk
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
// Instantiate the AWS SDK for PHP
$config = $container->get('Config');
$config = isset($config['aws']) ? $config['aws'] : [];

$config += [
'ua_append' => [
'ZF2/' . Version::VERSION,
'ZF2/' . Module::VERSION,
'ZFMOD/' . Module::VERSION,
]
];
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/CloudFrontLinkViewHelperFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Aws\Sdk as AwsSdk;
use AwsModule\View\Helper\CloudFrontLink;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\Factory\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/DynamoDbSessionSaveHandlerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use AwsModule\Session\SaveHandler\DynamoDb as DynamoDbSaveHandler;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\Factory\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/S3LinkViewHelperFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Aws\Sdk as AwsSdk;
use AwsModule\View\Helper\S3Link;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\Factory\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/S3RenameUploadFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Aws\Sdk as AwsSdk;
use AwsModule\Filter\File\S3RenameUpload;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\Factory\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
Expand Down
9 changes: 3 additions & 6 deletions tests/Factory/AwsFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Aws\Sdk as AwsSdk;
use AwsModule\Module;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Version\Version;

/**
* AWS Module test cases
Expand All @@ -29,21 +28,19 @@ public function testProvidesVersionInformationForSdkUserAgent()
$serviceLocator = $this->getMockServiceLocator();
$awsFactory = new AwsFactory();
$aws = $awsFactory->createService($serviceLocator);
$argsProperty = (new \ReflectionClass($aws))
->getProperty('args');
$argsProperty = (new \ReflectionClass($aws))->getProperty('args');
$argsProperty->setAccessible(true);
$args = $argsProperty->getValue($aws);


$this->assertArrayHasKey('ua_append', $args);
$this->assertInternalType('array', $args['ua_append']);
$this->assertNotEmpty($args['ua_append']);
$this->assertNotEmpty(array_filter($args['ua_append'], function ($ua) {
return false !== strpos($ua, Module::VERSION);
}));
$this->assertNotEmpty(array_filter($args['ua_append'], function ($ua) {
return false !== strpos($ua, Version::VERSION);
}));
}

private function getMockServiceLocator()
{
$serviceLocator = $this->getMock(ServiceLocatorInterface::class);
Expand Down

0 comments on commit 012ce4c

Please sign in to comment.