PhpArrayDumperTest.php in Service Container 7
File
tests/src/DependencyInjection/Dumper/PhpArrayDumperTest.php
View source
<?php
namespace Drupal\Tests\service_container\DependencyInjection\Dumper;
use Drupal\Component\DependencyInjection\Dumper\PhpArrayDumper;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class PhpArrayDumperTest extends \PHPUnit_Framework_TestCase {
protected $container_builder;
protected $dumper;
public function setUp() {
$this->container_builder = new ContainerBuilder();
$this->container_builder
->register('foo', 'My/Class');
$this->container_builder
->setAlias('bar', 'foo');
$this->dumper = new PhpArrayDumper($this->container_builder);
}
public function test_dump() {
$dump = unserialize($this->dumper
->dump());
$this
->assertTrue(is_array($dump));
$this
->assertEquals($dump['aliases']['bar'], 'foo');
$this
->assertEquals($dump['services']['foo'], array(
'class' => 'My/Class',
'arguments_count' => 0,
));
}
public function test_getArray() {
$dump = $this->dumper
->getArray();
$this
->assertTrue(is_array($dump));
$this
->assertEquals($dump['aliases']['bar'], 'foo');
$this
->assertEquals($dump['services']['foo'], array(
'class' => 'My/Class',
'arguments_count' => 0,
));
}
}