Skip to content
Snippets Groups Projects
Commit bc06fee4 authored by sarwan verma's avatar sarwan verma Committed by Tim Diels
Browse files

Issue #3482380 by tim-diels, biarr: Getting Error: "Too few arguments to function"

parent 53517f20
Branches
Tags
1 merge request!18Fixed arguments to function issue
Pipeline #468581 failed
################
# DrupalCI GitLabCI template
# GitLabCI template for Drupal projects.
#
# Gitlab-ci.yml to replicate DrupalCI testing for Contrib
#
# With thanks to:
# * The GitLab Acceleration Initiative participants
# * DrupalSpoons
################
################
# Guidelines
#
# This template is designed to give any Contrib maintainer everything they need to test, without requiring modification. It is also designed to keep up to date with Core Development automatically through the use of include files that can be centrally maintained.
#
# However, you can modify this template if you have additional needs for your project.
################
################
# Includes
#
# Additional configuration can be provided through includes.
# One advantage of include files is that if they are updated upstream, the changes affect all pipelines using that include.
#
# Includes can be overridden by re-declaring anything provided in an include, here in gitlab-ci.yml
# https://docs.gitlab.com/ee/ci/yaml/includes.html#override-included-configuration-values
# This template is designed to give any Contrib maintainer everything they need to test, without requiring modification.
# It is also designed to keep up to date with Core Development automatically through the use of include files that can be centrally maintained.
# As long as you include the project, ref and three files below, any future updates added by the Drupal Association will be used in your
# pipelines automatically. However, you can modify this template if you have additional needs for your project.
# The full documentation is on https://project.pages.drupalcode.org/gitlab_templates/
################
# For information on alternative values for 'ref' see https://project.pages.drupalcode.org/gitlab_templates/info/templates-version/
# To test a Drupal 7 project, change the first include filename from .main.yml to .main-d7.yml
include:
################
# DrupalCI includes:
# As long as you include this, any future includes added by the Drupal Association will be accessible to your pipelines automatically.
# View these include files at https://git.drupalcode.org/project/gitlab_templates/
################
- project: $_GITLAB_TEMPLATES_REPO
# "ref" value can be:
# - Recommended (default) - `ref: $_GITLAB_TEMPLATES_REF` - The Drupal Association will update this value to the recommended tag for contrib.
# - Latest - `ref: main` - Get the latest additions and bug fixes as they are merged into the templates.
# - Minor or Major latests - `ref: 1.x-latest` or `ref: 1.0.x-latest` - Get the latest additions within a minor (mostly bugfixes) or major (bugs and new features).
# - Fixed tag - `ref: 1.0.1` - Set the value to a known tag. This will not get any updates.
# If you change the default value of ref, you should set the _CURL_TEMPLATES_REF variable in the variables section to be the same as set here.
ref: $_GITLAB_TEMPLATES_REF
file:
- "/includes/include.drupalci.main.yml"
# For Drupal 7, remove the above line and uncomment the below.
# - "/includes/include.drupalci.main-d7.yml"
- "/includes/include.drupalci.variables.yml"
- "/includes/include.drupalci.workflows.yml"
- '/includes/include.drupalci.main.yml'
- '/includes/include.drupalci.variables.yml'
- '/includes/include.drupalci.workflows.yml'
#
################
# Pipeline configuration variables
#
# These are the variables provided to the Run Pipeline form that a user may want to override.
#
# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/main/includes/include.drupalci.variables.yml
# Pipeline configuration variables are defined with default values and descriptions in the file
# https://git.drupalcode.org/project/gitlab_templates/-/blob/main/includes/include.drupalci.variables.yml
# Uncomment the lines below if you want to override any of the variables. The following is just an example.
################
variables:
_TARGET_DRUPAL: 11.0
_TARGET_PHP: 8.3
OPT_IN_TEST_CURRENT: 1
OPT_IN_TEST_PREVIOUS_MAJOR: 1
OPT_IN_TEST_PREVIOUS_MINOR: 1
OPT_IN_TEST_NEXT_MINOR: 1
OPT_IN_TEST_NEXT_MAJOR: 1
OPT_IN_TEST_MAX_PHP: 1
_CSPELL_WORDS: 'idmenu'
# SKIP_ESLINT: '1'
# OPT_IN_TEST_NEXT_MAJOR: '1'
# _CURL_TEMPLATES_REF: 'main'
###################################################################################
#
# *
# /(
# ((((,
# /(((((((
# ((((((((((*
# ,(((((((((((((((
# ,(((((((((((((((((((
# ((((((((((((((((((((((((*
# *(((((((((((((((((((((((((((((
# ((((((((((((((((((((((((((((((((((*
# *(((((((((((((((((( .((((((((((((((((((
# ((((((((((((((((((. /(((((((((((((((((*
# /((((((((((((((((( .(((((((((((((((((,
# ,(((((((((((((((((( ((((((((((((((((((
# .(((((((((((((((((((( .(((((((((((((((((
# ((((((((((((((((((((((( ((((((((((((((((/
# (((((((((((((((((((((((((((/ ,(((((((((((((((*
# .((((((((((((((/ /(((((((((((((. ,(((((((((((((((
# *(((((((((((((( ,(((((((((((((/ *((((((((((((((.
# ((((((((((((((, /(((((((((((((. ((((((((((((((,
# (((((((((((((/ ,(((((((((((((* ,(((((((((((((,
# *((((((((((((( .((((((((((((((( ,(((((((((((((
# ((((((((((((/ /((((((((((((((((((. ,((((((((((((/
# ((((((((((((( *(((((((((((((((((((((((* *((((((((((((
# ((((((((((((( ,(((((((((((((..((((((((((((( *((((((((((((
# ((((((((((((, /((((((((((((* /((((((((((((/ ((((((((((((
# ((((((((((((( /((((((((((((/ (((((((((((((* ((((((((((((
# (((((((((((((/ /(((((((((((( ,((((((((((((, *((((((((((((
# (((((((((((((( *(((((((((((/ *((((((((((((. ((((((((((((/
# *((((((((((((((((((((((((((, /(((((((((((((((((((((((((
# ((((((((((((((((((((((((( ((((((((((((((((((((((((,
# .(((((((((((((((((((((((/ ,(((((((((((((((((((((((
# ((((((((((((((((((((((/ ,(((((((((((((((((((((/
# *((((((((((((((((((((( (((((((((((((((((((((,
# ,(((((((((((((((((((((, ((((((((((((((((((((/
# ,(((((((((((((((((((((* /((((((((((((((((((((
# ((((((((((((((((((((((, ,/((((((((((((((((((((,
# ,(((((((((((((((((((((((((((((((((((((((((((((((((((
# .(((((((((((((((((((((((((((((((((((((((((((((
# .((((((((((((((((((((((((((((((((((((,.
# .,(((((((((((((((((((((((((.
#
###################################################################################
......@@ -3,7 +3,7 @@ description: 'Domain-based access control for menu link.'
package: Domain
type: module
core_version_requirement: ^9 || ^10 || ^11
core_version_requirement: ^10.2 || ^11
dependencies:
- domain:domain
- domain:domain_access
......
......@@ -3,7 +3,8 @@
namespace Drupal\domain_menu_access\Form;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -27,12 +28,17 @@ class DomainMenuAccessSettingsForm extends ConfigFormBase {
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
* @param \Drupal\Core\Entity\EntityStorageInterface $menu_storage
* The menu storage.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config_manager
* The typed configuration manager.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function __construct(ConfigFactoryInterface $config_factory, EntityStorageInterface $menu_storage) {
parent::__construct($config_factory);
$this->menuStorage = $menu_storage;
public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, TypedConfigManagerInterface $typed_config_manager) {
parent::__construct($config_factory, $typed_config_manager);
$this->menuStorage = $entity_type_manager->getStorage('menu');
}
/**
......@@ -41,7 +47,8 @@ class DomainMenuAccessSettingsForm extends ConfigFormBase {
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('entity_type.manager')->getStorage('menu')
$container->get('entity_type.manager'),
$container->get('config.typed')
);
}
......@@ -80,7 +87,7 @@ class DomainMenuAccessSettingsForm extends ConfigFormBase {
$form[$key] = [
'#type' => 'checkbox',
'#title' => $item->label(),
'#default_value' => is_array($config) ? in_array($key, $config, TRUE) ? '1' : '' : '',
'#default_value' => is_array($config) ? (in_array($key, $config, TRUE) ? '1' : '') : '',
'#description' => $item->getDescription(),
];
}
......
......@@ -56,7 +56,7 @@ class DomainMenuAccessInstallTest extends BrowserTestBase {
$this->configFactory = $this->container->get('config.factory');
$this->domainStorage = $this->container->get('entity_type.manager')->getStorage('domain');
$this->domainCreateTestDomains(1, 'example');
$this->domainCreateTestDomains();
}
/**
......
<?php
namespace Drupal\Tests\domain_menu_access\Functional;
use Drupal\Tests\domain\Functional\DomainTestBase;
use Drupal\Tests\domain\Traits\DomainTestTrait;
use Drupal\Tests\domain_menu_access\Traits\DomainMenuAccessTestTrait;
/**
* Tests the domain menu access user interface.
*
* @group domain_menu_access
*/
class DomainMenuAccessPermissionsTest extends DomainTestBase {
use DomainTestTrait;
use DomainMenuAccessTestTrait;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'menu_link_content',
'domain',
'domain_access',
'domain_menu_access',
];
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->createAdminUser();
$this->createEditorUser();
$this->domainCreateTestDomains();
}
/**
* Tests access to the settings form.
*/
public function testSettingsAccess() {
$path = $this->configFormPath;
// Visit the domain menu access administration page as admin.
$this->drupalLogin($this->adminUser);
$this->drupalGet($path);
$this->assertSession()->statusCodeEquals(200);
// Visit the domain menu access administration page as editor.
$this->drupalLogin($this->editorUser);
$this->drupalGet($path);
$this->assertSession()->statusCodeEquals(403);
}
}
<?php
namespace Drupal\Tests\domain_menu_access\Traits;
use Drupal\Core\Session\AccountInterface;
/**
* Contains helper classes for tests to set up various configuration.
*/
trait DomainMenuAccessTestTrait {
/**
* The path to the config form.
*
* @var string
*/
protected string $configFormPath = '/admin/config/domain/domain_menu_access/config';
/**
* A user with full permissions to use the module.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected AccountInterface $adminUser;
/**
* A user with administration access but not this module.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected AccountInterface $editorUser;
/**
* Create an admin user.
*/
public function createAdminUser() {
$this->adminUser = $this->drupalCreateUser([
'access administration pages',
'access content',
'administer domains',
'administer site configuration',
]);
}
/**
* Create an editor user.
*/
public function createEditorUser() {
$this->editorUser = $this->drupalCreateUser([
'access administration pages',
'access content',
'administer site configuration',
]);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment