class PhpArrayContainerTest
@coversDefaultClass \Drupal\Component\DependencyInjection\PhpArrayContainer
@group DependencyInjection
Hierarchy
- class \Drupal\Tests\Component\DependencyInjection\ContainerTest uses \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Prophecy\PhpUnit\ProphecyTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\Component\DependencyInjection\PhpArrayContainerTest extends \Drupal\Tests\Component\DependencyInjection\ContainerTest
Expanded class hierarchy of PhpArrayContainerTest
File
-
core/
tests/ Drupal/ Tests/ Component/ DependencyInjection/ PhpArrayContainerTest.php, line 13
Namespace
Drupal\Tests\Component\DependencyInjectionView source
class PhpArrayContainerTest extends ContainerTest {
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->machineFormat = FALSE;
$this->containerClass = '\\Drupal\\Component\\DependencyInjection\\PhpArrayContainer';
$this->containerDefinition = $this->getMockContainerDefinition();
$this->container = new $this->containerClass($this->containerDefinition);
}
/**
* Helper function to return a service definition.
*/
protected function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
if ($invalid_behavior !== ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
return sprintf('@?%s', $id);
}
return sprintf('@%s', $id);
}
/**
* Helper function to return a service definition.
*/
protected function getParameterCall($name) {
return '%' . $name . '%';
}
/**
* Helper function to return a machine-optimized '@notation'.
*/
protected function getCollection($collection, $resolve = TRUE) {
return $collection;
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
|---|---|---|---|---|
| ContainerTest::$container | protected | property | The tested container. | |
| ContainerTest::$containerClass | protected | property | The container class to be tested. | |
| ContainerTest::$containerDefinition | protected | property | The container definition used for the test. | |
| ContainerTest::$machineFormat | protected | property | Whether the container uses the machine-optimized format or not. | |
| ContainerTest::getIterator | protected | function | Helper function to return a service iterator. | |
| ContainerTest::getMockContainerDefinition | protected | function | Gets a mock container definition. | |
| ContainerTest::getPrivateServiceCall | protected | function | Helper function to return a private service definition. | |
| ContainerTest::getRaw | protected | function | Helper function to return a raw value definition. | |
| ContainerTest::getServiceClosureCall | protected | function | Helper function to return a service closure definition. | |
| ContainerTest::testConstruct | public | function | Tests that passing a non-supported format throws an InvalidArgumentException. | |
| ContainerTest::testGet | public | function | Tests that Container::get() works properly. | |
| ContainerTest::testGetForAliasedService | public | function | Tests that Container::get() for aliased services works properly. | |
| ContainerTest::testGetForCircularServices | public | function | Tests that Container::get() for circular dependencies works properly. @covers ::get[[api-linebreak]] @covers ::createService[[api-linebreak]] |
|
| ContainerTest::testGetForClassFromParameter | public | function | Tests that Container::get() works properly for class from parameters. | |
| ContainerTest::testGetForConfigurator | public | function | Tests that Container::get() for configurable services works. | |
| ContainerTest::testGetForConfiguratorWithException | public | function | Tests that Container::get() for configurable services throws an Exception. | |
| ContainerTest::testGetForFactoryClass | public | function | Tests that Container::get() for factories via class works (Symfony 2.7.0). | |
| ContainerTest::testGetForFactoryService | public | function | Tests Container::get() for factories via services (Symfony 2.7.0). | |
| ContainerTest::testGetForInstantiationWithVariousArgumentLengths | public | function | Tests that Container::get() for various arguments lengths works. | |
| ContainerTest::testGetForNonExistentNULLService | public | function | Tests that Container::get() for NULL service works properly. @covers ::get[[api-linebreak]] @covers ::createService[[api-linebreak]] |
|
| ContainerTest::testGetForNonExistentParameterDependency | public | function | Tests that Container::get() for non-existent parameters works properly. | |
| ContainerTest::testGetForNonExistentParameterDependencyWithException | public | function | Tests that Container::get() for non-existent parameters works properly. | |
| ContainerTest::testGetForNonExistentService | public | function | Tests that Container::get() for non-existent services works properly. | |
| ContainerTest::testGetForNonExistentServiceDependency | public | function | Tests that Container::get() for non-existent dependencies works properly. | |
| ContainerTest::testGetForNonExistentServiceDependencyWithException | public | function | Tests that Container::get() for non-existent dependencies works properly. | |
| ContainerTest::testGetForNonExistentServiceMultipleTimes | public | function | Tests multiple Container::get() calls for non-existing dependencies work. | |
| ContainerTest::testGetForNonExistentServiceWhenUsingNull | public | function | Tests that Container::get() for non-existent services works properly. | |
| ContainerTest::testGetForNonExistentServiceWithExceptionOnSecondCall | public | function | Tests multiple Container::get() calls with exception on the second time. | |
| ContainerTest::testGetForNonSharedService | public | function | Tests that Container::get() for non-shared services works properly. | |
| ContainerTest::testGetForParameterDependencyWithExceptionOnSecondCall | public | function | Tests Container::get() with an exception due to missing parameter on the second call. | |
| ContainerTest::testGetForSerializedServiceDefinition | public | function | Tests that Container::get() for a serialized definition works properly. | |
| ContainerTest::testGetForSyntheticService | public | function | Tests that Container::get() for synthetic services works - if defined. | |
| ContainerTest::testGetForSyntheticServiceWithException | public | function | Tests that Container::get() for synthetic services throws an Exception if not defined. | |
| ContainerTest::testGetForWrongFactory | public | function | Tests that Container::get() for wrong factories works correctly. | |
| ContainerTest::testGetParameter | public | function | Tests that Container::getParameter() works properly. | |
| ContainerTest::testGetParameterIfNotFound | public | function | Tests that Container::getParameter() works for non-existing parameters. | |
| ContainerTest::testGetParameterIfNotFoundBecauseNull | public | function | Tests that Container::getParameter() works properly for NULL parameters. | |
| ContainerTest::testGetServiceIdMappings | public | function | @covers \Drupal\Component\DependencyInjection\ServiceIdHashTrait::getServiceIdMappings[[api-linebreak]] @covers \Drupal\Component\DependencyInjection\ServiceIdHashTrait::generateServiceIdHash[[api-linebreak]] |
|
| ContainerTest::testGetServiceIds | public | function | Tests that Container::getServiceIds() works properly. | |
| ContainerTest::testGetWithFileInclude | public | function | Tests that Container::get() for services with file includes works. | |
| ContainerTest::testHas | public | function | Tests that Container::has() works properly. | |
| ContainerTest::testHasForAliasedService | public | function | Tests that Container::has() for aliased services works properly. | |
| ContainerTest::testHasParameter | public | function | Tests that Container::hasParameter() works properly. | |
| ContainerTest::testInitialized | public | function | Tests that Container::initialized works correctly. | |
| ContainerTest::testInitializedForAliases | public | function | Tests that Container::initialized works correctly for aliases. | |
| ContainerTest::testIterator | public | function | Tests that service iterators are lazily instantiated. | |
| ContainerTest::testReset | public | function | Tests Container::reset(). | |
| ContainerTest::testResolveServicesAndParametersForArgumentsUsingDeepArray | public | function | Tests that services with an array of arguments work correctly. | |
| ContainerTest::testResolveServicesAndParametersForInvalidArgument | public | function | Tests that an invalid argument throw an Exception. | |
| ContainerTest::testResolveServicesAndParametersForInvalidArguments | public | function | Tests that invalid arguments throw an Exception. | |
| ContainerTest::testResolveServicesAndParametersForOptionalServiceDependencies | public | function | Tests that services that are optional work correctly. | |
| ContainerTest::testResolveServicesAndParametersForPrivateService | public | function | Tests that private services work correctly. | |
| ContainerTest::testResolveServicesAndParametersForRawArgument | public | function | Tests that raw type services arguments are resolved correctly. | |
| ContainerTest::testResolveServicesAndParametersForServiceInstantiatedFromParameter | public | function | Tests that a parameter that points to a service works correctly. | |
| ContainerTest::testResolveServicesAndParametersForServiceReferencedViaServiceClosure | public | function | Tests that services wrapped in a closure work correctly. | |
| ContainerTest::testResolveServicesAndParametersForSharedPrivateService | public | function | Tests that private service sharing works correctly. | |
| ContainerTest::testSet | public | function | Tests that Container::set() works properly. | |
| ContainerTest::testSetParameterWithFrozenContainer | public | function | Tests that Container::setParameter() in a frozen case works properly. | |
| ContainerTest::testSetParameterWithUnfrozenContainer | public | function | Tests that Container::setParameter() in an unfrozen case works properly. | |
| PhpArrayContainerTest::getCollection | protected | function | Helper function to return a machine-optimized '@notation'. | Overrides ContainerTest::getCollection |
| PhpArrayContainerTest::getParameterCall | protected | function | Helper function to return a service definition. | Overrides ContainerTest::getParameterCall |
| PhpArrayContainerTest::getServiceCall | protected | function | Helper function to return a service definition. | Overrides ContainerTest::getServiceCall |
| PhpArrayContainerTest::setUp | protected | function | Overrides ContainerTest::setUp |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.