View source
<?php
namespace Drupal\Tests\conditional_fields\FunctionalJavascript;
use Drupal\Tests\conditional_fields\FunctionalJavascript\TestCases\ConditionalFieldCheckedUncheckedInterface;
class ConditionalFieldCheckboxTest extends ConditionalFieldTestBase implements ConditionalFieldCheckedUncheckedInterface {
protected $screenshotPath = 'sites/simpletest/conditional_fields/checkbox/';
public function testVisibleChecked() {
$this
->baseTestSteps();
$this
->createCondition('body', 'promote', 'visible', 'checked');
$this
->drupalGet('admin/structure/conditional_fields/node/article');
$this
->assertSession()
->pageTextContains('body promote visible checked');
$this
->drupalGet('node/add/article');
$this
->waitUntilVisible('.field--name-body', 10, '01. Article Body field is not visible');
$this
->changeSelect('#edit-promote-value', FALSE);
$this
->waitUntilHidden('.field--name-body', 0, '02. Article Body field is visible');
}
public function testVisibleUnchecked() {
$this
->baseTestSteps();
$this
->createCondition('body', 'promote', 'visible', '!checked');
$this
->drupalGet('admin/structure/conditional_fields/node/article');
$this
->assertSession()
->pageTextContains('body promote visible !checked');
$this
->drupalGet('node/add/article');
$this
->waitUntilHidden('.field--name-body', 10, '01. Article Body field is visible');
$this
->changeSelect('#edit-promote-value', FALSE);
$this
->waitUntilVisible('.field--name-body', 0, '02. Article Body field is not visible');
}
public function testInvisibleChecked() {
$this
->baseTestSteps();
$this
->createCondition('body', 'promote', '!visible', 'checked');
$this
->drupalGet('admin/structure/conditional_fields/node/article');
$this
->assertSession()
->pageTextContains('body promote !visible checked');
$this
->drupalGet('node/add/article');
$this
->waitUntilHidden('.field--name-body', 10, '01. Article Body field is visible');
$this
->changeSelect('#edit-promote-value', FALSE);
$this
->waitUntilVisible('.field--name-body', 0, '02. Article Body field is not visible');
}
public function testInvisibleUnchecked() {
$this
->baseTestSteps();
$this
->createCondition('body', 'promote', '!visible', '!checked');
$this
->drupalGet('admin/structure/conditional_fields/node/article');
$this
->assertSession()
->pageTextContains('body promote !visible !checked');
$this
->drupalGet('node/add/article');
$this
->waitUntilVisible('.field--name-body', 10, '01. Article Body field is not visible');
$this
->changeSelect('#edit-promote-value', FALSE);
$this
->waitUntilHidden('.field--name-body', 0, '02. Article Body field is visible');
}
}