WebDriverTestBaseTest.php

Same filename and directory in other branches
  1. 10 core/tests/Drupal/Tests/Core/Test/WebDriverTestBaseTest.php

Namespace

Drupal\Tests\Core\Test

File

core/tests/Drupal/Tests/Core/Test/WebDriverTestBaseTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\Core\Test;

use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PHPUnit\Framework\Attributes\TestWith;

/**
 * Tests Drupal\FunctionalJavascriptTests\WebDriverTestBase.
 */
class WebDriverTestBaseTest extends UnitTestCase {
  
  /**
   * Tests W3C setting is added to goog:chromeOptions as expected.
   *
   * @legacy-covers ::getMinkDriverArgs
   */
  public function testCapabilities($expected, ?string $mink_driver_args_webdriver, ?string $mink_driver_args = NULL) : void {
    $this->putEnv("MINK_DRIVER_ARGS_WEBDRIVER", $mink_driver_args_webdriver);
    $this->putEnv("MINK_DRIVER_ARGS", $mink_driver_args);
    $object = new class ('test') extends WebDriverTestBase {

};
    $method = new \ReflectionMethod($object, 'getMinkDriverArgs');
    $this->assertSame($expected, $method->invoke($object));
  }
  
  /**
   * Sets or deletes an environment variable.
   *
   * @param string $variable
   *   The environment variable to set or delete.
   * @param string|null $value
   *   The value to set the variable to. If the value is NULL then the
   *   environment variable will be unset.
   *
   * @return void
   *   No return value.
   */
  private function putEnv(string $variable, ?string $value) : void {
    if (is_string($value)) {
      putenv($variable . "=" . $value);
    }
    else {
      putenv($variable);
    }
  }

}

Classes

Title Deprecated Summary
WebDriverTestBaseTest Tests Drupal\FunctionalJavascriptTests\WebDriverTestBase.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.