function UpdateOrderingTest::setUp

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Update/UpdateOrderingTest.php, line 37

Class

UpdateOrderingTest
Tests update ordering.

Namespace

Drupal\Tests\Core\Update

Code

protected function setUp() : void {
  parent::setUp();
  require_once $this->root . '/core/includes/update.inc';
  // Load a hook_update_dependencies() implementation that allows this test
  // to control the update ordering.
  require_once $this->root . '/core/tests/fixtures/test_update_ordering/test_update_ordering.php';
  $registry = $this->prophesize(UpdateHookRegistry::class);
  $registry->getAllInstalledVersions()
    ->willReturn([
    'a_module' => 8000,
    'system' => 8000,
    'z_module' => 8000,
  ]);
  $registry->getAvailableUpdates('system')
    ->willReturn([
    9000,
    9001,
  ]);
  $registry->getInstalledVersion('system')
    ->willReturn(8000);
  $registry->getAvailableUpdates('a_module')
    ->willReturn([
    9000,
  ]);
  $registry->getInstalledVersion('a_module')
    ->willReturn(8000);
  $registry->getAvailableUpdates('z_module')
    ->willReturn([
    9000,
    9001,
  ]);
  $registry->getInstalledVersion('z_module')
    ->willReturn(8000);
  $extension_list = $this->prophesize(ModuleExtensionList::class);
  $extension_list->exists(Argument::any())
    ->willReturn(TRUE);
  $module_handler = $this->prophesize(ModuleHandlerInterface::class);
  $container = $this->prophesize(ContainerInterface::class);
  $container->get('extension.list.module')
    ->willReturn($extension_list->reveal());
  $container->get('update.update_hook_registry')
    ->willReturn($registry->reveal());
  $container->get('module_handler')
    ->willReturn($module_handler->reveal());
  \Drupal::setContainer($container->reveal());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.