setValue example

$this->drupalLogin($this->drupalCreateUser([
      'administer site configuration',
    ]));

    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    $this->drupalGet('admin/structure/config_test/add');
    // Test that 'size value' field is not show initially, and it is show after     // selecting value in the 'size' field.     $this->assertNull($page->findField('size_value'));
    $page->findField('size')->setValue('custom');
    $this->assertNotNull($assert_session->waitForField('size_value'));
  }

}
$this->expectException(Exception::class);
    $this->drupalGet('/js_interaction_test');
    $this->assertSession()->elementExists('named', ['link', 'Target link'])->click();
  }

  /** * Assert an exception is thrown when the field is never enabled. */
  public function testFieldValueNotSettable() {
    $this->expectException(Exception::class);
    $this->drupalGet('/js_interaction_test');
    $this->assertSession()->fieldExists('target_field')->setValue('Test');
  }

  /** * Assert no exception is thrown when elements become interactive. */
  public function testElementsInteraction() {
    $this->drupalGet('/js_interaction_test');
    // Remove blocking element after 100 ms.     $this->clickLink('Remove Blocker Trigger');
    $this->clickLink('Target link');

    

    public function testPayloadStructureBasic(): void
    {
        $builder = new PromotionItemBuilder();

        $discount = new PromotionDiscountEntity();
        $discount->setId('D5');
        $discount->setType(PromotionDiscountEntity::TYPE_ABSOLUTE);
        $discount->setValue(50);
        $discount->setConsiderAdvancedRules(true);
        $discount->setScope(PromotionDiscountEntity::SCOPE_CART);

        $currencyFactor = 0.3;

        $ruleCollection = new RuleCollection();
        $discount->setDiscountRules($ruleCollection);

        $item = $builder->buildDiscountLineItem('my-Code-123', $this->promotion, $discount, 'C1', $currencyFactor);

        $expected = [
            
    $this->assertNotEmpty($assert_session->waitForElement('css', '.ckeditor5-toolbar-item-sourceEditing'));
    $this->triggerKeyUp('.ckeditor5-toolbar-item-sourceEditing', 'ArrowDown');
    $assert_session->assertWaitOnAjaxRequest();

    // Updating Source Editing's editable tags should automatically update     // filter_html to include those additional tags.     $assert_session->waitForText('Source editing');
    $page->find('css', '[href^="#edit-editor-settings-plugins-ckeditor5-sourceediting"]')->click();
    $assert_session->assertWaitOnAjaxRequest();
    $assert_session->waitForText('Manually editable HTML tags');
    $source_edit_tags_field = $assert_session->fieldExists('editor[settings][plugins][ckeditor5_sourceEditing][allowed_tags]');
    $source_edit_tags_field->setValue('<aside>');
    $assert_session->assertWaitOnAjaxRequest();

    $this->assertHtmlEsqueFieldValueEquals('filters[filter_html][settings][allowed_html]', '<br> <p> <h2> <h3> <h4> <h5> <h6> <aside> <strong> <em> <blockquote>');
    $allowed_html_field = $assert_session->fieldExists('filters[filter_html][settings][allowed_html]');
    $this->assertTrue($allowed_html_field->hasAttribute('readonly'));

    // Adding tags to Source Editing's editable tags that are already supported     // by enabled CKEditor 5 plugins must trigger a validation error, and that     // error must be associated with the correct form item.     $source_edit_tags_field->setValue('<aside><strong>');
    $assert_session->waitForText('The following tag(s) are already supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: Bold (<strong>)');
    
$line_numbers = array_keys($unparseable_lines);
      $form_state->setError($form['styles']$this->formatPlural(
        count($unparseable_lines),
        'Line @line-number does not contain a valid value. Enter a valid CSS selector containing one or more classes, followed by a pipe symbol and a label.',
        'Lines @line-numbers do not contain a valid value. Enter a valid CSS selector containing one or more classes, followed by a pipe symbol and a label.',
        [
          '@line-number' => reset($line_numbers),
          '@line-numbers' => implode(', ', $line_numbers),
        ]
      ));
    }
    $form_state->setValue('styles', $styles);
  }

  /** * Parses the line-based (for form) style configuration. * * @param string $form_value * A string containing >=1 lines with on each line a CSS selector targeting * 1 tag with >=1 classes, a pipe symbol and a label. An example of a single * line: `p.foo.bar|Foo bar paragraph`. * * @return array * The parsed equivalent: a list of arrays with each containing: * - label: the label after the pipe symbol, with whitespace trimmed * - element: the CKEditor 5 element equivalent of the tag + classes * * @internal * This method is public only to allow the CKEditor 4 to 5 upgrade path to * reuse this logic. Mark this private in https://www.drupal.org/i/3239012. * * @see \Drupal\ckeditor5\Plugin\CKEditor4To5Upgrade\Core::mapCKEditor4SettingsToCKEditor5Configuration() */

    }

    public function __construct(BufferingLogger $bootstrappingLogger = null, bool $debug = false)
    {
        if ($bootstrappingLogger) {
            $this->bootstrappingLogger = $bootstrappingLogger;
            $this->setDefaultLogger($bootstrappingLogger);
        }
        $traceReflector = new \ReflectionProperty(\Exception::class, 'trace');
        $this->configureException = \Closure::bind(static function D$e$trace$file = null, $line = null) use ($traceReflector) {
            $traceReflector->setValue($e$trace);
            $e->file = $file ?? $e->file;
            $e->line = $line ?? $e->line;
        }, null, new class() extends \Exception {
        });
        $this->debug = $debug;
    }

    /** * Sets a logger to non assigned errors levels. * * @param LoggerInterface $logger A PSR-3 logger to put as default for the given levels * @param array|int|null $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants * @param bool $replace Whether to replace or not any existing logger */
'#default_value' => $this->options['formats'],
    ];
  }

  /** * {@inheritdoc} */
  public function submitOptionsForm(&$form, FormStateInterface $form_state) {
    parent::submitOptionsForm($form$form_state);

    $formats = $form_state->getValue(['style_options', 'formats']);
    $form_state->setValue(['style_options', 'formats']array_filter($formats));
  }

  /** * {@inheritdoc} */
  public function render() {
    $rows = [];
    // If the Data Entity row plugin is used, this will be an array of entities     // which will pass through Serializer to one of the registered Normalizers,     // which will transform it to arrays/scalars. If the Data field row plugin     // is used, $rows will not contain objects and will pass directly to the

    public static function setPrivateProperty($obj$property$value)
    {
        $refProperty = self::getAccessibleRefProperty($obj$property);
        $refProperty->setValue($obj$value);
    }

    /** * Retrieve a private property. * * @param object|string $obj object or class name * @param string $property property name * * @return mixed value * * @throws ReflectionException */

  protected static function createEphemeralPairedEditor(EditorInterface $editor, FilterFormatInterface $filter_format): EditorInterface {
    $paired_editor = clone $editor;
    // If the editor is still being configured, the configuration may not yet be     // valid. Explicitly mark the ephemeral paired editor as new to allow other     // code to treat this accordingly.     // @see \Drupal\ckeditor5\Plugin\CKEditor5PluginManager::getProvidedElements()     $paired_editor->enforceIsNew(TRUE);
    $reflector = new \ReflectionObject($paired_editor);
    $property = $reflector->getProperty('filterFormat');
    $property->setValue($paired_editorclone $filter_format);
    return $paired_editor;
  }

  /** * Maps Text Editor config object property paths to form names. * * @param string $property_path * A config object property path. * @param array $subform * The subform being checked. * * @return string * The corresponding form name in the subform. */
/** * {@inheritdoc} */
  public function create(DataDefinitionInterface $definition$value = NULL, $name = NULL, $parent = NULL) {
    $typed_data = $this->createInstance($definition->getDataType()[
      'data_definition' => $definition,
      'name' => $name,
      'parent' => $parent,
    ]);
    if (isset($value)) {
      $typed_data->setValue($value, FALSE);
    }
    return $typed_data;
  }

  /** * {@inheritdoc} */
  public function createDataDefinition($data_type) {
    $type_definition = $this->getDefinition($data_type);
    if (!isset($type_definition)) {
      throw new \InvalidArgumentException("Invalid data type '$data_type' has been given");
    }
/** * {@inheritdoc} */
  public function setValue($values$notify = TRUE) {
    // Treat the values as property value of the first property, if no array is     // given.     if (isset($values) && !is_array($values)) {
      $keys = array_keys($this->definition->getPropertyDefinitions());
      $values = [$keys[0] => $values];
    }
    parent::setValue($values$notify);
  }

  /** * {@inheritdoc} * * Different to the parent Map class, we avoid creating property objects as * far as possible in order to optimize performance. Thus we just update * $this->values if no property object has been created yet. */
  protected function writePropertyValue($property_name$value) {
    // For defined properties there is either a property object or a plain
$web_assert->waitForField('options[group_info][group_items][4][title]');

    // A new items was added, weight options should now be -4 to 4.     $this->assertEmpty($weight->find('named', ['option', -5]));
    foreach (range(-4, 4) as $value) {
      $this->assertNotEmpty($weight->find('named', ['option', $value]));
    }
    $this->assertEmpty($weight->find('named', ['option', 5]));

    // Set the date value to a zero value and make sure it's stored.     $between_from = $page->findField('options[group_info][group_items][1][value][min]');
    $between_from->setValue('0');
    $apply_button = $page->find('css', '.views-ui-dialog button.button--primary');
    $this->assertNotEmpty($apply_button);
    $apply_button->press();
    $web_assert->assertWaitOnAjaxRequest();

    // Open the dialog for the grouped filter.     $page->clickLink('Content: Authored on (grouped)');
    $web_assert->assertWaitOnAjaxRequest();

    // Test that the 'min' field is shown and that it contains the right value.     $between_from = $page->findField('options[group_info][group_items][1][value][min]');
    

  }

  protected function valueValidate($form, FormStateInterface $form_state) {
    $uids = [];
    if ($values = $form_state->getValue(['options', 'value'])) {
      foreach ($values as $value) {
        $uids[] = $value['target_id'];
      }
      sort($uids);
    }
    $form_state->setValue(['options', 'value']$uids);
  }

  public function acceptExposedInput($input) {
    $rc = parent::acceptExposedInput($input);

    if ($rc) {
      // If we have previously validated input, override.       if (isset($this->validated_exposed_input)) {
        $this->value = $this->validated_exposed_input;
      }
    }

    
'path_info' => '/detail/87a78cf58f114d5587ae23c140825694',
                'seo_path_info' => 'Test',
                'is_canonical' => 1,
                'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
            ]
        );

        $request = Request::create('http://base.test' . $virtualUrl . '/detail/87a78cf58f114d5587ae23c140825694');
        $ref = new \ReflectionClass($request);
        $prob = $ref->getProperty('baseUrl');
        $prob->setAccessible(true);
        $prob->setValue($request$baseUrl);

        $resolved = $this->requestTransformer->transform($request);

        static::assertSame('http://base.test' . $resolvedUrl$resolved->attributes->get(SalesChannelRequest::ATTRIBUTE_CANONICAL_LINK));
    }

    /** * @return array<string, string[]> */
    public static function seoRedirectProvider(): iterable
    {
        
$this->csrfToken->expects($this->any())
        ->method('get')
        ->willReturnArgument(0);
      $this->csrfToken->expects($this->atLeastOnce())
        ->method('validate')
        ->willReturn($valid_token);
    }

    $current_user = $this->prophesize(AccountInterface::class);
    $current_user->isAuthenticated()->willReturn($user_is_authenticated);
    $property = new \ReflectionProperty(FormBuilder::class, 'currentUser');
    $property->setValue($this->formBuilder, $current_user->reveal());

    $expected_form = $form_id();
    $form_arg = $this->getMockForm($form_id$expected_form);

    // Set up some request data so we can be sure it is removed when a token is     // invalid.     $this->request->request->set('foo', 'bar');
    $_POST['foo'] = 'bar';

    $form_state = new FormState();
    $input['form_id'] = $form_id;
    
Home | Imprint | This part of the site doesn't use cookies.