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

Commit

Permalink
Merge branch 'hotfix/5' into release-1.0.0
Browse files Browse the repository at this point in the history
Forward port #5

Conflicts:
	CHANGELOG.md
  • Loading branch information
weierophinney committed Jan 23, 2018
2 parents b896eed + 5262056 commit 0de6541
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ Versions prior to 0.2.0 were released as the package "webimpress/zend-auradi-con

- Nothing.

## 0.2.1 - 2018-01-23

### Added

- Nothing.

### Changed

- Nothing.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- [#5](https://github.com/zendframework/zend-auradi-config/pull/5) fixes an
issue whereby factories would not receive the service name as the second
argument, preventing their re-use for additional services.

## 0.2.0 - 2017-11-21

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function define(Container $container)
if (! $container->has($factory)) {
$container->set($factory, $container->lazyNew($factory));
}
$container->set($service, $container->lazyGetCall($factory, '__invoke', $container));
$container->set($service, $container->lazyGetCall($factory, '__invoke', $container, $service));
}
}

Expand Down
22 changes: 22 additions & 0 deletions test/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Aura\Di\ContainerBuilder;
use PHPUnit\Framework\TestCase;
use Zend\AuraDi\Config\Config;
use ZendTest\AuraDi\Config\TestAsset\FactoryWithName;

class ConfigTest extends TestCase
{
Expand Down Expand Up @@ -214,4 +215,25 @@ public function testInjectMultipleDelegators()
$service->injected
);
}

public function testFactoryGetsServiceName()
{
$factory = new FactoryWithName();

$dependencies = [
'services' => [
'factory' => $factory,
],
'factories' => [
'foo-bar' => 'factory',
],
];

$container = $this->builder->newConfiguredInstance([new Config(['dependencies' => $dependencies])]);
$args = $container->get('foo-bar');

self::assertCount(2, $args);
self::assertSame($container, array_shift($args));
self::assertEquals('foo-bar', array_shift($args));
}
}
16 changes: 16 additions & 0 deletions test/TestAsset/FactoryWithName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* @see https://github.com/zendframework/zend-auradi-config for the canonical source repository
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-auradi-config/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\AuraDi\Config\TestAsset;

class FactoryWithName
{
public function __invoke()
{
return func_get_args();
}
}

0 comments on commit 0de6541

Please sign in to comment.