module_set_weight example

/** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->setUpCurrentUser(['uid' => 0]);
    $this->installEntitySchema('menu_link_content');

    // Ensure that the weight of module_link_content is higher than system.     // @see menu_link_content_install()     module_set_weight('menu_link_content', 1);
  }

  /** * Tests bubbleable metadata of menu links' outbound route/path processing. */
  public function testOutboundPathAndRouteProcessing() {
    $request_stack = \Drupal::requestStack();
    /** @var \Symfony\Component\Routing\RequestContext $request_context */
    $request_context = \Drupal::service('router.request_context');

    $request = Request::create('/');
    

  protected function setUp(): void {
    parent::setUp();

    $this->installEntitySchema('user');
    $this->installEntitySchema('menu_link_content');
    $this->installEntitySchema('path_alias');

    // Ensure that the weight of module_link_content is higher than system.     // @see menu_link_content_install()     module_set_weight('menu_link_content', 1);
  }

  /** * {@inheritdoc} */
  public function register(ContainerBuilder $container) {
    parent::register($container);

    $definition = $container->getDefinition('path_alias.path_processor');
    $definition
      ->addTag('path_processor_inbound', ['priority' => 100]);
  }
$this->installSchema('node', ['node_access']);
    $this->installConfig(['node']);

    // Create a node type for testing.     $type = NodeType::create(['type' => 'page', 'name' => 'page']);
    $type->save();

    // Set editor_test module weight to be lower than editor module's weight so     // that editor_test_entity_update() is called before editor_entity_update().     $extension_config = \Drupal::configFactory()->get('core.extension');
    $editor_module_weight = $extension_config->get('module.editor');
    module_set_weight('editor_test', $editor_module_weight - 1);
  }

  /** * Tests updating an existing entity. * * @see editor_test_entity_update() */
  public function testEntityUpdate() {
    // Create a node.     $node = Node::create([
      'type' => 'page',
      

    sort($module_list);
    $this->assertModuleList($module_list, 'Initial');

    // Try to install a new module.     $this->moduleInstaller()->install(['ban']);
    $module_list[] = 'ban';
    sort($module_list);
    $this->assertModuleList($module_list, 'After adding a module');

    // Try to mess with the module weights.     module_set_weight('ban', 20);

    // Move ban to the end of the array.     unset($module_list[array_search('ban', $module_list)]);
    $module_list[] = 'ban';
    $this->assertModuleList($module_list, 'After changing weights');

    // Test the fixed list feature.     $fixed_list = [
      'system' => 'core/modules/system/system.module',
      'menu' => 'core/modules/menu/menu.module',
    ];
    
Home | Imprint | This part of the site doesn't use cookies.