You are here

public function ContainerTest::testServiceResolvingInCalls in Little helpers 7.2

Test service resolving in calls.

File

tests/Services/ContainerTest.php, line 74

Class

ContainerTest
Test the service container.

Namespace

Drupal\little_helpers\Services

Code

public function testServiceResolvingInCalls() {
  $specs['a'] = [
    'class' => \SplFixedArray::class,
    'constructor' => 'fromArray',
    'arguments' => [
      [
        1,
        2,
        3,
      ],
    ],
  ];
  $specs['nested_a'] = [
    'class' => \SplFixedArray::class,
    'arguments' => [
      1,
    ],
    'calls' => [
      [
        'offsetSet',
        [
          0,
          '@a',
        ],
      ],
    ],
  ];
  $container = new Container();
  $container
    ->setSpecs($specs);
  $a = $container
    ->loadService('nested_a');
  $this
    ->assertEqual([
    \SplFixedArray::fromArray([
      1,
      2,
      3,
    ]),
  ], $a
    ->toArray());
}