Skip to content
Snippets Groups Projects
Commit 03fdcd34 authored by Zoltan Attila Horvath's avatar Zoltan Attila Horvath
Browse files

Merge branch '3451923-drupal-11' into '1.0.x'

Issue #3451923: Add new contructor property to EmeSettingsForm

See merge request !4
parents 3e533fe0 e0ddc9a0
No related branches found
No related tags found
No related merge requests found
Pipeline #211680 passed
......@@ -5,6 +5,7 @@ namespace Drupal\eme\Form;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Entity\ContentEntityType;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
......@@ -18,24 +19,22 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class EmeSettingsForm extends ConfigFormBase {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs an Entity Export settings form.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* The factory for configuration objects.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
* @param \Drupal\Core\Config\TypedConfigManagerInterface $typedConfigManager
* The typed config manager.
*/
public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($config_factory);
$this->entityTypeManager = $entity_type_manager;
public function __construct(
ConfigFactoryInterface $configFactory,
protected EntityTypeManagerInterface $entityTypeManager,
TypedConfigManagerInterface $typedConfigManager,
) {
parent::__construct($configFactory, $typedConfigManager);
}
/**
......@@ -44,7 +43,8 @@ class EmeSettingsForm extends ConfigFormBase {
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('entity_type.manager')
$container->get('entity_type.manager'),
$container->get('config.typed'),
);
}
......
......@@ -58,7 +58,7 @@ class MenuLinkContentTest extends KernelTestBase {
]);
$this->entity->save();
// Create an another test entity.
// Create another test entity.
EntityTest::create([
'id' => 2,
'uid' => $uid,
......@@ -88,7 +88,7 @@ class MenuLinkContentTest extends KernelTestBase {
);
$actual_matching_menu_link_uris = array_map(function (MenuLinkContentInterface $menu_link) {
return $menu_link->link->first()->uri;
return $menu_link->link->first()->getValue()['uri'] ?? NULL;
}, $plugin->fetchReverseReferences($this->entity));
sort($expected_matching_uris);
......@@ -103,20 +103,20 @@ class MenuLinkContentTest extends KernelTestBase {
* @return array
* The test cases.
*/
public function providerTestFetchReverseReferences(): array {
public static function providerTestFetchReverseReferences(): array {
return [
'No menu links' => [
'Links' => [],
'Expected' => [],
'link_uris' => [],
'expected_matching_uris' => [],
],
'Menu links for test entity' => [
'Links' => [
'link_uris' => [
'internal:/entity_test/1',
'entity:entity_test/1',
'internal:/entity_test/1',
'route:entity.entity_test.canonical;entity_test=1',
],
'Expected' => [
'expected_matching_uris' => [
'entity:entity_test/1',
'internal:/entity_test/1',
'internal:/entity_test/1',
......@@ -124,21 +124,21 @@ class MenuLinkContentTest extends KernelTestBase {
],
],
'Menu links for other test entity' => [
'Links' => [
'link_uris' => [
'entity:entity_test/2',
'internal:/entity_test/2',
'base:entity_test/2',
'route:entity.entity_test.canonical;entity_test=2',
],
'Expected' => [],
'expected_matching_uris' => [],
],
'Menu links for test entity and for other entities' => [
'Links' => [
'link_uris' => [
'entity:entity_test/1',
'internal:/entity_test/2',
'base:entity_test/2',
],
'Expected' => [
'expected_matching_uris' => [
'entity:entity_test/1',
],
],
......
......@@ -96,38 +96,38 @@ class PathAliasTest extends KernelTestBase {
* @return array
* The test cases.
*/
public function providerTestFetchReferences(): array {
public static function providerTestFetchReferences(): array {
return [
'No aliases' => [
'Source aliases' => [],
'Expected aliases' => [],
'source_aliases' => [],
'expected_aliases' => [],
],
'Path aliases for test entity' => [
'Source aliases' => [
'source_aliases' => [
['path' => '/entity_test/1', 'alias' => '/an-alias'],
['path' => '/entity_test/1', 'alias' => '/an/another/alias'],
],
'Expected aliases' => [
'expected_aliases' => [
['path' => '/entity_test/1', 'alias' => '/an-alias'],
['path' => '/entity_test/1', 'alias' => '/an/another/alias'],
],
],
'Unrelated aliases for other test entity' => [
'Source aliases' => [
'source_aliases' => [
['path' => '/entity_test/2', 'alias' => '/an-unrelated-alias'],
['path' => '/user/1', 'alias' => '/root-user'],
],
'Expected aliases' => [],
'expected_aliases' => [],
],
'Aliases for the test entity and for other entities' => [
'Source aliases' => [
'source_aliases' => [
['path' => '/entity_test/2', 'alias' => '/an-unrelated-alias'],
['path' => '/entity_test/1', 'alias' => '/an-alias'],
['path' => '/user/1', 'alias' => '/root-user'],
['path' => '/user/login', 'alias' => '/not-an-entity-alias'],
['path' => '/entity_test/1', 'alias' => '/an/another/alias'],
],
'Expected aliases' => [
'expected_aliases' => [
['path' => '/entity_test/1', 'alias' => '/an-alias'],
['path' => '/entity_test/1', 'alias' => '/an/another/alias'],
],
......
......@@ -91,17 +91,17 @@ class DiscoveryPluginManagerTest extends UnitTestCase {
* @return array
* The test cases.
*/
public function providerTestGetReferencePlugins() {
public static function providerTestGetReferencePlugins() {
return [
'No plugins' => [
'Cached definitions' => [],
'Expected results' => [
'cached_plugins' => [],
'expected_results' => [
'direct' => [],
'reverse' => [],
],
],
'Only direct plugins' => [
'Cached definitions' => [
'cached_plugins' => [
'direct_2' => [
'id' => 'direct_2',
'class' => DummyDirectReferencePlugin::class,
......@@ -111,7 +111,7 @@ class DiscoveryPluginManagerTest extends UnitTestCase {
'class' => DummyDirectReferencePlugin::class,
],
],
'Expected results' => [
'expected_results' => [
'direct' => [
'direct_1' => new DummyDirectReferencePlugin([], 'direct_1', [
'id' => 'direct_1',
......@@ -126,7 +126,7 @@ class DiscoveryPluginManagerTest extends UnitTestCase {
],
],
'Direct and reverse plugins' => [
'Cached definitions' => [
'cached_plugins' => [
'direct' => [
'id' => 'direct',
'class' => DummyDirectReferencePlugin::class,
......@@ -140,7 +140,7 @@ class DiscoveryPluginManagerTest extends UnitTestCase {
'class' => DummyAllReferencePlugin::class,
],
],
'Expected results' => [
'expected_results' => [
'direct' => [
'direct' => new DummyDirectReferencePlugin([], 'direct', [
'id' => 'direct',
......@@ -164,7 +164,7 @@ class DiscoveryPluginManagerTest extends UnitTestCase {
],
],
'Only reverse plugins' => [
'Cached definitions' => [
'cached_plugins' => [
'reverse_1' => [
'id' => 'reverse_1',
'class' => DummyReverseReferencePlugin::class,
......@@ -174,7 +174,7 @@ class DiscoveryPluginManagerTest extends UnitTestCase {
'class' => DummyReverseReferencePlugin::class,
],
],
'Expected results' => [
'expected_results' => [
'direct' => [],
'reverse' => [
'reverse_1' => new DummyReverseReferencePlugin([], 'reverse_1', [
......
......@@ -61,29 +61,29 @@ class EntityReferenceTest extends UnitTestCase {
* @return array
* The test cases.
*/
public function providerTestFetchReferences(): array {
public static function providerTestFetchReferences(): array {
return [
'No fields' => [
'Fields' => [],
'Expected number of referenced content entities' => 0,
'fields' => [],
'expected_number_of_entities' => 0,
],
'Unrelated fields' => [
'Fields' => [
'fields' => [
'field_unrelated1' => 'neutral',
'field_config_reference' => 'config',
'field_unrelated2' => 'neutral',
],
'Expected number of referenced content entities' => 0,
'expected_number_of_entities' => 0,
],
'Fields with content references' => [
'Fields' => [
'fields' => [
'field_unrelated1' => 'neutral',
'field_content_ref_1' => 'content',
'field_config_reference' => 'config',
'field_unrelated2' => 'neutral',
'field_content_ref_2' => 'content',
],
'Expected number of referenced content entities' => 2,
'expected_number_of_entities' => 2,
],
];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment