mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-05 14:37:27 +02:00
PHP7 Dependency Injection
This commit is contained in:
@@ -2,24 +2,16 @@
|
||||
|
||||
namespace DesignPatterns\Structural\DependencyInjection\Tests;
|
||||
|
||||
use DesignPatterns\Structural\DependencyInjection\ArrayConfig;
|
||||
use DesignPatterns\Structural\DependencyInjection\Connection;
|
||||
use DesignPatterns\Structural\DependencyInjection\DatabaseConfiguration;
|
||||
use DesignPatterns\Structural\DependencyInjection\DatabaseConnection;
|
||||
|
||||
class DependencyInjectionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $config;
|
||||
protected $source;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->source = include 'config.php';
|
||||
$this->config = new ArrayConfig($this->source);
|
||||
}
|
||||
|
||||
public function testDependencyInjection()
|
||||
{
|
||||
$connection = new Connection($this->config);
|
||||
$connection->connect();
|
||||
$this->assertEquals($this->source['host'], $connection->getHost());
|
||||
$config = new DatabaseConfiguration('localhost', 3306, 'domnikl', '1234');
|
||||
$connection = new DatabaseConnection($config);
|
||||
|
||||
$this->assertEquals('domnikl:1234@localhost:3306', $connection->getDsn());
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +0,0 @@
|
||||
<?php
|
||||
|
||||
return array('host' => 'github.com');
|
Reference in New Issue
Block a user