PHP Class VersionPress\Tests\Selenium\SeleniumTestCase

Inheritance: extends PHPUnit_Extensions_Selenium2TestCas\PHPUnit_Extensions_Selenium2TestCase
ファイルを表示 Open project: versionpress/versionpress Class Usage Examples

Protected Properties

Property Type Description
$autologin boolean If true, {@link loginIfNecessary} is called on {@link setUpSite}.
$gitRepository VersionPress\Git\GitRepository
$testConfig VersionPress\Tests\Utils\TestConfig
$wpAdminPath string
$wpAutomation VersionPress\Tests\Automation\WpAutomation

Public Methods

Method Description
__construct ( $name = null, array $data = [], $dataName = '' )
setUpBeforeClass ( )
setUpPage ( )
setUpSite ( boolean $force ) Check if site is set up and VersionPress fully activated, and if not, do so. The $force parametr may force this.

Protected Methods

Method Description
assertElementExists ( string $cssSelector ) Asserts that element exists.
elementExists ( $cssSelector )
executeScript ( string $code ) : string Small wrapper aroung built-in execute() method
jsClick ( string $cssSelector ) Selenium cannot click on hidden things, JavaScript can. Use this method instead of `$this->byCssSelector('.
jsClickAndWait ( string $cssSelector ) Uses {@link jsClick} and waits for AJAX request.
logOut ( )
loginIfNecessary ( )
setTinyMCEContent ( string $text ) Types text into TinyMCE. Can be plain text or contain HTML tags.
setValue ( $cssSelector, $value ) The built-in $element->value('xyz') method only appends to an existing value, this method overwrites the whole field.
waitAfterRedirect ( integer $timeout = 5000 ) If there is a redirect after POST (Post/Redirect/Get pattern) you have wait for the shutdown function that creates a commit - the commit may take longer time then rendering new page.
waitForAjax ( ) Wait for all AJAX requests caused by jQuery are done.
waitForElement ( string $cssSelector, integer $timeout = 3000 ) Explicitly wait for the element identified by $cssSelector to appear on the screen (throws assertion error if this element doesn't appear). Note that default Selenium methods have this behavior built-in so you typically only need to call this method at the end of the test method, before the assertions are run (it prevents them from running too soon).
waitUntilTrue ( $callback, $timeout = null ) Selenium API improvement. Wait until callback is true or timeout occurs.

Private Methods

Method Description
staticInitialization ( ) Makes sure some static properties are initialized. Called from constructor and from static methods that might run before it.

Method Details

__construct() public method

public __construct ( $name = null, array $data = [], $dataName = '' )
$data array

assertElementExists() protected method

Asserts that element exists.
protected assertElementExists ( string $cssSelector )
$cssSelector string

elementExists() protected method

protected elementExists ( $cssSelector )

executeScript() protected method

Small wrapper aroung built-in execute() method
protected executeScript ( string $code ) : string
$code string JavaScript code
return string JS result, if any

jsClick() protected method

..')->click()` if you need to.
protected jsClick ( string $cssSelector )
$cssSelector string

jsClickAndWait() protected method

Uses {@link jsClick} and waits for AJAX request.
protected jsClickAndWait ( string $cssSelector )
$cssSelector string

logOut() protected method

protected logOut ( )

loginIfNecessary() protected method

protected loginIfNecessary ( )

setTinyMCEContent() protected method

Types text into TinyMCE. Can be plain text or contain HTML tags.
protected setTinyMCEContent ( string $text )
$text string

setUpBeforeClass() public static method

public static setUpBeforeClass ( )

setUpPage() public method

public setUpPage ( )

setUpSite() public static method

Check if site is set up and VersionPress fully activated, and if not, do so. The $force parametr may force this.
public static setUpSite ( boolean $force )
$force boolean Force all the automation actions to be taken regardless of the site state

setValue() protected method

The built-in $element->value('xyz') method only appends to an existing value, this method overwrites the whole field.
protected setValue ( $cssSelector, $value )
$cssSelector
$value

waitAfterRedirect() protected method

If there is a redirect after POST (Post/Redirect/Get pattern) you have wait for the shutdown function that creates a commit - the commit may take longer time then rendering new page.
protected waitAfterRedirect ( integer $timeout = 5000 )
$timeout integer Milliseconds

waitForAjax() protected method

Wait for all AJAX requests caused by jQuery are done.
protected waitForAjax ( )

waitForElement() protected method

(This is just a friendly name / facade to the built-in waiting mechanism. Doing something like $el = $this->byCssSelector(..) has the same effect but would look a bit odd.)
protected waitForElement ( string $cssSelector, integer $timeout = 3000 )
$cssSelector string
$timeout integer Timeout in milliseconds. Default: 3 seconds.

waitUntilTrue() protected method

Selenium API improvement. Wait until callback is true or timeout occurs.
protected waitUntilTrue ( $callback, $timeout = null )
$callback
$timeout

Property Details

$autologin protected_oe static_oe property

If true, {@link loginIfNecessary} is called on {@link setUpSite}.
protected static bool $autologin
return boolean

$gitRepository protected_oe property

protected GitRepository,VersionPress\Git $gitRepository
return VersionPress\Git\GitRepository

$testConfig protected_oe static_oe property

protected static TestConfig,VersionPress\Tests\Utils $testConfig
return VersionPress\Tests\Utils\TestConfig

$wpAdminPath protected_oe static_oe property

protected static string $wpAdminPath
return string

$wpAutomation protected_oe static_oe property

protected static WpAutomation,VersionPress\Tests\Automation $wpAutomation
return VersionPress\Tests\Automation\WpAutomation