You are here

class CheckboxTest in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/behat/mink/driver-testsuite/tests/Form/CheckboxTest.php \Behat\Mink\Tests\Driver\Form\CheckboxTest
  2. 8.0 core/modules/system/src/Tests/Form/CheckboxTest.php \Drupal\system\Tests\Form\CheckboxTest
Same name and namespace in other branches
  1. 8 vendor/behat/mink/driver-testsuite/tests/Form/CheckboxTest.php \Behat\Mink\Tests\Driver\Form\CheckboxTest

Hierarchy

  • class \Behat\Mink\Tests\Driver\TestCase extends \Behat\Mink\Tests\Driver\PHPUnit_Framework_TestCase

Expanded class hierarchy of CheckboxTest

File

vendor/behat/mink/driver-testsuite/tests/Form/CheckboxTest.php, line 7

Namespace

Behat\Mink\Tests\Driver\Form
View source
class CheckboxTest extends TestCase {
  public function testManipulate() {
    $this
      ->getSession()
      ->visit($this
      ->pathTo('advanced_form.html'));
    $checkbox = $this
      ->getAssertSession()
      ->fieldExists('agreement');
    $this
      ->assertNull($checkbox
      ->getValue());
    $this
      ->assertFalse($checkbox
      ->isChecked());
    $checkbox
      ->check();
    $this
      ->assertEquals('yes', $checkbox
      ->getValue());
    $this
      ->assertTrue($checkbox
      ->isChecked());
    $checkbox
      ->uncheck();
    $this
      ->assertNull($checkbox
      ->getValue());
    $this
      ->assertFalse($checkbox
      ->isChecked());
  }
  public function testSetValue() {
    $this
      ->getSession()
      ->visit($this
      ->pathTo('advanced_form.html'));
    $checkbox = $this
      ->getAssertSession()
      ->fieldExists('agreement');
    $this
      ->assertNull($checkbox
      ->getValue());
    $this
      ->assertFalse($checkbox
      ->isChecked());
    $checkbox
      ->setValue(true);
    $this
      ->assertEquals('yes', $checkbox
      ->getValue());
    $this
      ->assertTrue($checkbox
      ->isChecked());
    $checkbox
      ->setValue(false);
    $this
      ->assertNull($checkbox
      ->getValue());
    $this
      ->assertFalse($checkbox
      ->isChecked());
  }
  public function testCheckboxMultiple() {
    $this
      ->getSession()
      ->visit($this
      ->pathTo('/multicheckbox_form.html'));
    $webAssert = $this
      ->getAssertSession();
    $this
      ->assertEquals('Multicheckbox Test', $webAssert
      ->elementExists('css', 'h1')
      ->getText());
    $updateMail = $webAssert
      ->elementExists('css', '[name="mail_types[]"][value="update"]');
    $spamMail = $webAssert
      ->elementExists('css', '[name="mail_types[]"][value="spam"]');
    $this
      ->assertEquals('update', $updateMail
      ->getValue());
    $this
      ->assertNull($spamMail
      ->getValue());
    $this
      ->assertTrue($updateMail
      ->isChecked());
    $this
      ->assertFalse($spamMail
      ->isChecked());
    $updateMail
      ->uncheck();
    $this
      ->assertFalse($updateMail
      ->isChecked());
    $this
      ->assertFalse($spamMail
      ->isChecked());
    $spamMail
      ->check();
    $this
      ->assertFalse($updateMail
      ->isChecked());
    $this
      ->assertTrue($spamMail
      ->isChecked());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CheckboxTest::testCheckboxMultiple public function
CheckboxTest::testManipulate public function
CheckboxTest::testSetValue public function
TestCase::$config private static property
TestCase::$mink private static property Mink session manager.
TestCase::checkRequirements protected function
TestCase::createDriver protected function Creates a new driver instance.
TestCase::findById protected function
TestCase::getAssertSession protected function Returns assert session.
TestCase::getConfig private static function
TestCase::getSession protected function Returns session.
TestCase::mapRemoteFilePath protected function Map remote file path.
TestCase::onNotSuccessfulTest protected function
TestCase::pathTo protected function
TestCase::safePageWait protected function Waits for a condition to be true, considering than it is successful for drivers not supporting wait().
TestCase::setUpBeforeClass public static function Initializes the test case.
TestCase::tearDown protected function