Skip to content

Commit

Permalink
Test that merged container is injected for container aware consumers
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Vegner committed Jan 9, 2018
1 parent 73807b7 commit 2906cf1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,6 @@ public function testMerge() {
$consumer = $mergedContainer->inject(new MultiConsumer());
$this->assertSame($post, $consumer->getPost(), 'Must inject post from post container');
$this->assertSame($request, $consumer->getRequest(), 'Must inject request from request container');
$this->assertSame($mergedContainer, $consumer->getContainer(), 'Must inject merged container');
}
}
12 changes: 11 additions & 1 deletion tests/MultiConsumer.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<?php
namespace tests;

use SD\DependencyInjection\AutoDeclarerInterface;
use SD\DependencyInjection\AutoDeclarerTrait;
use SD\DependencyInjection\ContainerAwareTrait;
use SD\DependencyInjection\DeclarerInterface;

class MultiConsumer implements DeclarerInterface {
class MultiConsumer implements AutoDeclarerInterface, DeclarerInterface {
use AutoDeclarerTrait;
use ContainerAwareTrait;

private $post;
private $request;

Expand All @@ -26,4 +32,8 @@ public function setRequest($request) {
public function getRequest() {
return $this->request;
}

public function getContainer() {
return $this->container;
}
}

0 comments on commit 2906cf1

Please sign in to comment.