hiddenFieldValueNotEquals example

// Ensure the hidden 'form_build_id' field is unique.     $this->assertSession()->elementsCount('xpath', '//input[@name="form_build_id"]', 1);

    $buildId = $this->assertSession()->hiddenFieldExists('form_build_id')->getValue();

    // Trigger validation error by submitting an empty title.     $edit = ['title' => ''];
    $this->submitForm($edit, 'Continue submit');

    // Verify that the build-id did change.     $this->assertSession()->hiddenFieldValueNotEquals('form_build_id', $buildId);

    // Ensure the hidden 'form_build_id' field is unique.     $this->assertSession()->elementsCount('xpath', '//input[@name="form_build_id"]', 1);

    // Retrieve the new build-id.     $buildId = (string) $this->assertSession()->hiddenFieldExists('form_build_id')->getValue();

    // Trigger validation error by again submitting an empty title.     $edit = ['title' => ''];
    $this->submitForm($edit, 'Continue submit');

    
    $this->drupalGet('form-test/object-builder');
    $this->assertSession()->statusCodeEquals(200);

    // Ensure the form and text field exist.     $this->assertSession()->elementExists('css', 'form#form-test-form-test-object');
    $this->assertSession()->fieldExists('bananas');

    // Check that the hidden field exists and has a specific value.     $this->assertSession()->hiddenFieldExists('strawberry');
    $this->assertSession()->hiddenFieldExists('red');
    $this->assertSession()->hiddenFieldExists('redstrawberryhiddenfield');
    $this->assertSession()->hiddenFieldValueNotEquals('strawberry', 'brown');
    $this->assertSession()->hiddenFieldValueEquals('strawberry', 'red');

    // Check that a hidden field does not exist.     $this->assertSession()->hiddenFieldNotExists('bananas');
    $this->assertSession()->hiddenFieldNotExists('pineapple');

    $edit = ['bananas' => 'green'];
    $this->submitForm($edit, 'Save', 'form-test-form-test-object');

    $config_factory = $this->container->get('config.factory');
    $value = $config_factory->get('form_test.object')->get('bananas');
    
Home | Imprint | This part of the site doesn't use cookies.