public function ContainerTest::test_set in Service Container 7
Same name and namespace in other branches
- 7.2 tests/src/DependencyInjection/ContainerTest.php \Drupal\Tests\service_container\DependencyInjection\ContainerTest::test_set()
Tests that Container::set() works properly.
@covers ::set()
File
- tests/
src/ DependencyInjection/ ContainerTest.php, line 150 - Contains \Drupal\Tests\service_container\DependencyInjection\ContainerTest
Class
- ContainerTest
- @coversDefaultClass \Drupal\service_container\DependencyInjection\Container @group dic
Namespace
Drupal\Tests\service_container\DependencyInjectionCode
public function test_set() {
$this
->assertNull($this->container
->get('new_id', ContainerInterface::NULL_ON_INVALID_REFERENCE));
$mock_service = new MockService();
$this->container
->set('new_id', $mock_service);
$this
->assertSame($mock_service, $this->container
->get('new_id'), 'A manual set service works as expected.');
}