From 17e72159f703ed8d6c652ccab2a4efc76a57a520 Mon Sep 17 00:00:00 2001 From: Enrico Zimuel Date: Tue, 23 Feb 2016 19:08:56 +0100 Subject: [PATCH 1/6] Code refactor for service manager v2 and v3 --- .travis.yml | 19 +++++++++++++++++-- composer.json | 19 +++++++++---------- test/DiCompatibilityTest.php | 14 +------------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index 73f4c148..503d1f1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,13 +17,26 @@ matrix: - php: 5.5 env: - EXECUTE_CS_CHECK=true + - php: 5.5 + env: + - SERVICE_MANAGER_VERSION='^2.7.5' - php: 5.6 env: - EXECUTE_TEST_COVERALLS=true + - DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)" + - PATH="$HOME/.local/bin:$PATH" + - php: 5.6 + env: + - SERVICE_MANAGER_VERSION='^2.7.5' - php: 7 - - php: hhvm - allow_failures: - php: 7 + env: + - SERVICE_MANAGER_VERSION='^2.7.5' + - php: hhvm + - php: hhvm + env: + - SERVICE_MANAGER_VERSION='^2.7.5' + allow_failures: - php: hhvm notifications: @@ -34,6 +47,8 @@ before_install: - if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi - composer self-update - if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi + - if [[ $SERVICE_MANAGER_VERSION != '' ]]; then composer require --dev --no-update "zendframework/zend-servicemanager:$SERVICE_MANAGER_VERSION" ; fi + - if [[ $SERVICE_MANAGER_VERSION == '' ]]; then composer require --dev --no-update "zendframework/zend-servicemanager:^3.0.3" ; fi install: - travis_retry composer install --no-interaction --ignore-platform-reqs diff --git a/composer.json b/composer.json index c1c965d3..66317676 100644 --- a/composer.json +++ b/composer.json @@ -14,18 +14,17 @@ }, "require": { "php": ">=5.5", - "zendframework/zend-code": "~2.5", - "zendframework/zend-stdlib": "dev-develop as 2.8.0" + "zendframework/zend-code": "^2.6 || ^3.0", + "zendframework/zend-stdlib": "^2.7 || ^3.0" }, "require-dev": { - "zendframework/zend-config": "dev-develop as 2.6.0", - "zendframework/zend-db": "dev-develop as 2.7.0", - "zendframework/zend-filter": "~2.5", - "zendframework/zend-form": "~2.5", - "zendframework/zend-log": "~2.5", - "zendframework/zend-mvc": "dev-develop as 2.7.0", - "zendframework/zend-servicemanager": "dev-develop as 2.7.0", - "zendframework/zend-view": "dev-develop as 2.6.0", + "zendframework/zend-config": "^2.6", + "zendframework/zend-db": "^2.7", + "zendframework/zend-filter": "^2.6", + "zendframework/zend-form": "^2.7", + "zendframework/zend-log": "^2.7", + "zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3", + "zendframework/zend-view": "^2.6", "fabpot/php-cs-fixer": "1.7.*", "phpunit/PHPUnit": "~4.0" }, diff --git a/test/DiCompatibilityTest.php b/test/DiCompatibilityTest.php index b55dd6a6..66319827 100644 --- a/test/DiCompatibilityTest.php +++ b/test/DiCompatibilityTest.php @@ -123,21 +123,9 @@ public function testCanCreateInstanceWithConstructorRequiredParameterWithDi($cla public function providesClassWithConstructionParameters() { - $serviceManager = new \Zend\ServiceManager\ServiceManager; - $eventManager = new \Zend\EventManager\EventManager; - $request = $this->getMockBuilder('Zend\Stdlib\RequestInterface')->getMock(); - $response = $this->getMockBuilder('Zend\Stdlib\ResponseInterface')->getMock(); - return [ ['Zend\Config\Config', ['array' => []]], - ['Zend\Db\Adapter\Adapter', ['driver' => ['driver' => 'Pdo_Sqlite']]], - ['Zend\Mvc\Application', [ - 'configuration' => [], - 'serviceManager' => $serviceManager, - 'events' => $eventManager, - 'request' => $request, - 'response' => $response - ]], + ['Zend\Db\Adapter\Adapter', ['driver' => ['driver' => 'Pdo_Sqlite']]] ]; } } From b64d18e5d157897ac21edb93f21067dcf58024c7 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 23 Feb 2016 13:24:58 -0600 Subject: [PATCH 2/6] Implement container-interop - Removed dependency on zend-servicemanaer. We can test for container-interop exceptions instead, as zend-servicemanager, for the versions we'll receive with this component, will throw compatible exceptions. - Updated `LocatorInterface` to extend container-interop. - Updated `Di` to implement `has()`. - Updated `ServiceLocator` to implement `has()`. --- composer.json | 4 ++-- src/Di.php | 24 ++++++++++++++++--- src/LocatorInterface.php | 12 +++------- src/ServiceLocator.php | 17 ++++++++++++++ test/DiTest.php | 47 +++++++++++++++++++++++++++++++++++++ test/ServiceLocatorTest.php | 15 ++++++++++++ 6 files changed, 105 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index 66317676..09a7786b 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ } }, "require": { - "php": ">=5.5", + "php": "^5.5 || ^7.0", + "container-interop/container-interop": "^1.1", "zendframework/zend-code": "^2.6 || ^3.0", "zendframework/zend-stdlib": "^2.7 || ^3.0" }, @@ -23,7 +24,6 @@ "zendframework/zend-filter": "^2.6", "zendframework/zend-form": "^2.7", "zendframework/zend-log": "^2.7", - "zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3", "zendframework/zend-view": "^2.6", "fabpot/php-cs-fixer": "1.7.*", "phpunit/PHPUnit": "~4.0" diff --git a/src/Di.php b/src/Di.php index 203a59d6..98e6a2aa 100644 --- a/src/Di.php +++ b/src/Di.php @@ -10,8 +10,8 @@ namespace Zend\Di; use Closure; +use Interop\Container\Exception\ContainerException; use Zend\Di\Exception\RuntimeException as DiRuntimeException; -use Zend\ServiceManager\Exception\ExceptionInterface as ServiceManagerException; /** * Dependency injector that can generate instances using class definitions and configured instance parameters @@ -212,6 +212,24 @@ protected function getCallParameters($name, array $params, $method = "__construc return $params; } + /** + * Is the DI container capable of returning the named instance? + * + * @param string $name + * @return bool + */ + public function has($name) + { + $definitions = $this->definitions; + $instanceManager = $this->instanceManager(); + + $class = $instanceManager->hasAlias($name) + ? $instanceManager->getClassFromAlias($name) + : $name; + + return $definitions->hasClass($class); + } + /** * Lazy-load a class * @@ -831,8 +849,8 @@ protected function resolveMethodParameters($class, $method, array $callTimeUserP } return false; } - } catch (ServiceManagerException $e) { - // Zend\ServiceManager\Exception\ServiceNotCreatedException + } catch (ContainerException $e) { + // Exceptions thrown by nested/peered containers (e.g., zend-servicemanager) if ($methodRequirementType & self::RESOLVE_STRICT) { //finally ( be aware to do at the end of flow) array_pop($this->currentDependencies); diff --git a/src/LocatorInterface.php b/src/LocatorInterface.php index 77f5aa48..d68942f9 100644 --- a/src/LocatorInterface.php +++ b/src/LocatorInterface.php @@ -9,14 +9,8 @@ namespace Zend\Di; -interface LocatorInterface +use Interop\Container\ContainerInterface; + +interface LocatorInterface extends ContainerInterface { - /** - * Retrieve a class instance - * - * @param string $name Class name or service name - * @param null|array $params Parameters to be used when instantiating a new instance of $name - * @return object|null - */ - public function get($name, array $params = []); } diff --git a/src/ServiceLocator.php b/src/ServiceLocator.php index 25e12c41..e6c1f07d 100644 --- a/src/ServiceLocator.php +++ b/src/ServiceLocator.php @@ -52,6 +52,23 @@ public function set($name, $service) return $this; } + /** + * Can the locator return the named instance? + * + * @param string $name + * @return bool + */ + public function has($name) + { + if (! isset($this->services[$name]) + && ! isset($this->map[$name]) + ) { + return false; + } + + return true; + } + /** * Retrieve a registered service * diff --git a/test/DiTest.php b/test/DiTest.php index 29ef0942..7bdf5e5c 100644 --- a/test/DiTest.php +++ b/test/DiTest.php @@ -1017,4 +1017,51 @@ public function testGetInstanceWithParamsHasSameNameAsDependencyParam() $di = new Di(null, null, $config); $this->assertCount(1, $di->get('ZendTest\Di\TestAsset\AggregatedParamClass')->aggregator->items); } + + public function hasInstanceProvider() + { + $config = new Config(['instance' => [ + TestAsset\BasicClassWithParam::class => [ + 'params' => ['foo' => 'bar'], + ], + ]]); + + $classDefB = new Definition\ClassDefinition(TestAsset\CallbackClasses\B::class); + $classDefC = new Definition\ClassDefinition(TestAsset\CallbackClasses\C::class); + $classDefB->setInstantiator(TestAsset\CallbackClasses\B::class . '::factory'); + $classDefB->addMethod('factory', true); + $classDefB->addMethodParameter('factory', 'c', [ + 'type' => TestAsset\CallbackClasses\C::class, + 'required' => true, + ]); + $classDefB->addMethodParameter('factory', 'params', ['type' => 'Array', 'required' => false]); + $definitionList = new DefinitionList([ + $classDefB, + $classDefC, + new Definition\RuntimeDefinition(), + ]); + + $instanceManager = new InstanceManager(); + $instanceManager->setParameters(TestAsset\ConstructorInjection\X::class, ['one' => 1, 'two' => 2]); + + return [ + 'no-config' => [null, null, null, TestAsset\BasicClass::class], + 'config-instance' => [null, null, $config, TestAsset\BasicClassWithParam::class], + 'definition-list' => [$definitionList, null, null, TestAsset\CallbackClasses\B::class], + 'instance-manager' => [null, $instanceManager, null, TestAsset\ConstructorInjection\X::class], + ]; + } + + /** + * @dataProvider hasInstanceProvider + */ + public function testCanQueryToSeeIfContainerHasOrCanCreateAnInstance( + $definitionList, + $instanceManager, + $config, + $testFor + ) { + $di = new Di($definitionList, $instanceManager, $config); + $this->assertTrue($di->has($testFor), sprintf('Failed to find instance for %s', $testFor)); + } } diff --git a/test/ServiceLocatorTest.php b/test/ServiceLocatorTest.php index 9de9883f..41bae22f 100644 --- a/test/ServiceLocatorTest.php +++ b/test/ServiceLocatorTest.php @@ -106,4 +106,19 @@ public function testProxiedMethodsReceiveParametersPassedToGet() $this->assertEquals($params, $test); $this->assertEquals($params, $sc->params); } + + public function testHasReturnsFalseIfLocatorDoesNotKnowOfService() + { + $this->assertFalse($this->services->has('does-not-exist')); + } + + public function testHasReturnsTrueIfLocatorKnowsOfService() + { + $this->services->set('foo', function () { + // Implementation does not matter for this test + return $this; + }); + + $this->assertTrue($this->services->has('foo')); + } } From be6c8d44371c5f148c1817a0d57844ee608577b9 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 23 Feb 2016 13:58:09 -0600 Subject: [PATCH 3/6] Removed dependency on zend-config In all cases, usage of zend-config was to pull data from configuration files, and then pass the parsed data to zend-di objects. This could be easily accomplished without the zend-config component by simply using configuration arrays. --- composer.json | 1 - test/ConfigTest.php | 36 +++++----- test/Definition/BuilderDefinitionTest.php | 3 +- test/DiCompatibilityTest.php | 2 +- test/_files/sample-definitions.php | 87 +++++++++++++++++++++++ test/_files/sample.ini | 34 --------- 6 files changed, 109 insertions(+), 54 deletions(-) create mode 100644 test/_files/sample-definitions.php delete mode 100644 test/_files/sample.ini diff --git a/composer.json b/composer.json index 09a7786b..864ec9a0 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,6 @@ "zendframework/zend-stdlib": "^2.7 || ^3.0" }, "require-dev": { - "zendframework/zend-config": "^2.6", "zendframework/zend-db": "^2.7", "zendframework/zend-filter": "^2.6", "zendframework/zend-form": "^2.7", diff --git a/test/ConfigTest.php b/test/ConfigTest.php index d86fc555..f9abc3dc 100644 --- a/test/ConfigTest.php +++ b/test/ConfigTest.php @@ -11,15 +11,15 @@ use Zend\Di\Config; use Zend\Di\Di; -use Zend\Config\Factory as ConfigFactory; use PHPUnit_Framework_TestCase as TestCase; class ConfigTest extends TestCase { public function testConfigCanConfigureInstanceManagerWithIniFile() { - $ini = ConfigFactory::fromFile(__DIR__ . '/_files/sample.ini', true)->get('section-a'); - $config = new Config($ini->di); + $ini = include __DIR__ . '/_files/sample-definitions.php'; + $ini = $ini['section-a']; + $config = new Config($ini['di']); $di = new Di(); $di->configure($config); @@ -52,8 +52,9 @@ public function testConfigCanConfigureInstanceManagerWithIniFile() public function testConfigCanConfigureBuilderDefinitionFromIni() { $this->markTestIncomplete('Builder not updated to new DI yet'); - $ini = ConfigFactory::fromFile(__DIR__ . '/_files/sample.ini', true)->get('section-b'); - $config = new Config($ini->di); + $ini = include __DIR__ . '/_files/sample-definitions.php'; + $ini = $ini['section-b']; + $config = new Config($ini['di']); $di = new Di($config); $definition = $di->getDefinition(); @@ -62,27 +63,28 @@ public function testConfigCanConfigureBuilderDefinitionFromIni() $this->assertEquals( ['username' => null, 'password' => null], $definition->getInjectionMethodParameters('My\DbAdapter', '__construct') - ); + ); $this->assertTrue($definition->hasClass('My\Mapper')); $this->assertEquals('__construct', $definition->getInstantiator('My\Mapper')); $this->assertEquals( ['dbAdapter' => 'My\DbAdapter'], $definition->getInjectionMethodParameters('My\Mapper', '__construct') - ); + ); $this->assertTrue($definition->hasClass('My\Repository')); $this->assertEquals('__construct', $definition->getInstantiator('My\Repository')); $this->assertEquals( ['mapper' => 'My\Mapper'], $definition->getInjectionMethodParameters('My\Repository', '__construct') - ); + ); } public function testConfigCanConfigureRuntimeDefinitionDefaultFromIni() { - $ini = ConfigFactory::fromFile(__DIR__ . '/_files/sample.ini', true)->get('section-c'); - $config = new Config($ini->di); + $ini = include __DIR__ . '/_files/sample-definitions.php'; + $ini = $ini['section-c']; + $config = new Config($ini['di']); $di = new Di(); $di->configure($config); $definition = $di->definitions()->getDefinitionByType('Zend\Di\Definition\RuntimeDefinition'); @@ -92,8 +94,9 @@ public function testConfigCanConfigureRuntimeDefinitionDefaultFromIni() public function testConfigCanConfigureRuntimeDefinitionDisabledFromIni() { - $ini = ConfigFactory::fromFile(__DIR__ . '/_files/sample.ini', true)->get('section-d'); - $config = new Config($ini->di); + $ini = include __DIR__ . '/_files/sample-definitions.php'; + $ini = $ini['section-d']; + $config = new Config($ini['di']); $di = new Di(); $di->configure($config); $definition = $di->definitions()->getDefinitionByType('Zend\Di\Definition\RuntimeDefinition'); @@ -102,8 +105,9 @@ public function testConfigCanConfigureRuntimeDefinitionDisabledFromIni() public function testConfigCanConfigureRuntimeDefinitionUseAnnotationFromIni() { - $ini = ConfigFactory::fromFile(__DIR__ . '/_files/sample.ini', true)->get('section-e'); - $config = new Config($ini->di); + $ini = include __DIR__ . '/_files/sample-definitions.php'; + $ini = $ini['section-e']; + $config = new Config($ini['di']); $di = new Di(); $di->configure($config); $definition = $di->definitions()->getDefinitionByType('Zend\Di\Definition\RuntimeDefinition'); @@ -112,8 +116,8 @@ public function testConfigCanConfigureRuntimeDefinitionUseAnnotationFromIni() public function testConfigCanConfigureCompiledDefinition() { - $config = ConfigFactory::fromFile(__DIR__ . '/_files/sample.php', true); - $config = new Config($config->di); + $config = include __DIR__ . '/_files/sample.php'; + $config = new Config($config['di']); $di = new Di(); $di->configure($config); $definition = $di->definitions()->getDefinitionByType('Zend\Di\Definition\ArrayDefinition'); diff --git a/test/Definition/BuilderDefinitionTest.php b/test/Definition/BuilderDefinitionTest.php index 5e2ef3a0..7789eeb2 100644 --- a/test/Definition/BuilderDefinitionTest.php +++ b/test/Definition/BuilderDefinitionTest.php @@ -11,7 +11,6 @@ use Zend\Di\Definition\BuilderDefinition; use Zend\Di\Definition\Builder; -use Zend\Config\Factory as ConfigFactory; use PHPUnit_Framework_TestCase as TestCase; class BuilderDefinitionTest extends TestCase @@ -73,7 +72,7 @@ public function testBuilderDefinitionHasMethods() public function testBuilderCanBuildFromArray() { - $ini = ConfigFactory::fromFile(__DIR__ . '/../_files/sample.ini'); + $ini = include __DIR__ . '/../_files/sample-definitions.php'; $iniAsArray = $ini['section-b']; $definitionArray = $iniAsArray['di']['definitions'][1]; unset($definitionArray['class']); diff --git a/test/DiCompatibilityTest.php b/test/DiCompatibilityTest.php index 66319827..3788a763 100644 --- a/test/DiCompatibilityTest.php +++ b/test/DiCompatibilityTest.php @@ -124,7 +124,7 @@ public function testCanCreateInstanceWithConstructorRequiredParameterWithDi($cla public function providesClassWithConstructionParameters() { return [ - ['Zend\Config\Config', ['array' => []]], + [TestAsset\BasicClassWithParam::class, ['foo' => 'bar']], ['Zend\Db\Adapter\Adapter', ['driver' => ['driver' => 'Pdo_Sqlite']]] ]; } diff --git a/test/_files/sample-definitions.php b/test/_files/sample-definitions.php new file mode 100644 index 00000000..e3616a68 --- /dev/null +++ b/test/_files/sample-definitions.php @@ -0,0 +1,87 @@ + [ + 'di' => [ + 'instance' => [ + 'alias' => [ + 'my-repository' => 'My\RepositoryA', + 'my-mapper' => 'My\Mapper', + 'my-dbAdapter' => 'My\DbAdapter', + ], + 'preferences' => [ + 'my-repository' => [ 'my-mapper' ], + 'my-mapper' => [ 'my-dbAdapter' ], + ], + 'My\DbAdapter' => [ + 'parameters' => [ + 'username' => 'readonly', + 'password' => 'mypassword', + ], + ], + 'my-dbAdapter' => [ + 'parameters' => [ + 'username' => 'readwrite', + ], + ], + ], + ], + ], + 'section-b' => [ + 'di' => [ + 'definitions' => [ + 1 => [ + 'class' => Zend\Di\Definition\BuilderDefinition::class, + 'My\DbAdapter' => [ + 'methods' => [ + '__construct' => [ + 'username' => null, + 'password' => null, + ], + ], + ], + 'My\Mapper' => [ + 'methods' => [ + '__construct' => [ + 'dbAdapter' => 'My\DbAdapter', + ], + ], + ], + 'My\Repository' => [ + 'methods' => [ + '__construct' => [ + 'mapper' => 'My\Mapper', + ], + ], + ], + ], + ], + ], + ], + 'section-c' => [ + 'di' => [ + 'definition' => [ + 'runtime' => [ + 'xxx' => 'zzz', + ], + ], + ], + ], + 'section-d' => [ + 'di' => [ + 'definition' => [ + 'runtime' => [ + 'enabled' => false, + ], + ], + ], + ], + 'section-e' => [ + 'di' => [ + 'definition' => [ + 'runtime' => [ + 'use_annotations' => true, + ], + ], + ], + ], +]; diff --git a/test/_files/sample.ini b/test/_files/sample.ini deleted file mode 100644 index b1f49824..00000000 --- a/test/_files/sample.ini +++ /dev/null @@ -1,34 +0,0 @@ - -[section-a] - -di.instance.alias.my-repository = 'My\RepositoryA' -di.instance.alias.my-mapper = 'My\Mapper' -di.instance.alias.my-dbAdapter = 'My\DbAdapter' - -di.instance.preferences.my-repository[] = 'my-mapper' -di.instance.preferences.my-mapper[] = 'my-dbAdapter' - -di.instance.My\DbAdapter.parameters.username = 'readonly' -di.instance.My\DbAdapter.parameters.password = 'mypassword' - -di.instance.my-dbAdapter.parameters.username = 'readwrite'; - -[section-b] - -di.definitions.1.class = Zend\Di\Definition\BuilderDefinition -di.definitions.1.My\DbAdapter.methods.__construct.username = NULL -di.definitions.1.My\DbAdapter.methods.__construct.password = NULL -di.definitions.1.My\Mapper.methods.__construct.dbAdapter = My\DbAdapter -di.definitions.1.My\Repository.methods.__construct.mapper = My\Mapper - -[section-c] - -di.definition.runtime.xxx = zzz - -[section-d] - -di.definition.runtime.enabled = 0 - -[section-e] - -di.definition.runtime.use_annotations = 1 \ No newline at end of file From 898b58d9caf8c1bc796f0b7b1d08966d2e6edeb5 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 23 Feb 2016 14:03:15 -0600 Subject: [PATCH 4/6] Removed dependency on zend-db - Only test that required it could be mimiced with generic test assets. --- composer.json | 1 - test/DiCompatibilityTest.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 864ec9a0..10e7427d 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,6 @@ "zendframework/zend-stdlib": "^2.7 || ^3.0" }, "require-dev": { - "zendframework/zend-db": "^2.7", "zendframework/zend-filter": "^2.6", "zendframework/zend-form": "^2.7", "zendframework/zend-log": "^2.7", diff --git a/test/DiCompatibilityTest.php b/test/DiCompatibilityTest.php index 3788a763..64357ed5 100644 --- a/test/DiCompatibilityTest.php +++ b/test/DiCompatibilityTest.php @@ -125,7 +125,7 @@ public function providesClassWithConstructionParameters() { return [ [TestAsset\BasicClassWithParam::class, ['foo' => 'bar']], - ['Zend\Db\Adapter\Adapter', ['driver' => ['driver' => 'Pdo_Sqlite']]] + [TestAsset\ConstructorInjection\X::class, ['one' => 1, 'two' => 2]], ]; } } From 44d7b5404a4d82875c2365994662ad31896921c9 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 23 Feb 2016 14:07:02 -0600 Subject: [PATCH 5/6] Remove unneeded dependencies Removes each of: - zend-filter - zend-form - zend-log - zend-view as each component was used only to test specific instantiation patterns, each of which could be mimiced via generic test assets or PHP built-in classes. --- composer.json | 9 +-------- test/DiCompatibilityTest.php | 11 ++++------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 10e7427d..87dadaff 100644 --- a/composer.json +++ b/composer.json @@ -19,22 +19,15 @@ "zendframework/zend-stdlib": "^2.7 || ^3.0" }, "require-dev": { - "zendframework/zend-filter": "^2.6", - "zendframework/zend-form": "^2.7", - "zendframework/zend-log": "^2.7", - "zendframework/zend-view": "^2.6", "fabpot/php-cs-fixer": "1.7.*", "phpunit/PHPUnit": "~4.0" }, - "suggest": { - "zendframework/zend-servicemanager": "Zend\\ServiceManager component" - }, "minimum-stability": "dev", "prefer-stable": true, "extra": { "branch-alias": { "dev-master": "2.5-dev", - "dev-develop": "3.0-dev" + "dev-develop": "2.6-dev" } }, "autoload-dev": { diff --git a/test/DiCompatibilityTest.php b/test/DiCompatibilityTest.php index 64357ed5..ac502093 100644 --- a/test/DiCompatibilityTest.php +++ b/test/DiCompatibilityTest.php @@ -12,6 +12,7 @@ use BadMethodCallException; use Exception; use PHPUnit_Framework_Error; +use SplStack; use Zend\Di\Di; class DiCompatibilityTest extends \PHPUnit_Framework_TestCase @@ -41,13 +42,9 @@ public function testDiSimple($class) public function providesSimpleClasses() { return [ - ['Zend\Di\Di'], - ['Zend\EventManager\EventManager'], - ['Zend\Filter\ToNull'], - ['Zend\Form\Form'], - ['Zend\Log\Logger'], - ['Zend\Stdlib\SplStack'], - ['Zend\View\Model\ViewModel'], + [Di::class], + [SplStack::class], + [TestAsset\BasicClass::class], ]; } From 06e3caecac23d7b543eb0fb73700ff309436b497 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 23 Feb 2016 14:12:25 -0600 Subject: [PATCH 6/6] Updated build matrix - Remove documentation build artifacts (not yet deployed) - `s/SERVICE_MANAGER/CODE/g`, and set versions to `^2.6` and `^3.0` for testing. --- .travis.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 503d1f1d..6dd5a7f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,10 @@ cache: directories: - $HOME/.composer/cache +env: + global: + - CODE_VERSION="^3.0" + matrix: fast_finish: true include: @@ -19,23 +23,21 @@ matrix: - EXECUTE_CS_CHECK=true - php: 5.5 env: - - SERVICE_MANAGER_VERSION='^2.7.5' + - CODE_VERSION="^2.6" - php: 5.6 env: - EXECUTE_TEST_COVERALLS=true - - DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)" - - PATH="$HOME/.local/bin:$PATH" - php: 5.6 env: - - SERVICE_MANAGER_VERSION='^2.7.5' + - CODE_VERSION="^2.6" - php: 7 - php: 7 env: - - SERVICE_MANAGER_VERSION='^2.7.5' + - CODE_VERSION="^2.6" - php: hhvm - php: hhvm env: - - SERVICE_MANAGER_VERSION='^2.7.5' + - CODE_VERSION="^2.6" allow_failures: - php: hhvm @@ -47,8 +49,7 @@ before_install: - if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi - composer self-update - if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi - - if [[ $SERVICE_MANAGER_VERSION != '' ]]; then composer require --dev --no-update "zendframework/zend-servicemanager:$SERVICE_MANAGER_VERSION" ; fi - - if [[ $SERVICE_MANAGER_VERSION == '' ]]; then composer require --dev --no-update "zendframework/zend-servicemanager:^3.0.3" ; fi + - composer require --no-update "zendframework/zend-code:$CODE_VERSION" install: - travis_retry composer install --no-interaction --ignore-platform-reqs