You are here

class PhpArrayDumperTest in Service Container 7

Same name and namespace in other branches
  1. 7.2 tests/src/DependencyInjection/Dumper/PhpArrayDumperTest.php \Drupal\Tests\service_container\DependencyInjection\Dumper\PhpArrayDumperTest

@coversDefaultClass \Drupal\Component\DependencyInjection\Dumper\PhpArrayDumper @group dic

Hierarchy

  • class \Drupal\Tests\service_container\DependencyInjection\Dumper\PhpArrayDumperTest extends \Drupal\Tests\service_container\DependencyInjection\Dumper\PHPUnit_Framework_TestCase

Expanded class hierarchy of PhpArrayDumperTest

File

tests/src/DependencyInjection/Dumper/PhpArrayDumperTest.php, line 17
Contains \Drupal\Tests\service_container\DependencyInjection\Dumper\PhpArrayDumperTest

Namespace

Drupal\Tests\service_container\DependencyInjection\Dumper
View source
class PhpArrayDumperTest extends \PHPUnit_Framework_TestCase {

  /**
   * @var ContainerBuilder
   */
  protected $container_builder;

  /**
   * @var PhpArrayDumper
   */
  protected $dumper;

  /**
   * {@inheritdoc}
   */
  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);
  }

  /**
   * @covers ::dump
   */
  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,
    ));
  }

  /**
   * @covers ::getArray
   */
  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,
    ));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhpArrayDumperTest::$container_builder protected property
PhpArrayDumperTest::$dumper protected property
PhpArrayDumperTest::setUp public function
PhpArrayDumperTest::test_dump public function @covers ::dump
PhpArrayDumperTest::test_getArray public function @covers ::getArray