-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #508 from lcobucci/fix-base-class-configuration
Fix generation of containers using a base class
- Loading branch information
Showing
10 changed files
with
109 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Lcobucci\DependencyInjection; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @covers \Lcobucci\DependencyInjection\ContainerBuilder | ||
* @covers \Lcobucci\DependencyInjection\Compiler | ||
* @covers \Lcobucci\DependencyInjection\Compiler\ParameterBag | ||
* @covers \Lcobucci\DependencyInjection\Config\ContainerConfiguration | ||
* @covers \Lcobucci\DependencyInjection\Generator | ||
* @covers \Lcobucci\DependencyInjection\Generators\Xml | ||
* @covers \Lcobucci\DependencyInjection\Testing\MakeServicesPublic | ||
*/ | ||
final class CompilationWithBaseClassTest extends TestCase | ||
{ | ||
use GeneratesDumpDirectory; | ||
|
||
private const DI_NAMESPACE = 'Lcobucci\\DiTests\\BaseClass'; | ||
|
||
/** @test */ | ||
public function containerCanHaveACustomBaseClass(): void | ||
{ | ||
$container = ContainerBuilder::default(__FILE__, self::DI_NAMESPACE) | ||
->setBaseClass(ContainerForTests::class) | ||
->setDumpDir($this->dumpDirectory) | ||
->getContainer(); | ||
|
||
self::assertInstanceOf(ContainerForTests::class, $container); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Lcobucci\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\Container; | ||
|
||
abstract class ContainerForTests extends Container | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Lcobucci\DependencyInjection; | ||
|
||
use function assert; | ||
use function exec; | ||
use function is_string; | ||
use function mkdir; | ||
use function tempnam; | ||
use function unlink; | ||
|
||
trait GeneratesDumpDirectory | ||
{ | ||
private string $dumpDirectory; | ||
|
||
/** @before */ | ||
public function createDumpDir(): void | ||
{ | ||
mkdir(__DIR__ . '/../tmp'); | ||
|
||
$tempName = tempnam(__DIR__ . '/../tmp', 'lcobucci-di-builder'); | ||
assert(is_string($tempName)); | ||
|
||
$this->dumpDirectory = $tempName; | ||
unlink($this->dumpDirectory); | ||
mkdir($this->dumpDirectory); | ||
} | ||
|
||
/** @after */ | ||
public function removeDumpDir(): void | ||
{ | ||
exec('rm -rf ' . __DIR__ . '/../tmp'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters