You are here

public function ContainerAwarePluginManagerTest::test_createInstance in Service Container 7.2

Same name and namespace in other branches
  1. 7 tests/src/Plugin/ContainerAwarePluginManagerTest.php \Drupal\Tests\service_container\Plugin\ContainerAwarePluginManagerTest::test_createInstance()

@covers ::createInstance()

File

tests/src/Plugin/ContainerAwarePluginManagerTest.php, line 57
Contains \Drupal\Tests\service_container\Plugin\ContainerAwarePluginManagerTest

Class

ContainerAwarePluginManagerTest
@coversDefaultClass \Drupal\service_container\Plugin\ContainerAwarePluginManager @group dic

Namespace

Drupal\Tests\service_container\Plugin

Code

public function test_createInstance() {
  $block_controller = $this->controllerPluginManager
    ->createInstance('block');
  $this
    ->assertInstanceof('\\Drupal\\render_cache_block\\RenderCache\\Controller\\BlockController', $block_controller, 'createInstance() returns the right class.');
  $block_controller2 = $this->controllerPluginManager
    ->createInstance('block');
  $this
    ->assertNotSame($block_controller, $block_controller2, 'createInstance() returns not the same instance when called twice.');
}