Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit c696ea7

Browse files
committed
Merge branch 'hotfix/container-vs-sl'
Helps with zendframework/zend-mvc#149
2 parents 78b67d3 + 6ea9ff6 commit c696ea7

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5-
## 1.0.1 - TBD
5+
## 1.0.1 - 2016-06-09
66

77
### Added
88

@@ -14,7 +14,9 @@ All notable changes to this project will be documented in this file, in reverse
1414

1515
### Removed
1616

17-
- Nothing.
17+
- Imports a patch from [zend-mvc](https://github.com/zendframework/zend-mvc/pull/149)
18+
that fixes some issues with the `DiAbstractServiceFactoryFactory` due to
19+
incorrect variable names and import statements.
1820

1921
### Fixed
2022

src/DiAbstractServiceFactoryFactory.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
namespace Zend\ServiceManager\Di;
99

1010
use Interop\Container\ContainerInterface;
11-
use DiAbstractServiceFactory;
1211
use Zend\ServiceManager\FactoryInterface;
1312
use Zend\ServiceManager\ServiceLocatorInterface;
1413
use Zend\ServiceManager\ServiceManager;
@@ -27,8 +26,8 @@ public function __invoke(ContainerInterface $container, $name, array $options =
2726
{
2827
$factory = new DiAbstractServiceFactory($container->get('Di'), DiAbstractServiceFactory::USE_SL_BEFORE_DI);
2928

30-
if ($serviceLocator instanceof ServiceManager) {
31-
$serviceLocator->addAbstractFactory($factory, false);
29+
if ($container instanceof ServiceManager) {
30+
$container->addAbstractFactory($factory, false);
3231
}
3332

3433
return $factory;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
namespace ZendTest\Mvc\Service;
3+
4+
use Zend\ServiceManager\Di\DiAbstractServiceFactoryFactory;
5+
use Zend\ServiceManager\Di\DiFactory;
6+
use Zend\ServiceManager\Di\DiAbstractServiceFactory;
7+
use Zend\ServiceManager\ServiceManager;
8+
9+
class DiAbstractServiceFactoryFactoryTest extends \PHPUnit_Framework_TestCase
10+
{
11+
public function testWillInitializeDiAbstractServiceFactory()
12+
{
13+
$serviceManager = new ServiceManager();
14+
$serviceManager->setService('config', ['di' => ['']]);
15+
$serviceManager->setFactory('Di', new DiFactory());
16+
$serviceManager->setFactory(DiAbstractServiceFactoryFactory::class, new DiAbstractServiceFactoryFactory());
17+
18+
$factory = $serviceManager->get(DiAbstractServiceFactoryFactory::class);
19+
$this->assertInstanceOf(DiAbstractServiceFactory::class, $factory);
20+
}
21+
22+
public function testDiAbstractServiceFactoryIsAddedToAbstractFactoriesOfServiceManager()
23+
{
24+
$serviceManager = $this->getMockBuilder(ServiceManager::class)
25+
->setMethods(['addAbstractFactory'])
26+
->getMock();
27+
28+
$serviceManager->expects($this->once())->method('addAbstractFactory')->with($this->callback(function ($param) {
29+
return $param instanceof DiAbstractServiceFactory;
30+
}));
31+
32+
$serviceManager->setService('config', ['di' => ['']]);
33+
$serviceManager->setFactory('Di', new DiFactory());
34+
$serviceManager->setFactory(DiAbstractServiceFactoryFactory::class, new DiAbstractServiceFactoryFactory());
35+
36+
$serviceManager->get(DiAbstractServiceFactoryFactory::class);
37+
}
38+
}

0 commit comments

Comments
 (0)