Update to drupal-org-drupal 8.0.0-rc2. For more information, see https://www.drupal.org/node/2598668

This commit is contained in:
Pantheon Automation 2015-10-21 21:44:50 -07:00 committed by Greg Anderson
parent f32e58e4b1
commit 8e18df8c36
3062 changed files with 15044 additions and 172506 deletions

View file

@ -1,96 +0,0 @@
Mink Driver testsuite
=====================
This is the common testsuite for Mink drivers to ensure consistency among implementations.
Usage
-----
The testsuite of a driver should be based as follow:
```json
{
"require": {
"behat/mink": "~1.6@dev"
},
"autoload-dev": {
"psr-4": {
"Acme\\MyDriver\\Tests\\": "tests"
}
}
}
```
```xml
<!-- phpunit.xml.dist -->
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" bootstrap="vendor/behat/mink/driver-testsuite/bootstrap.php">
<php>
<var name="driver_config_factory" value="Acme\MyDriver\Tests\Config::getInstance" />
<server name="WEB_FIXTURES_HOST" value="http://test.mink.dev" />
</php>
<testsuites>
<testsuite name="Functional tests">
<directory>vendor/behat/mink/driver-testsuite/tests</directory>
</testsuite>
<!-- if needed to add more tests -->
<testsuite name="Driver tests">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
```
Then create the driver config for the testsuite:
```php
// tests/Config.php
namespace Acme\MyDriver\Tests;
use Behat\Mink\Tests\Driver\AbstractConfig;
class Config extends AbstractConfig
{
/**
* Creates an instance of the config.
*
* This is the callable registered as a php variable in the phpunit.xml config file.
* It could be outside the class but this is convenient.
*/
public static function getInstance()
{
return new self();
}
/**
* Creates driver instance.
*
* @return \Behat\Mink\Driver\DriverInterface
*/
public function createDriver()
{
return new \Acme\MyDriver\MyDriver();
}
}
```
Some other methods are available in the AbstractConfig which can be overwritten to adapt the testsuite to
the needs of the driver (skipping some tests for instance).
Adding Driver-specific Tests
----------------------------
When adding extra test cases specific to the driver, either use your own namespace or put them in the
``Behat\Mink\Tests\Driver\Custom`` subnamespace to ensure that you will not create conflicts with test cases
added in the driver testsuite in the future.

View file

@ -1,28 +0,0 @@
<?php
$file = __DIR__.'/../../../autoload.php';
if (!file_exists($file)) {
echo PHP_EOL.'The Mink driver testsuite expects Mink to be installed as a composer dependency of your project'.PHP_EOL;
exit(1);
}
/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require $file;
$loader->addPsr4('Behat\Mink\Tests\Driver\\', __DIR__.'/tests');
// Clean the global variables
unset($file);
unset($loader);
// Check the definition of the driverLoaderFactory
if (!isset($GLOBALS['driver_config_factory'])) {
echo PHP_EOL.'The "driver_config_factory" global variable must be set.'.PHP_EOL;
exit(1);
}
if (!is_callable($GLOBALS['driver_config_factory'])) {
echo PHP_EOL.'The "driver_config_factory" global variable must be a callable.'.PHP_EOL;
exit(1);
}

View file

@ -1,83 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver;
use Behat\Mink\Driver\DriverInterface;
abstract class AbstractConfig
{
/**
* Creates driver instance.
*
* @return DriverInterface
*/
abstract public function createDriver();
/**
* Map remote file path.
*
* @param string $file File path.
*
* @return string
*/
public function mapRemoteFilePath($file)
{
if (!isset($_SERVER['TEST_MACHINE_BASE_PATH']) || !isset($_SERVER['DRIVER_MACHINE_BASE_PATH'])) {
return $file;
}
$pattern = '/^'.preg_quote($_SERVER['TEST_MACHINE_BASE_PATH'], '/').'/';
$basePath = $_SERVER['DRIVER_MACHINE_BASE_PATH'];
return preg_replace($pattern, $basePath, $file, 1);
}
/**
* Gets the base url to the fixture folder.
*
* @return string
*/
public function getWebFixturesUrl()
{
return $_SERVER['WEB_FIXTURES_HOST'];
}
/**
* @param string $testCase The name of the TestCase class
* @param string $test The name of the test method
*
* @return string|null A message explaining why the test should be skipped, or null to run the test.
*/
public function skipMessage($testCase, $test)
{
if (!$this->supportsCss() && 0 === strpos($testCase, 'Behat\Mink\Tests\Driver\Css\\')) {
return 'This driver does not support CSS.';
}
if (!$this->supportsJs() && 0 === strpos($testCase, 'Behat\Mink\Tests\Driver\Js\\')) {
return 'This driver does not support JavaScript.';
}
return null;
}
/**
* Whether the JS tests should run or no.
*
* @return bool
*/
protected function supportsJs()
{
return true;
}
/**
* Whether the CSS tests should run or no.
*
* @return bool
*/
protected function supportsCss()
{
return false;
}
}

View file

@ -1,64 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Basic;
use Behat\Mink\Tests\Driver\TestCase;
class BasicAuthTest extends TestCase
{
/**
* @dataProvider setBasicAuthDataProvider
*/
public function testSetBasicAuth($user, $pass, $pageText)
{
$session = $this->getSession();
$session->setBasicAuth($user, $pass);
$session->visit($this->pathTo('/basic_auth.php'));
$this->assertContains($pageText, $session->getPage()->getContent());
}
public function setBasicAuthDataProvider()
{
return array(
array('mink-user', 'mink-password', 'is authenticated'),
array('', '', 'is not authenticated'),
);
}
public function testResetBasicAuth()
{
$session = $this->getSession();
$session->setBasicAuth('mink-user', 'mink-password');
$session->visit($this->pathTo('/basic_auth.php'));
$this->assertContains('is authenticated', $session->getPage()->getContent());
$session->setBasicAuth(false);
$session->visit($this->pathTo('/headers.php'));
$this->assertNotContains('PHP_AUTH_USER', $session->getPage()->getContent());
}
public function testResetWithBasicAuth()
{
$session = $this->getSession();
$session->setBasicAuth('mink-user', 'mink-password');
$session->visit($this->pathTo('/basic_auth.php'));
$this->assertContains('is authenticated', $session->getPage()->getContent());
$session->reset();
$session->visit($this->pathTo('/headers.php'));
$this->assertNotContains('PHP_AUTH_USER', $session->getPage()->getContent());
}
}

View file

@ -1,84 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Basic;
use Behat\Mink\Tests\Driver\TestCase;
/**
* This testcase ensures that the driver implementation follows recommended practices for drivers.
*/
class BestPracticesTest extends TestCase
{
public function testExtendsCoreDriver()
{
$driver = $this->createDriver();
$this->assertInstanceOf('Behat\Mink\Driver\CoreDriver', $driver);
return $driver;
}
/**
* @depends testExtendsCoreDriver
*/
public function testImplementFindXpath()
{
$driver = $this->createDriver();
$this->assertNotImplementMethod('find', $driver, 'The driver should overwrite `findElementXpaths` rather than `find` for forward compatibility with Mink 2.');
$this->assertImplementMethod('findElementXpaths', $driver, 'The driver must be able to find elements.');
$this->assertNotImplementMethod('setSession', $driver, 'The driver should not deal with the Session directly for forward compatibility with Mink 2.');
}
/**
* @dataProvider provideRequiredMethods
*/
public function testImplementBasicApi($method)
{
$driver = $this->createDriver();
$this->assertImplementMethod($method, $driver, 'The driver is unusable when this method is not implemented.');
}
public function provideRequiredMethods()
{
return array(
array('start'),
array('isStarted'),
array('stop'),
array('reset'),
array('visit'),
array('getCurrentUrl'),
array('getContent'),
array('click'),
);
}
private function assertImplementMethod($method, $object, $reason = '')
{
$ref = new \ReflectionClass(get_class($object));
$refMethod = $ref->getMethod($method);
$message = sprintf('The driver should implement the `%s` method.', $method);
if ('' !== $reason) {
$message .= ' '.$reason;
}
$this->assertSame($ref->name, $refMethod->getDeclaringClass()->name, $message);
}
private function assertNotImplementMethod($method, $object, $reason = '')
{
$ref = new \ReflectionClass(get_class($object));
$refMethod = $ref->getMethod($method);
$message = sprintf('The driver should not implement the `%s` method.', $method);
if ('' !== $reason) {
$message .= ' '.$reason;
}
$this->assertNotSame($ref->name, $refMethod->getDeclaringClass()->name, $message);
}
}

View file

@ -1,86 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Basic;
use Behat\Mink\Tests\Driver\TestCase;
class ContentTest extends TestCase
{
public function testOuterHtml()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$element = $this->getAssertSession()->elementExists('css', '.travers');
$this->assertEquals(
"<div class=\"travers\">\n <div class=\"sub\">el1</div>\n".
" <div class=\"sub\">el2</div>\n <div class=\"sub\">\n".
" <a href=\"some_url\">some <strong>deep</strong> url</a>\n".
" </div>\n </div>",
$element->getOuterHtml()
);
}
public function testDumpingEmptyElements()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$element = $this->getAssertSession()->elementExists('css', '#empty');
$this->assertEquals(
'An empty <em></em> tag should be rendered with both open and close tags.',
trim($element->getHtml())
);
}
/**
* @dataProvider getAttributeDataProvider
*/
public function testGetAttribute($attributeName, $attributeValue)
{
$this->getSession()->visit($this->pathTo('/index.html'));
$element = $this->getSession()->getPage()->findById('attr-elem['.$attributeName.']');
$this->assertNotNull($element);
$this->assertSame($attributeValue, $element->getAttribute($attributeName));
}
public function getAttributeDataProvider()
{
return array(
array('with-value', 'some-value'),
array('without-value', ''),
array('with-empty-value', ''),
array('with-missing', null),
);
}
public function testJson()
{
$this->getSession()->visit($this->pathTo('/json.php'));
$this->assertContains(
'{"key1":"val1","key2":234,"key3":[1,2,3]}',
$this->getSession()->getPage()->getContent()
);
}
public function testHtmlDecodingNotPerformed()
{
$session = $this->getSession();
$webAssert = $this->getAssertSession();
$session->visit($this->pathTo('/html_decoding.html'));
$page = $session->getPage();
$span = $webAssert->elementExists('css', 'span');
$input = $webAssert->elementExists('css', 'input');
$expectedHtml = '<span custom-attr="&amp;">some text</span>';
$this->assertContains($expectedHtml, $page->getHtml(), '.innerHTML is returned as-is');
$this->assertContains($expectedHtml, $page->getContent(), '.outerHTML is returned as-is');
$this->assertEquals('&', $span->getAttribute('custom-attr'), '.getAttribute value is decoded');
$this->assertEquals('&', $input->getAttribute('value'), '.getAttribute value is decoded');
$this->assertEquals('&', $input->getValue(), 'node value is decoded');
}
}

View file

@ -1,168 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Basic;
use Behat\Mink\Tests\Driver\TestCase;
class CookieTest extends TestCase
{
/**
* test cookie decoding.
*
* @group issue140
*/
public function testIssue140()
{
$this->getSession()->visit($this->pathTo('/issue140.php'));
$this->getSession()->getPage()->fillField('cookie_value', 'some:value;');
$this->getSession()->getPage()->pressButton('Set cookie');
$this->getSession()->visit($this->pathTo('/issue140.php?show_value'));
$this->assertEquals('some:value;', $this->getSession()->getCookie('tc'));
$this->assertEquals('some:value;', $this->getSession()->getPage()->getText());
}
public function testCookie()
{
$this->getSession()->visit($this->pathTo('/cookie_page2.php'));
$this->assertContains('Previous cookie: NO', $this->getSession()->getPage()->getText());
$this->assertNull($this->getSession()->getCookie('srvr_cookie'));
$this->getSession()->setCookie('srvr_cookie', 'client cookie set');
$this->getSession()->reload();
$this->assertContains('Previous cookie: client cookie set', $this->getSession()->getPage()->getText());
$this->assertEquals('client cookie set', $this->getSession()->getCookie('srvr_cookie'));
$this->getSession()->setCookie('srvr_cookie', null);
$this->getSession()->reload();
$this->assertContains('Previous cookie: NO', $this->getSession()->getPage()->getText());
$this->getSession()->visit($this->pathTo('/cookie_page1.php'));
$this->getSession()->visit($this->pathTo('/cookie_page2.php'));
$this->assertContains('Previous cookie: srv_var_is_set', $this->getSession()->getPage()->getText());
$this->getSession()->setCookie('srvr_cookie', null);
$this->getSession()->reload();
$this->assertContains('Previous cookie: NO', $this->getSession()->getPage()->getText());
}
/**
* @dataProvider cookieWithPathsDataProvider
*/
public function testCookieWithPaths($cookieRemovalMode)
{
// start clean
$session = $this->getSession();
$session->visit($this->pathTo('/sub-folder/cookie_page2.php'));
$this->assertContains('Previous cookie: NO', $session->getPage()->getText());
// cookie from root path is accessible in sub-folder
$session->visit($this->pathTo('/cookie_page1.php'));
$session->visit($this->pathTo('/sub-folder/cookie_page2.php'));
$this->assertContains('Previous cookie: srv_var_is_set', $session->getPage()->getText());
// cookie from sub-folder overrides cookie from root path
$session->visit($this->pathTo('/sub-folder/cookie_page1.php'));
$session->visit($this->pathTo('/sub-folder/cookie_page2.php'));
$this->assertContains('Previous cookie: srv_var_is_set_sub_folder', $session->getPage()->getText());
if ($cookieRemovalMode == 'session_reset') {
$session->reset();
} elseif ($cookieRemovalMode == 'cookie_delete') {
$session->setCookie('srvr_cookie', null);
}
// cookie is removed from all paths
$session->visit($this->pathTo('/sub-folder/cookie_page2.php'));
$this->assertContains('Previous cookie: NO', $session->getPage()->getText());
}
public function cookieWithPathsDataProvider()
{
return array(
array('session_reset'),
array('cookie_delete'),
);
}
public function testReset()
{
$this->getSession()->visit($this->pathTo('/cookie_page1.php'));
$this->getSession()->visit($this->pathTo('/cookie_page2.php'));
$this->assertContains('Previous cookie: srv_var_is_set', $this->getSession()->getPage()->getText());
$this->getSession()->reset();
$this->getSession()->visit($this->pathTo('/cookie_page2.php'));
$this->assertContains('Previous cookie: NO', $this->getSession()->getPage()->getText());
$this->getSession()->setCookie('srvr_cookie', 'test_cookie');
$this->getSession()->visit($this->pathTo('/cookie_page2.php'));
$this->assertContains('Previous cookie: test_cookie', $this->getSession()->getPage()->getText());
$this->getSession()->reset();
$this->getSession()->visit($this->pathTo('/cookie_page2.php'));
$this->assertContains('Previous cookie: NO', $this->getSession()->getPage()->getText());
$this->getSession()->setCookie('client_cookie1', 'some_val');
$this->getSession()->setCookie('client_cookie2', 123);
$this->getSession()->visit($this->pathTo('/session_test.php'));
$this->getSession()->visit($this->pathTo('/cookie_page1.php'));
$this->getSession()->visit($this->pathTo('/print_cookies.php'));
$this->assertContains(
"'client_cookie1' = 'some_val'",
$this->getSession()->getPage()->getText()
);
$this->assertContains(
"'client_cookie2' = '123'",
$this->getSession()->getPage()->getText()
);
$this->assertContains(
"_SESS' = ",
$this->getSession()->getPage()->getText()
);
$this->assertContains(
" 'srvr_cookie' = 'srv_var_is_set'",
$this->getSession()->getPage()->getText()
);
$this->getSession()->reset();
$this->getSession()->visit($this->pathTo('/print_cookies.php'));
$this->assertContains('array ( )', $this->getSession()->getPage()->getText());
}
public function testHttpOnlyCookieIsDeleted()
{
$this->getSession()->restart();
$this->getSession()->visit($this->pathTo('/cookie_page3.php'));
$this->assertEquals('Has Cookie: false', $this->findById('cookie-status')->getText());
$this->getSession()->reload();
$this->assertEquals('Has Cookie: true', $this->findById('cookie-status')->getText());
$this->getSession()->restart();
$this->getSession()->visit($this->pathTo('/cookie_page3.php'));
$this->assertEquals('Has Cookie: false', $this->findById('cookie-status')->getText());
}
public function testSessionPersistsBetweenRequests()
{
$this->getSession()->visit($this->pathTo('/session_test.php'));
$webAssert = $this->getAssertSession();
$node = $webAssert->elementExists('css', '#session-id');
$sessionId = $node->getText();
$this->getSession()->visit($this->pathTo('/session_test.php'));
$node = $webAssert->elementExists('css', '#session-id');
$this->assertEquals($sessionId, $node->getText());
$this->getSession()->visit($this->pathTo('/session_test.php?login'));
$node = $webAssert->elementExists('css', '#session-id');
$this->assertNotEquals($sessionId, $newSessionId = $node->getText());
$this->getSession()->visit($this->pathTo('/session_test.php'));
$node = $webAssert->elementExists('css', '#session-id');
$this->assertEquals($newSessionId, $node->getText());
}
}

View file

@ -1,265 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Basic;
use Behat\Mink\Tests\Driver\TestCase;
/**
* @group slow
*/
class ErrorHandlingTest extends TestCase
{
const NOT_FOUND_XPATH = '//html/./invalid';
const NOT_FOUND_EXCEPTION = 'Exception';
const INVALID_EXCEPTION = 'Exception';
public function testVisitErrorPage()
{
$this->getSession()->visit($this->pathTo('/500.php'));
$this->assertContains(
'Sorry, a server error happened',
$this->getSession()->getPage()->getContent(),
'Drivers allow loading pages with a 500 status code'
);
}
public function testCheckInvalidElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$element = $this->findById('user-name');
$this->setExpectedException(self::INVALID_EXCEPTION);
$this->getSession()->getDriver()->check($element->getXpath());
}
public function testCheckNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->check(self::NOT_FOUND_XPATH);
}
public function testUncheckInvalidElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$element = $this->findById('user-name');
$this->setExpectedException(self::INVALID_EXCEPTION);
$this->getSession()->getDriver()->uncheck($element->getXpath());
}
public function testUncheckNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->uncheck(self::NOT_FOUND_XPATH);
}
public function testSelectOptionInvalidElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$element = $this->findById('user-name');
$this->setExpectedException(self::INVALID_EXCEPTION);
$this->getSession()->getDriver()->selectOption($element->getXpath(), 'test');
}
public function testSelectOptionNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->selectOption(self::NOT_FOUND_XPATH, 'test');
}
public function testAttachFileInvalidElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$element = $this->findById('user-name');
$this->setExpectedException(self::INVALID_EXCEPTION);
$this->getSession()->getDriver()->attachFile($element->getXpath(), __FILE__);
}
public function testAttachFileNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->attachFile(self::NOT_FOUND_XPATH, __FILE__);
}
public function testSubmitFormInvalidElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$element = $this->findById('core');
$this->setExpectedException(self::INVALID_EXCEPTION);
$this->getSession()->getDriver()->submitForm($element->getXpath());
}
public function testSubmitFormNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->submitForm(self::NOT_FOUND_XPATH);
}
public function testGetTagNameNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->getTagName(self::NOT_FOUND_XPATH);
}
public function testGetTextNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->getText(self::NOT_FOUND_XPATH);
}
public function testGetHtmlNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->getHtml(self::NOT_FOUND_XPATH);
}
public function testGetOuterHtmlNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->getOuterHtml(self::NOT_FOUND_XPATH);
}
public function testGetValueNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->getValue(self::NOT_FOUND_XPATH);
}
public function testSetValueNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->setValue(self::NOT_FOUND_XPATH, 'test');
}
public function testIsSelectedNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->isSelected(self::NOT_FOUND_XPATH);
}
public function testIsCheckedNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->isChecked(self::NOT_FOUND_XPATH);
}
public function testIsVisibleNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->isVisible(self::NOT_FOUND_XPATH);
}
public function testClickNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->click(self::NOT_FOUND_XPATH);
}
public function testDoubleClickNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->doubleClick(self::NOT_FOUND_XPATH);
}
public function testRightClickNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->rightClick(self::NOT_FOUND_XPATH);
}
public function testGetAttributeNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->getAttribute(self::NOT_FOUND_XPATH, 'id');
}
public function testMouseOverNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->mouseOver(self::NOT_FOUND_XPATH);
}
public function testFocusNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->focus(self::NOT_FOUND_XPATH);
}
public function testBlurNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->blur(self::NOT_FOUND_XPATH);
}
public function testKeyPressNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->keyPress(self::NOT_FOUND_XPATH, 'a');
}
public function testKeyDownNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->keyDown(self::NOT_FOUND_XPATH, 'a');
}
public function testKeyUpNotFoundElement()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->setExpectedException(self::NOT_FOUND_EXCEPTION);
$this->getSession()->getDriver()->keyUp(self::NOT_FOUND_XPATH, 'a');
}
}

View file

@ -1,78 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Basic;
use Behat\Mink\Tests\Driver\TestCase;
class HeaderTest extends TestCase
{
/**
* test referrer.
*
* @group issue130
*/
public function testIssue130()
{
$this->getSession()->visit($this->pathTo('/issue130.php?p=1'));
$page = $this->getSession()->getPage();
$page->clickLink('Go to 2');
$this->assertEquals($this->pathTo('/issue130.php?p=1'), $page->getText());
}
public function testHeaders()
{
$this->getSession()->setRequestHeader('Accept-Language', 'fr');
$this->getSession()->visit($this->pathTo('/headers.php'));
$this->assertContains('[HTTP_ACCEPT_LANGUAGE] => fr', $this->getSession()->getPage()->getContent());
}
public function testSetUserAgent()
{
$session = $this->getSession();
$session->setRequestHeader('user-agent', 'foo bar');
$session->visit($this->pathTo('/headers.php'));
$this->assertContains('[HTTP_USER_AGENT] => foo bar', $session->getPage()->getContent());
}
public function testResetHeaders()
{
$session = $this->getSession();
$session->setRequestHeader('X-Mink-Test', 'test');
$session->visit($this->pathTo('/headers.php'));
$this->assertContains(
'[HTTP_X_MINK_TEST] => test',
$session->getPage()->getContent(),
'The custom header should be sent',
true
);
$session->reset();
$session->visit($this->pathTo('/headers.php'));
$this->assertNotContains(
'[HTTP_X_MINK_TEST] => test',
$session->getPage()->getContent(),
'The custom header should not be sent after resetting',
true
);
}
public function testResponseHeaders()
{
$this->getSession()->visit($this->pathTo('/response_headers.php'));
$headers = $this->getSession()->getResponseHeaders();
$lowercasedHeaders = array();
foreach ($headers as $name => $value) {
$lowercasedHeaders[str_replace('_', '-', strtolower($name))] = $value;
}
$this->assertArrayHasKey('x-mink-test', $lowercasedHeaders);
}
}

View file

@ -1,27 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Basic;
use Behat\Mink\Tests\Driver\TestCase;
class IFrameTest extends TestCase
{
public function testIFrame()
{
$this->getSession()->visit($this->pathTo('/iframe.html'));
$webAssert = $this->getAssertSession();
$el = $webAssert->elementExists('css', '#text');
$this->assertSame('Main window div text', $el->getText());
$this->getSession()->switchToIFrame('subframe');
$el = $webAssert->elementExists('css', '#text');
$this->assertSame('iFrame div text', $el->getText());
$this->getSession()->switchToIFrame();
$el = $webAssert->elementExists('css', '#text');
$this->assertSame('Main window div text', $el->getText());
}
}

View file

@ -1,69 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Basic;
use Behat\Mink\Tests\Driver\TestCase;
class NavigationTest extends TestCase
{
public function testRedirect()
{
$this->getSession()->visit($this->pathTo('/redirector.php'));
$this->assertEquals($this->pathTo('/redirect_destination.html'), $this->getSession()->getCurrentUrl());
}
public function testPageControls()
{
$this->getSession()->visit($this->pathTo('/randomizer.php'));
$number1 = $this->getAssertSession()->elementExists('css', '#number')->getText();
$this->getSession()->reload();
$number2 = $this->getAssertSession()->elementExists('css', '#number')->getText();
$this->assertNotEquals($number1, $number2);
$this->getSession()->visit($this->pathTo('/links.html'));
$this->getSession()->getPage()->clickLink('Random number page');
$this->assertEquals($this->pathTo('/randomizer.php'), $this->getSession()->getCurrentUrl());
$this->getSession()->back();
$this->assertEquals($this->pathTo('/links.html'), $this->getSession()->getCurrentUrl());
$this->getSession()->forward();
$this->assertEquals($this->pathTo('/randomizer.php'), $this->getSession()->getCurrentUrl());
}
public function testLinks()
{
$this->getSession()->visit($this->pathTo('/links.html'));
$page = $this->getSession()->getPage();
$link = $page->findLink('Redirect me to');
$this->assertNotNull($link);
$this->assertRegExp('/redirector\.php$/', $link->getAttribute('href'));
$link->click();
$this->assertEquals($this->pathTo('/redirect_destination.html'), $this->getSession()->getCurrentUrl());
$this->getSession()->visit($this->pathTo('/links.html'));
$page = $this->getSession()->getPage();
$link = $page->findLink('basic form image');
$this->assertNotNull($link);
$this->assertRegExp('/basic_form\.html$/', $link->getAttribute('href'));
$link->click();
$this->assertEquals($this->pathTo('/basic_form.html'), $this->getSession()->getCurrentUrl());
$this->getSession()->visit($this->pathTo('/links.html'));
$page = $this->getSession()->getPage();
$link = $page->findLink('Link with a ');
$this->assertNotNull($link);
$this->assertRegExp('/links\.html\?quoted$/', $link->getAttribute('href'));
$link->click();
$this->assertEquals($this->pathTo('/links.html?quoted'), $this->getSession()->getCurrentUrl());
}
}

View file

@ -1,30 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Basic;
use Behat\Mink\Tests\Driver\TestCase;
class ScreenshotTest extends TestCase
{
public function testScreenshot()
{
if (!extension_loaded('gd')) {
$this->markTestSkipped('Testing screenshots requires the GD extension');
}
$this->getSession()->visit($this->pathTo('/index.html'));
$screenShot = $this->getSession()->getScreenshot();
$this->assertInternalType('string', $screenShot);
$this->assertFalse(base64_decode($screenShot, true), 'The returned screenshot should not be base64-encoded');
$img = imagecreatefromstring($screenShot);
if (false === $img) {
$this->fail('The screenshot should be a valid image');
}
imagedestroy($img);
}
}

View file

@ -1,22 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Basic;
use Behat\Mink\Tests\Driver\TestCase;
class StatusCodeTest extends TestCase
{
public function testStatuses()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->assertEquals(200, $this->getSession()->getStatusCode());
$this->assertEquals($this->pathTo('/index.html'), $this->getSession()->getCurrentUrl());
$this->getSession()->visit($this->pathTo('/404.php'));
$this->assertEquals($this->pathTo('/404.php'), $this->getSession()->getCurrentUrl());
$this->assertEquals(404, $this->getSession()->getStatusCode());
$this->assertEquals('Sorry, page not found', $this->getSession()->getPage()->getContent());
}
}

View file

@ -1,143 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Basic;
use Behat\Mink\Tests\Driver\TestCase;
class TraversingTest extends TestCase
{
/**
* find by label.
*
* @group issue211
*/
public function testIssue211()
{
$this->getSession()->visit($this->pathTo('/issue211.html'));
$field = $this->getSession()->getPage()->findField('Téléphone');
$this->assertNotNull($field);
}
public function testElementsTraversing()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$page = $this->getSession()->getPage();
$title = $page->find('css', 'h1');
$this->assertNotNull($title);
$this->assertEquals('Extremely useless page', $title->getText());
$this->assertEquals('h1', $title->getTagName());
$strong = $page->find('xpath', '//div/strong[3]');
$this->assertNotNull($strong);
$this->assertEquals('pariatur', $strong->getText());
$this->assertEquals('super-duper', $strong->getAttribute('class'));
$this->assertTrue($strong->hasAttribute('class'));
$strong2 = $page->find('xpath', '//div/strong[2]');
$this->assertNotNull($strong2);
$this->assertEquals('veniam', $strong2->getText());
$this->assertEquals('strong', $strong2->getTagName());
$this->assertNull($strong2->getAttribute('class'));
$this->assertFalse($strong2->hasAttribute('class'));
$strongs = $page->findAll('css', 'div#core > strong');
$this->assertCount(3, $strongs);
$this->assertEquals('Lorem', $strongs[0]->getText());
$this->assertEquals('pariatur', $strongs[2]->getText());
$element = $page->find('css', '#some-element');
$this->assertNotNull($element);
$this->assertEquals('some very interesting text', $element->getText());
$this->assertEquals(
"\n some <div>very\n </div>\n".
"<em>interesting</em> text\n ",
$element->getHtml()
);
$this->assertTrue($element->hasAttribute('data-href'));
$this->assertFalse($element->hasAttribute('data-url'));
$this->assertEquals('http://mink.behat.org', $element->getAttribute('data-href'));
$this->assertNull($element->getAttribute('data-url'));
$this->assertEquals('div', $element->getTagName());
}
public function testVeryDeepElementsTraversing()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$page = $this->getSession()->getPage();
$footer = $page->find('css', 'footer');
$this->assertNotNull($footer);
$searchForm = $footer->find('css', 'form#search-form');
$this->assertNotNull($searchForm);
$this->assertEquals('search-form', $searchForm->getAttribute('id'));
$searchInput = $searchForm->findField('Search site...');
$this->assertNotNull($searchInput);
$this->assertEquals('text', $searchInput->getAttribute('type'));
$searchInput = $searchForm->findField('Search site...');
$this->assertNotNull($searchInput);
$this->assertEquals('text', $searchInput->getAttribute('type'));
$profileForm = $footer->find('css', '#profile');
$this->assertNotNull($profileForm);
$profileFormDiv = $profileForm->find('css', 'div');
$this->assertNotNull($profileFormDiv);
$profileFormDivLabel = $profileFormDiv->find('css', 'label');
$this->assertNotNull($profileFormDivLabel);
$profileFormDivParent = $profileFormDivLabel->getParent();
$this->assertNotNull($profileFormDivParent);
$profileFormDivParent = $profileFormDivLabel->getParent();
$this->assertEquals('something', $profileFormDivParent->getAttribute('data-custom'));
$profileFormInput = $profileFormDivLabel->findField('user-name');
$this->assertNotNull($profileFormInput);
$this->assertEquals('username', $profileFormInput->getAttribute('name'));
}
public function testDeepTraversing()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$traversDivs = $this->getSession()->getPage()->findAll('css', 'div.travers');
$this->assertCount(1, $traversDivs);
$subDivs = $traversDivs[0]->findAll('css', 'div.sub');
$this->assertCount(3, $subDivs);
$this->assertTrue($subDivs[2]->hasLink('some deep url'));
$this->assertFalse($subDivs[2]->hasLink('come deep url'));
$subUrl = $subDivs[2]->findLink('some deep url');
$this->assertNotNull($subUrl);
$this->assertRegExp('/some_url$/', $subUrl->getAttribute('href'));
$this->assertEquals('some deep url', $subUrl->getText());
$this->assertEquals('some <strong>deep</strong> url', $subUrl->getHtml());
$this->assertTrue($subUrl->has('css', 'strong'));
$this->assertFalse($subUrl->has('css', 'em'));
$this->assertEquals('deep', $subUrl->find('css', 'strong')->getText());
}
public function testFindingChild()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$form = $this->getSession()->getPage()->find('css', 'footer form');
$this->assertNotNull($form);
$this->assertCount(1, $form->findAll('css', 'input'), 'Elements are searched only in the element, not in all previous matches');
}
}

View file

@ -1,20 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Basic;
use Behat\Mink\Tests\Driver\TestCase;
class VisibilityTest extends TestCase
{
public function testVisibility()
{
$this->getSession()->visit($this->pathTo('/js_test.html'));
$webAssert = $this->getAssertSession();
$clicker = $webAssert->elementExists('css', '.elements div#clicker');
$invisible = $webAssert->elementExists('css', '#invisible');
$this->assertFalse($invisible->isVisible());
$this->assertTrue($clicker->isVisible());
}
}

View file

@ -1,76 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Css;
use Behat\Mink\Tests\Driver\TestCase;
class HoverTest extends TestCase
{
/**
* @group mouse-events
*/
public function testMouseOverHover()
{
$this->getSession()->visit($this->pathTo('/css_mouse_events.html'));
$this->findById('reset-square')->mouseOver();
$this->assertActionSquareHeight(100);
$this->findById('action-square')->mouseOver();
$this->assertActionSquareHeight(200);
}
/**
* @group mouse-events
* @depends testMouseOverHover
*/
public function testClickHover()
{
$this->getSession()->visit($this->pathTo('/css_mouse_events.html'));
$this->findById('reset-square')->mouseOver();
$this->assertActionSquareHeight(100);
$this->findById('action-square')->click();
$this->assertActionSquareHeight(200);
}
/**
* @group mouse-events
* @depends testMouseOverHover
*/
public function testDoubleClickHover()
{
$this->getSession()->visit($this->pathTo('/css_mouse_events.html'));
$this->findById('reset-square')->mouseOver();
$this->assertActionSquareHeight(100);
$this->findById('action-square')->doubleClick();
$this->assertActionSquareHeight(200);
}
/**
* @group mouse-events
* @depends testMouseOverHover
*/
public function testRightClickHover()
{
$this->getSession()->visit($this->pathTo('/css_mouse_events.html'));
$this->findById('reset-square')->mouseOver();
$this->assertActionSquareHeight(100);
$this->findById('action-square')->rightClick();
$this->assertActionSquareHeight(200);
}
private function assertActionSquareHeight($expected)
{
$this->assertEquals(
$expected,
$this->getSession()->evaluateScript("return window.$('#action-square').height();"),
'Mouse is located over the object when mouse-related action is performed'
);
}
}

View file

@ -1,73 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Form;
use Behat\Mink\Tests\Driver\TestCase;
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());
}
}

View file

@ -1,312 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Form;
use Behat\Mink\Tests\Driver\TestCase;
class GeneralTest extends TestCase
{
// test multiple submit buttons
public function testIssue212()
{
$session = $this->getSession();
$session->visit($this->pathTo('/issue212.html'));
$field = $this->findById('poney-button');
$this->assertEquals('poney', $field->getValue());
}
public function testBasicForm()
{
$this->getSession()->visit($this->pathTo('/basic_form.html'));
$webAssert = $this->getAssertSession();
$page = $this->getSession()->getPage();
$this->assertEquals('Basic Form Page', $webAssert->elementExists('css', 'h1')->getText());
$firstname = $webAssert->fieldExists('first_name');
$lastname = $webAssert->fieldExists('lastn');
$this->assertEquals('Firstname', $firstname->getValue());
$this->assertEquals('Lastname', $lastname->getValue());
$firstname->setValue('Konstantin');
$page->fillField('last_name', 'Kudryashov');
$this->assertEquals('Konstantin', $firstname->getValue());
$this->assertEquals('Kudryashov', $lastname->getValue());
$page->findButton('Reset')->click();
$this->assertEquals('Firstname', $firstname->getValue());
$this->assertEquals('Lastname', $lastname->getValue());
$firstname->setValue('Konstantin');
$page->fillField('last_name', 'Kudryashov');
$page->findButton('Save')->click();
if ($this->safePageWait(5000, 'document.getElementById("first") !== null')) {
$this->assertEquals('Anket for Konstantin', $webAssert->elementExists('css', 'h1')->getText());
$this->assertEquals('Firstname: Konstantin', $webAssert->elementExists('css', '#first')->getText());
$this->assertEquals('Lastname: Kudryashov', $webAssert->elementExists('css', '#last')->getText());
}
}
/**
* @dataProvider formSubmitWaysDataProvider
*/
public function testFormSubmitWays($submitVia)
{
$session = $this->getSession();
$session->visit($this->pathTo('/basic_form.html'));
$page = $session->getPage();
$webAssert = $this->getAssertSession();
$firstname = $webAssert->fieldExists('first_name');
$firstname->setValue('Konstantin');
$page->findButton($submitVia)->click();
if ($this->safePageWait(5000, 'document.getElementById("first") !== null')) {
$this->assertEquals('Firstname: Konstantin', $webAssert->elementExists('css', '#first')->getText());
} else {
$this->fail('Form was never submitted');
}
}
public function formSubmitWaysDataProvider()
{
return array(
array('Save'),
array('input-type-image'),
array('button-without-type'),
array('button-type-submit'),
);
}
public function testFormSubmit()
{
$session = $this->getSession();
$session->visit($this->pathTo('/basic_form.html'));
$webAssert = $this->getAssertSession();
$webAssert->fieldExists('first_name')->setValue('Konstantin');
$webAssert->elementExists('xpath', 'descendant-or-self::form[1]')->submit();
if ($this->safePageWait(5000, 'document.getElementById("first") !== null')) {
$this->assertEquals('Firstname: Konstantin', $webAssert->elementExists('css', '#first')->getText());
};
}
public function testFormSubmitWithoutButton()
{
$session = $this->getSession();
$session->visit($this->pathTo('/form_without_button.html'));
$webAssert = $this->getAssertSession();
$webAssert->fieldExists('first_name')->setValue('Konstantin');
$webAssert->elementExists('xpath', 'descendant-or-self::form[1]')->submit();
if ($this->safePageWait(5000, 'document.getElementById("first") !== null')) {
$this->assertEquals('Firstname: Konstantin', $webAssert->elementExists('css', '#first')->getText());
};
}
public function testBasicGetForm()
{
$this->getSession()->visit($this->pathTo('/basic_get_form.php'));
$webAssert = $this->getAssertSession();
$page = $this->getSession()->getPage();
$this->assertEquals('Basic Get Form Page', $webAssert->elementExists('css', 'h1')->getText());
$search = $webAssert->fieldExists('q');
$search->setValue('some#query');
$page->pressButton('Find');
$div = $webAssert->elementExists('css', 'div');
$this->assertEquals('some#query', $div->getText());
}
public function testAdvancedForm()
{
$this->getSession()->visit($this->pathTo('/advanced_form.html'));
$page = $this->getSession()->getPage();
$page->fillField('first_name', 'ever');
$page->fillField('last_name', 'zet');
$page->pressButton('Register');
$this->assertContains('no file', $page->getContent());
$this->getSession()->visit($this->pathTo('/advanced_form.html'));
$webAssert = $this->getAssertSession();
$page = $this->getSession()->getPage();
$this->assertEquals('ADvanced Form Page', $webAssert->elementExists('css', 'h1')->getText());
$firstname = $webAssert->fieldExists('first_name');
$lastname = $webAssert->fieldExists('lastn');
$email = $webAssert->fieldExists('Your email:');
$select = $webAssert->fieldExists('select_number');
$sex = $webAssert->fieldExists('sex');
$maillist = $webAssert->fieldExists('mail_list');
$agreement = $webAssert->fieldExists('agreement');
$notes = $webAssert->fieldExists('notes');
$about = $webAssert->fieldExists('about');
$this->assertEquals('Firstname', $firstname->getValue());
$this->assertEquals('Lastname', $lastname->getValue());
$this->assertEquals('your@email.com', $email->getValue());
$this->assertEquals('20', $select->getValue());
$this->assertEquals('w', $sex->getValue());
$this->assertEquals('original notes', $notes->getValue());
$this->assertEquals('on', $maillist->getValue());
$this->assertNull($agreement->getValue());
$this->assertTrue($maillist->isChecked());
$this->assertFalse($agreement->isChecked());
$agreement->check();
$this->assertTrue($agreement->isChecked());
$maillist->uncheck();
$this->assertFalse($maillist->isChecked());
$select->selectOption('thirty');
$this->assertEquals('30', $select->getValue());
$sex->selectOption('m');
$this->assertEquals('m', $sex->getValue());
$notes->setValue('new notes');
$this->assertEquals('new notes', $notes->getValue());
$about->attachFile($this->mapRemoteFilePath(__DIR__.'/../../web-fixtures/some_file.txt'));
$button = $page->findButton('Register');
$this->assertNotNull($button);
$page->fillField('first_name', 'Foo "item"');
$page->fillField('last_name', 'Bar');
$page->fillField('Your email:', 'ever.zet@gmail.com');
$this->assertEquals('Foo "item"', $firstname->getValue());
$this->assertEquals('Bar', $lastname->getValue());
$button->press();
if ($this->safePageWait(5000, 'document.getElementsByTagName("title") !== null')) {
$out = <<<OUT
array (
'agreement' = 'on',
'email' = 'ever.zet@gmail.com',
'first_name' = 'Foo "item"',
'last_name' = 'Bar',
'notes' = 'new notes',
'select_number' = '30',
'sex' = 'm',
'submit' = 'Register',
)
some_file.txt
1 uploaded file
OUT;
$this->assertContains($out, $page->getContent());
}
}
public function testMultiInput()
{
$this->getSession()->visit($this->pathTo('/multi_input_form.html'));
$page = $this->getSession()->getPage();
$webAssert = $this->getAssertSession();
$this->assertEquals('Multi input Test', $webAssert->elementExists('css', 'h1')->getText());
$first = $webAssert->fieldExists('First');
$second = $webAssert->fieldExists('Second');
$third = $webAssert->fieldExists('Third');
$this->assertEquals('tag1', $first->getValue());
$this->assertSame('tag2', $second->getValue());
$this->assertEquals('tag1', $third->getValue());
$first->setValue('tag2');
$this->assertEquals('tag2', $first->getValue());
$this->assertSame('tag2', $second->getValue());
$this->assertEquals('tag1', $third->getValue());
$second->setValue('one');
$this->assertEquals('tag2', $first->getValue());
$this->assertSame('one', $second->getValue());
$third->setValue('tag3');
$this->assertEquals('tag2', $first->getValue());
$this->assertSame('one', $second->getValue());
$this->assertEquals('tag3', $third->getValue());
$button = $page->findButton('Register');
$this->assertNotNull($button);
$button->press();
$space = ' ';
$out = <<<OUT
'tags' =$space
array (
0 = 'tag2',
1 = 'one',
2 = 'tag3',
),
OUT;
$this->assertContains($out, $page->getContent());
}
public function testAdvancedFormSecondSubmit()
{
$this->getSession()->visit($this->pathTo('/advanced_form.html'));
$page = $this->getSession()->getPage();
$button = $page->findButton('Login');
$this->assertNotNull($button);
$button->press();
$toSearch = array(
"'agreement' = 'off',",
"'submit' = 'Login',",
'no file',
);
$pageContent = $page->getContent();
foreach ($toSearch as $searchString) {
$this->assertContains($searchString, $pageContent);
}
}
public function testSubmitEmptyTextarea()
{
$this->getSession()->visit($this->pathTo('/empty_textarea.html'));
$page = $this->getSession()->getPage();
$page->pressButton('Save');
$toSearch = array(
"'textarea' = '',",
"'submit' = 'Save',",
'no file',
);
$pageContent = $page->getContent();
foreach ($toSearch as $searchString) {
$this->assertContains($searchString, $pageContent);
}
}
}

View file

@ -1,128 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Form;
use Behat\Mink\Tests\Driver\TestCase;
class Html5Test extends TestCase
{
public function testHtml5FormInputAttribute()
{
$this->getSession()->visit($this->pathTo('/html5_form.html'));
$page = $this->getSession()->getPage();
$webAssert = $this->getAssertSession();
$firstName = $webAssert->fieldExists('first_name');
$lastName = $webAssert->fieldExists('last_name');
$this->assertEquals('not set', $lastName->getValue());
$firstName->setValue('John');
$lastName->setValue('Doe');
$this->assertEquals('Doe', $lastName->getValue());
$page->pressButton('Submit in form');
if ($this->safePageWait(5000, 'document.getElementsByTagName("title") !== null')) {
$out = <<<OUT
'first_name' = 'John',
'last_name' = 'Doe',
OUT;
$this->assertContains($out, $page->getContent());
$this->assertNotContains('other_field', $page->getContent());
}
}
public function testHtml5FormRadioAttribute()
{
$this->getSession()->visit($this->pathTo('html5_radio.html'));
$page = $this->getSession()->getPage();
$radio = $this->findById('sex_f');
$otherRadio = $this->findById('sex_invalid');
$this->assertEquals('f', $radio->getValue());
$this->assertEquals('invalid', $otherRadio->getValue());
$radio->selectOption('m');
$this->assertEquals('m', $radio->getValue());
$this->assertEquals('invalid', $otherRadio->getValue());
$page->pressButton('Submit in form');
$out = <<<OUT
'sex' = 'm',
OUT;
$this->assertContains($out, $page->getContent());
}
public function testHtml5FormButtonAttribute()
{
$this->getSession()->visit($this->pathTo('/html5_form.html'));
$page = $this->getSession()->getPage();
$webAssert = $this->getAssertSession();
$firstName = $webAssert->fieldExists('first_name');
$lastName = $webAssert->fieldExists('last_name');
$firstName->setValue('John');
$lastName->setValue('Doe');
$page->pressButton('Submit outside form');
if ($this->safePageWait(5000, 'document.getElementsByTagName("title") !== null')) {
$out = <<<OUT
'first_name' = 'John',
'last_name' = 'Doe',
'submit_button' = 'test',
OUT;
$this->assertContains($out, $page->getContent());
}
}
public function testHtml5FormOutside()
{
$this->getSession()->visit($this->pathTo('/html5_form.html'));
$page = $this->getSession()->getPage();
$page->fillField('other_field', 'hello');
$page->pressButton('Submit separate form');
if ($this->safePageWait(5000, 'document.getElementsByTagName("title") !== null')) {
$out = <<<OUT
'other_field' = 'hello',
OUT;
$this->assertContains($out, $page->getContent());
$this->assertNotContains('first_name', $page->getContent());
}
}
public function testHtml5Types()
{
$this->getSession()->visit($this->pathTo('html5_types.html'));
$page = $this->getSession()->getPage();
$page->fillField('url', 'http://mink.behat.org/');
$page->fillField('email', 'mink@example.org');
$page->fillField('number', '6');
$page->fillField('search', 'mink');
$page->fillField('date', '2014-05-19');
$page->fillField('color', '#ff00aa');
$page->pressButton('Submit');
$out = <<<OUT
'color' = '#ff00aa',
'date' = '2014-05-19',
'email' = 'mink@example.org',
'number' = '6',
'search' = 'mink',
'submit_button' = 'Submit',
'url' = 'http://mink.behat.org/',
OUT;
$this->assertContains($out, $page->getContent());
}
}

View file

@ -1,84 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Form;
use Behat\Mink\Tests\Driver\TestCase;
class RadioTest extends TestCase
{
protected function setUp()
{
$this->getSession()->visit($this->pathTo('radio.html'));
}
public function testIsChecked()
{
$option = $this->findById('first');
$option2 = $this->findById('second');
$this->assertTrue($option->isChecked());
$this->assertFalse($option2->isChecked());
$option2->selectOption('updated');
$this->assertFalse($option->isChecked());
$this->assertTrue($option2->isChecked());
}
public function testSelectOption()
{
$option = $this->findById('first');
$this->assertEquals('set', $option->getValue());
$option->selectOption('updated');
$this->assertEquals('updated', $option->getValue());
$option->selectOption('set');
$this->assertEquals('set', $option->getValue());
}
public function testSetValue()
{
$option = $this->findById('first');
$this->assertEquals('set', $option->getValue());
$option->setValue('updated');
$this->assertEquals('updated', $option->getValue());
$this->assertFalse($option->isChecked());
}
public function testSameNameInMultipleForms()
{
$option1 = $this->findById('reused_form1');
$option2 = $this->findById('reused_form2');
$this->assertEquals('test2', $option1->getValue());
$this->assertEquals('test3', $option2->getValue());
$option1->selectOption('test');
$this->assertEquals('test', $option1->getValue());
$this->assertEquals('test3', $option2->getValue());
}
/**
* @see https://github.com/Behat/MinkSahiDriver/issues/32
*/
public function testSetValueXPathEscaping()
{
$session = $this->getSession();
$session->visit($this->pathTo('/advanced_form.html'));
$page = $session->getPage();
$sex = $page->find('xpath', '//*[@name = "sex"]'."\n|\n".'//*[@id = "sex"]');
$this->assertNotNull($sex, 'xpath with line ending works');
$sex->setValue('m');
$this->assertEquals('m', $sex->getValue(), 'no double xpath escaping during radio button value change');
}
}

View file

@ -1,134 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Form;
use Behat\Mink\Tests\Driver\TestCase;
class SelectTest extends TestCase
{
public function testMultiselect()
{
$this->getSession()->visit($this->pathTo('/multiselect_form.html'));
$webAssert = $this->getAssertSession();
$page = $this->getSession()->getPage();
$this->assertEquals('Multiselect Test', $webAssert->elementExists('css', 'h1')->getText());
$select = $webAssert->fieldExists('select_number');
$multiSelect = $webAssert->fieldExists('select_multiple_numbers[]');
$secondMultiSelect = $webAssert->fieldExists('select_multiple_values[]');
$this->assertEquals('20', $select->getValue());
$this->assertSame(array(), $multiSelect->getValue());
$this->assertSame(array('2', '3'), $secondMultiSelect->getValue());
$select->selectOption('thirty');
$this->assertEquals('30', $select->getValue());
$multiSelect->selectOption('one', true);
$this->assertSame(array('1'), $multiSelect->getValue());
$multiSelect->selectOption('three', true);
$this->assertEquals(array('1', '3'), $multiSelect->getValue());
$secondMultiSelect->selectOption('two');
$this->assertSame(array('2'), $secondMultiSelect->getValue());
$button = $page->findButton('Register');
$this->assertNotNull($button);
$button->press();
$space = ' ';
$out = <<<OUT
'agreement' = 'off',
'select_multiple_numbers' =$space
array (
0 = '1',
1 = '3',
),
'select_multiple_values' =$space
array (
0 = '2',
),
'select_number' = '30',
OUT;
$this->assertContains($out, $page->getContent());
}
/**
* @dataProvider testElementSelectedStateCheckDataProvider
*/
public function testElementSelectedStateCheck($selectName, $optionValue, $optionText)
{
$session = $this->getSession();
$webAssert = $this->getAssertSession();
$session->visit($this->pathTo('/multiselect_form.html'));
$select = $webAssert->fieldExists($selectName);
$option = $webAssert->elementExists('named', array('option', $optionValue));
$this->assertFalse($option->isSelected());
$select->selectOption($optionText);
$this->assertTrue($option->isSelected());
}
public function testElementSelectedStateCheckDataProvider()
{
return array(
array('select_number', '30', 'thirty'),
array('select_multiple_numbers[]', '2', 'two'),
);
}
public function testSetValueSingleSelect()
{
$session = $this->getSession();
$session->visit($this->pathTo('/multiselect_form.html'));
$select = $this->getAssertSession()->fieldExists('select_number');
$select->setValue('10');
$this->assertEquals('10', $select->getValue());
}
public function testSetValueMultiSelect()
{
$session = $this->getSession();
$session->visit($this->pathTo('/multiselect_form.html'));
$select = $this->getAssertSession()->fieldExists('select_multiple_values[]');
$select->setValue(array('1', '2'));
$this->assertEquals(array('1', '2'), $select->getValue());
}
/**
* @see https://github.com/Behat/Mink/issues/193
*/
public function testOptionWithoutValue()
{
$session = $this->getSession();
$session->visit($this->pathTo('/issue193.html'));
$session->getPage()->selectFieldOption('options-without-values', 'Two');
$this->assertEquals('Two', $this->findById('options-without-values')->getValue());
$this->assertTrue($this->findById('two')->isSelected());
$this->assertFalse($this->findById('one')->isSelected());
$session->getPage()->selectFieldOption('options-with-values', 'two');
$this->assertEquals('two', $this->findById('options-with-values')->getValue());
}
/**
* @see https://github.com/Behat/Mink/issues/131
*/
public function testAccentuatedOption()
{
$this->getSession()->visit($this->pathTo('/issue131.html'));
$page = $this->getSession()->getPage();
$page->selectFieldOption('foobar', 'Gimme some accentués characters');
$this->assertEquals('1', $page->findField('foobar')->getValue());
}
}

View file

@ -1,155 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Js;
use Behat\Mink\Tests\Driver\TestCase;
/**
* @group slow
*/
class ChangeEventTest extends TestCase
{
/**
* 'change' event should be fired after selecting an <option> in a <select>.
*
* TODO check whether this test is redundant with other change event tests.
*/
public function testIssue255()
{
$session = $this->getSession();
$session->visit($this->pathTo('/issue255.html'));
$session->getPage()->selectFieldOption('foo_select', 'Option 3');
$session->wait(2000, '$("#output_foo_select").text() != ""');
$this->assertEquals('onChangeSelect', $this->getAssertSession()->elementExists('css', '#output_foo_select')->getText());
}
public function testIssue178()
{
$session = $this->getSession();
$session->visit($this->pathTo('/issue178.html'));
$this->findById('source')->setValue('foo');
$this->assertEquals('foo', $this->findById('target')->getText());
}
/**
* @dataProvider setValueChangeEventDataProvider
* @group change-event-detector
*/
public function testSetValueChangeEvent($elementId, $valueForEmpty, $valueForFilled = '')
{
$this->getSession()->visit($this->pathTo('/element_change_detector.html'));
$page = $this->getSession()->getPage();
$input = $this->findById($elementId);
$this->assertNull($page->findById($elementId.'-result'));
// Verify setting value, when control is initially empty.
$input->setValue($valueForEmpty);
$this->assertElementChangeCount($elementId, 'initial value setting triggers change event');
if ($valueForFilled) {
// Verify setting value, when control already has a value.
$this->findById('results')->click();
$input->setValue($valueForFilled);
$this->assertElementChangeCount($elementId, 'value change triggers change event');
}
}
public function setValueChangeEventDataProvider()
{
return array(
'input default' => array('the-input-default', 'from empty', 'from existing'),
'input text' => array('the-input-text', 'from empty', 'from existing'),
'input email' => array('the-email', 'from empty', 'from existing'),
'textarea' => array('the-textarea', 'from empty', 'from existing'),
'file' => array('the-file', 'from empty', 'from existing'),
'select' => array('the-select', '30'),
'radio' => array('the-radio-m', 'm'),
);
}
/**
* @dataProvider selectOptionChangeEventDataProvider
* @group change-event-detector
*/
public function testSelectOptionChangeEvent($elementId, $elementValue)
{
$this->getSession()->visit($this->pathTo('/element_change_detector.html'));
$page = $this->getSession()->getPage();
$input = $this->findById($elementId);
$this->assertNull($page->findById($elementId.'-result'));
$input->selectOption($elementValue);
$this->assertElementChangeCount($elementId);
}
public function selectOptionChangeEventDataProvider()
{
return array(
'select' => array('the-select', '30'),
'radio' => array('the-radio-m', 'm'),
);
}
/**
* @dataProvider checkboxTestWayDataProvider
* @group change-event-detector
*/
public function testCheckChangeEvent($useSetValue)
{
$this->getSession()->visit($this->pathTo('/element_change_detector.html'));
$page = $this->getSession()->getPage();
$checkbox = $this->findById('the-unchecked-checkbox');
$this->assertNull($page->findById('the-unchecked-checkbox-result'));
if ($useSetValue) {
$checkbox->setValue(true);
} else {
$checkbox->check();
}
$this->assertElementChangeCount('the-unchecked-checkbox');
}
/**
* @dataProvider checkboxTestWayDataProvider
* @group change-event-detector
*/
public function testUncheckChangeEvent($useSetValue)
{
$this->getSession()->visit($this->pathTo('/element_change_detector.html'));
$page = $this->getSession()->getPage();
$checkbox = $this->findById('the-checked-checkbox');
$this->assertNull($page->findById('the-checked-checkbox-result'));
if ($useSetValue) {
$checkbox->setValue(false);
} else {
$checkbox->uncheck();
}
$this->assertElementChangeCount('the-checked-checkbox');
}
public function checkboxTestWayDataProvider()
{
return array(
array(true),
array(false),
);
}
private function assertElementChangeCount($elementId, $message = '')
{
$counterElement = $this->getSession()->getPage()->findById($elementId.'-result');
$actualCount = null === $counterElement ? 0 : $counterElement->getText();
$this->assertEquals('1', $actualCount, $message);
}
}

View file

@ -1,122 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Js;
use Behat\Mink\Tests\Driver\TestCase;
class EventsTest extends TestCase
{
/**
* @group mouse-events
*/
public function testClick()
{
$this->getSession()->visit($this->pathTo('/js_test.html'));
$clicker = $this->getAssertSession()->elementExists('css', '.elements div#clicker');
$this->assertEquals('not clicked', $clicker->getText());
$clicker->click();
$this->assertEquals('single clicked', $clicker->getText());
}
/**
* @group mouse-events
*/
public function testDoubleClick()
{
$this->getSession()->visit($this->pathTo('/js_test.html'));
$clicker = $this->getAssertSession()->elementExists('css', '.elements div#clicker');
$this->assertEquals('not clicked', $clicker->getText());
$clicker->doubleClick();
$this->assertEquals('double clicked', $clicker->getText());
}
/**
* @group mouse-events
*/
public function testRightClick()
{
$this->getSession()->visit($this->pathTo('/js_test.html'));
$clicker = $this->getAssertSession()->elementExists('css', '.elements div#clicker');
$this->assertEquals('not clicked', $clicker->getText());
$clicker->rightClick();
$this->assertEquals('right clicked', $clicker->getText());
}
/**
* @group mouse-events
*/
public function testFocus()
{
$this->getSession()->visit($this->pathTo('/js_test.html'));
$focusBlurDetector = $this->getAssertSession()->elementExists('css', '.elements input#focus-blur-detector');
$this->assertEquals('no action detected', $focusBlurDetector->getValue());
$focusBlurDetector->focus();
$this->assertEquals('focused', $focusBlurDetector->getValue());
}
/**
* @group mouse-events
* @depends testFocus
*/
public function testBlur()
{
$this->getSession()->visit($this->pathTo('/js_test.html'));
$focusBlurDetector = $this->getAssertSession()->elementExists('css', '.elements input#focus-blur-detector');
$this->assertEquals('no action detected', $focusBlurDetector->getValue());
$focusBlurDetector->blur();
$this->assertEquals('blured', $focusBlurDetector->getValue());
}
/**
* @group mouse-events
*/
public function testMouseOver()
{
$this->getSession()->visit($this->pathTo('/js_test.html'));
$mouseOverDetector = $this->getAssertSession()->elementExists('css', '.elements div#mouseover-detector');
$this->assertEquals('no mouse action detected', $mouseOverDetector->getText());
$mouseOverDetector->mouseOver();
$this->assertEquals('mouse overed', $mouseOverDetector->getText());
}
/**
* @dataProvider provideKeyboardEventsModifiers
*/
public function testKeyboardEvents($modifier, $eventProperties)
{
$this->getSession()->visit($this->pathTo('/js_test.html'));
$webAssert = $this->getAssertSession();
$input1 = $webAssert->elementExists('css', '.elements input.input.first');
$input2 = $webAssert->elementExists('css', '.elements input.input.second');
$input3 = $webAssert->elementExists('css', '.elements input.input.third');
$event = $webAssert->elementExists('css', '.elements .text-event');
$input1->keyDown('u', $modifier);
$this->assertEquals('key downed:'.$eventProperties, $event->getText());
$input2->keyPress('r', $modifier);
$this->assertEquals('key pressed:114 / '.$eventProperties, $event->getText());
$input3->keyUp(78, $modifier);
$this->assertEquals('key upped:78 / '.$eventProperties, $event->getText());
}
public function provideKeyboardEventsModifiers()
{
return array(
'none' => array(null, '0 / 0 / 0 / 0'),
'alt' => array('alt', '1 / 0 / 0 / 0'),
// jQuery considers ctrl as being a metaKey in the normalized event
'ctrl' => array('ctrl', '0 / 1 / 0 / 1'),
'shift' => array('shift', '0 / 0 / 1 / 0'),
'meta' => array('meta', '0 / 0 / 0 / 1'),
);
}
}

View file

@ -1,85 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Js;
use Behat\Mink\Tests\Driver\TestCase;
class JavascriptEvaluationTest extends TestCase
{
/**
* Tests, that `wait` method returns check result after exit.
*/
public function testWaitReturnValue()
{
$this->getSession()->visit($this->pathTo('/js_test.html'));
$found = $this->getSession()->wait(5000, '$("#draggable").length == 1');
$this->assertTrue($found);
}
public function testWait()
{
$this->getSession()->visit($this->pathTo('/js_test.html'));
$waitable = $this->findById('waitable');
$waitable->click();
$this->getSession()->wait(3000, '$("#waitable").has("div").length > 0');
$this->assertEquals('arrived', $this->getAssertSession()->elementExists('css', '#waitable > div')->getText());
$waitable->click();
$this->getSession()->wait(3000, 'false');
$this->assertEquals('timeout', $this->getAssertSession()->elementExists('css', '#waitable > div')->getText());
}
/**
* @dataProvider provideExecutedScript
*/
public function testExecuteScript($script)
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->getSession()->executeScript($script);
sleep(1);
$heading = $this->getAssertSession()->elementExists('css', 'h1');
$this->assertEquals('Hello world', $heading->getText());
}
public function provideExecutedScript()
{
return array(
array('document.querySelector("h1").textContent = "Hello world"'),
array('document.querySelector("h1").textContent = "Hello world";'),
array('function () {document.querySelector("h1").textContent = "Hello world";}()'),
array('function () {document.querySelector("h1").textContent = "Hello world";}();'),
array('(function () {document.querySelector("h1").textContent = "Hello world";})()'),
array('(function () {document.querySelector("h1").textContent = "Hello world";})();'),
);
}
/**
* @dataProvider provideEvaluatedScript
*/
public function testEvaluateJavascript($script)
{
$this->getSession()->visit($this->pathTo('/index.html'));
$this->assertSame(2, $this->getSession()->evaluateScript($script));
}
public function provideEvaluatedScript()
{
return array(
array('1 + 1'),
array('1 + 1;'),
array('return 1 + 1'),
array('return 1 + 1;'),
array('function () {return 1+1;}()'),
array('(function () {return 1+1;})()'),
array('return function () { return 1+1;}()'),
array('return (function () {return 1+1;})()'),
);
}
}

View file

@ -1,42 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Js;
use Behat\Mink\Tests\Driver\TestCase;
class JavascriptTest extends TestCase
{
public function testAriaRoles()
{
$this->getSession()->visit($this->pathTo('/aria_roles.html'));
$this->getSession()->wait(5000, '$("#hidden-element").is(":visible") === false');
$this->getSession()->getPage()->pressButton('Toggle');
$this->getSession()->wait(5000, '$("#hidden-element").is(":visible") === true');
$this->getSession()->getPage()->clickLink('Go to Index');
$this->assertEquals($this->pathTo('/index.html'), $this->getSession()->getCurrentUrl());
}
public function testDragDrop()
{
$this->getSession()->visit($this->pathTo('/js_test.html'));
$webAssert = $this->getAssertSession();
$draggable = $webAssert->elementExists('css', '#draggable');
$droppable = $webAssert->elementExists('css', '#droppable');
$draggable->dragTo($droppable);
$this->assertEquals('Dropped!', $this->getAssertSession()->elementExists('css', 'p', $droppable)->getText());
}
// test accentuated char in button
public function testIssue225()
{
$this->getSession()->visit($this->pathTo('/issue225.html'));
$this->getSession()->getPage()->pressButton('Créer un compte');
$this->getSession()->wait(5000, '$("#panel").text() != ""');
$this->assertContains('OH AIH!', $this->getSession()->getPage()->getText());
}
}

View file

@ -1,83 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver\Js;
use Behat\Mink\Tests\Driver\TestCase;
class WindowTest extends TestCase
{
public function testWindow()
{
$this->getSession()->visit($this->pathTo('/window.html'));
$session = $this->getSession();
$page = $session->getPage();
$webAssert = $this->getAssertSession();
$page->clickLink('Popup #1');
$session->switchToWindow(null);
$page->clickLink('Popup #2');
$session->switchToWindow(null);
$el = $webAssert->elementExists('css', '#text');
$this->assertSame('Main window div text', $el->getText());
$session->switchToWindow('popup_1');
$el = $webAssert->elementExists('css', '#text');
$this->assertSame('Popup#1 div text', $el->getText());
$session->switchToWindow('popup_2');
$el = $webAssert->elementExists('css', '#text');
$this->assertSame('Popup#2 div text', $el->getText());
$session->switchToWindow(null);
$el = $webAssert->elementExists('css', '#text');
$this->assertSame('Main window div text', $el->getText());
}
public function testGetWindowNames()
{
$this->getSession()->visit($this->pathTo('/window.html'));
$session = $this->getSession();
$page = $session->getPage();
$windowName = $this->getSession()->getWindowName();
$this->assertNotNull($windowName);
$page->clickLink('Popup #1');
$page->clickLink('Popup #2');
$windowNames = $this->getSession()->getWindowNames();
$this->assertNotNull($windowNames[0]);
$this->assertNotNull($windowNames[1]);
$this->assertNotNull($windowNames[2]);
}
public function testResizeWindow()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$session = $this->getSession();
$session->resizeWindow(400, 300);
$session->wait(1000, 'false');
$script = 'return Math.abs(window.outerHeight - 300) <= 100 && Math.abs(window.outerWidth - 400) <= 100;';
$this->assertTrue($session->evaluateScript($script));
}
public function testWindowMaximize()
{
$this->getSession()->visit($this->pathTo('/index.html'));
$session = $this->getSession();
$session->maximizeWindow();
$session->wait(1000, 'false');
$script = 'return Math.abs(screen.availHeight - window.outerHeight) <= 100;';
$this->assertTrue($session->evaluateScript($script));
}
}

View file

@ -1,167 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver;
use Behat\Mink\Exception\UnsupportedDriverActionException;
use Behat\Mink\Mink;
use Behat\Mink\Session;
use Behat\Mink\WebAssert;
abstract class TestCase extends \PHPUnit_Framework_TestCase
{
/**
* Mink session manager.
*
* @var Mink
*/
private static $mink;
/**
* @var AbstractConfig
*/
private static $config;
/**
* Initializes the test case.
*/
public static function setUpBeforeClass()
{
if (null === self::$mink) {
$session = new Session(self::getConfig()->createDriver());
self::$mink = new Mink(array('sess' => $session));
}
}
/**
* @return AbstractConfig
*
* @throws \UnexpectedValueException if the global driver_config_factory returns an invalid object
*/
private static function getConfig()
{
if (null === self::$config) {
self::$config = call_user_func($GLOBALS['driver_config_factory']);
if (!self::$config instanceof AbstractConfig) {
throw new \UnexpectedValueException('The "driver_config_factory" global variable must return a \Behat\Mink\Tests\Driver\AbstractConfig.');
}
}
return self::$config;
}
protected function checkRequirements()
{
if (null !== $message = self::getConfig()->skipMessage(get_class($this), $this->getName(false))) {
$this->markTestSkipped($message);
}
parent::checkRequirements();
}
protected function tearDown()
{
if (null !== self::$mink) {
self::$mink->resetSessions();
}
}
protected function onNotSuccessfulTest(\Exception $e)
{
if ($e instanceof UnsupportedDriverActionException) {
$this->markTestSkipped($e->getMessage());
}
parent::onNotSuccessfulTest($e);
}
/**
* Returns session.
*
* @return Session
*/
protected function getSession()
{
return self::$mink->getSession('sess');
}
/**
* Returns assert session.
*
* @return WebAssert
*/
protected function getAssertSession()
{
return self::$mink->assertSession('sess');
}
/**
* @param string $id
*
* @return \Behat\Mink\Element\NodeElement
*/
protected function findById($id)
{
return $this->getAssertSession()->elementExists('named', array('id', $id));
}
/**
* Creates a new driver instance.
*
* This driver is not associated to a session. It is meant to be used for tests on the driver
* implementation itself rather than test using the Mink API.
*
* @return \Behat\Mink\Driver\DriverInterface
*/
protected function createDriver()
{
return self::getConfig()->createDriver();
}
/**
* Map remote file path.
*
* @param string $file File path.
*
* @return string
*/
protected function mapRemoteFilePath($file)
{
$realPath = realpath($file);
if (false !== $realPath) {
$file = $realPath;
}
return self::getConfig()->mapRemoteFilePath($file);
}
/**
* @param string $path
*
* @return string
*/
protected function pathTo($path)
{
return rtrim(self::getConfig()->getWebFixturesUrl(), '/').'/'.ltrim($path, '/');
}
/**
* Waits for a condition to be true, considering than it is successful for drivers not supporting wait().
*
* @param int $time
* @param string $condition A JS condition to evaluate
*
* @return bool
*
* @see \Behat\Mink\Session::wait()
*/
protected function safePageWait($time, $condition)
{
try {
return $this->getSession()->wait($time, $condition);
} catch (UnsupportedDriverActionException $e) {
return true;
}
}
}

View file

@ -1,2 +0,0 @@
<?php header("HTTP/1.0 404 Not Found") ?>
Sorry, page not found

View file

@ -1,2 +0,0 @@
<?php header("HTTP/1.0 500 Server Error") ?>
Sorry, a server error happened

View file

@ -1,40 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>ADvanced Form</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<h1>ADvanced Form Page</h1>
<form method="POST" enctype="multipart/form-data" action="advanced_form_post.php">
<input name="first_name" value="Firstname" type="text" />
<input id="lastn" name="last_name" value="Lastname" type="text" />
<label for="email">
Your email:
<input type="email" id="email" name="email" value="your@email.com" />
</label>
<select name="select_number">
<option value="10">ten</option>
<option selected="selected" value="20">twenty</option>
<option value="30">thirty</option>
</select>
<label>
<span><input type="radio" name="sex" value="m" /> m</span>
<span><input type="radio" name="sex" value="w" checked="checked" /> w</span>
</label>
<input type="checkbox" name="mail_list" checked="checked" value="on"/>
<input type="checkbox" name="agreement" value="yes"/>
<textarea name="notes">original notes</textarea>
<input type="file" name="about" />
<input type="submit" name="submit" value="Register" />
<input type="submit" name="submit" value="Login" />
</form>
</body>
</html>

View file

@ -1,26 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Advanced form save</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
</head>
<body>
<?php
error_reporting(0);
if (isset($_POST['select_multiple_numbers']) && false !== strpos($_POST['select_multiple_numbers'][0], ',')) {
$_POST['select_multiple_numbers'] = explode(',', $_POST['select_multiple_numbers'][0]);
}
$_POST['agreement'] = isset($_POST['agreement']) ? 'on' : 'off';
ksort($_POST);
echo str_replace('>', '', var_export($_POST, true)) . "\n";
if (isset($_FILES['about']) && file_exists($_FILES['about']['tmp_name'])) {
echo $_FILES['about']['name'] . "\n";
echo file_get_contents($_FILES['about']['tmp_name']);
} else {
echo "no file";
}
?>
</body>
</html>

View file

@ -1,30 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>ARIA roles test</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
This page tests selected ARIA roles<br />
(see <a href="http://www.w3.org/TR/wai-aria/">http://www.w3.org/TR/wai-aria/</a>)
<div id="hidden-element-toggle-button" role="button">Toggle</div>
<div id="hidden-element" style="display:none;">This content's visibility is changed by clicking the Toggle Button.</div>
<!-- This link is created programmatically -->
<div id="link-element"></div>
<script language="javascript" type="text/javascript" src="js/jquery-1.6.2-min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$('#hidden-element-toggle-button').click(function() {
$('#hidden-element').toggle();
});
$('#link-element').attr('role', 'link').text('Go to Index').click(function() {
window.location.href = 'index.html';
});
});
</script>
</body>
</html>

View file

@ -1,12 +0,0 @@
<?php
$username = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : false;
$password = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : false;
if ($username == 'mink-user' && $password == 'mink-password') {
echo 'is authenticated';
} else {
header('WWW-Authenticate: Basic realm="Mink Testing Area"');
header('HTTP/1.0 401 Unauthorized');
echo 'is not authenticated';
}

View file

@ -1,22 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Basic Form</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<h1>Basic Form Page</h1>
<form method="POST" action="basic_form_post.php">
<input name="first_name" value="Firstname" type="text" />
<input id="lastn" name="last_name" value="Lastname" type="text" />
<input type="reset" id="Reset" />
<input type="submit" id="Save" />
<input type="image" id="input-type-image"/>
<button>button-without-type</button>
<button type="submit">button-type-submit</button>
</form>
</body>
</html>

View file

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Basic Form Saving</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<h1>Anket for <?php echo $_POST['first_name'] ?></h1>
<span id="first">Firstname: <?php echo $_POST['first_name'] ?></span>
<span id="last">Lastname: <?php echo $_POST['last_name'] ?></span>
</body>
</html>

View file

@ -1,20 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Basic Get Form</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<h1>Basic Get Form Page</h1>
<div id="serach">
<?php echo isset($_GET['q']) && $_GET['q'] ? $_GET['q'] : 'No search query' ?>
</div>
<form>
<input name="q" value="" type="text" />
<input type="submit" value="Find" />
</form>
</body>
</html>

View file

@ -1,21 +0,0 @@
<?php
if (!isset($cookieAtRootPath)) {
$cookieAtRootPath = true;
}
if (!isset($cookieValue)) {
$cookieValue = 'srv_var_is_set';
}
setcookie('srvr_cookie', $cookieValue, null, $cookieAtRootPath ? '/' : null);
?>
<!DOCTYPE html>
<html>
<head>
<title>Basic Form</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
Basic Page With Cookie Set from Server Side
</body>
</html>

View file

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Basic Form</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
Previous cookie: <?php echo isset($_COOKIE['srvr_cookie']) ? $_COOKIE['srvr_cookie'] : 'NO'; ?>
</body>
</html>

View file

@ -1,16 +0,0 @@
<?php
$hasCookie = isset($_COOKIE['foo']);
setcookie('foo', 'bar', 0, '/', null, false, true);
?>
<!DOCTYPE html>
<html>
<head>
<title>HttpOnly Cookie Test</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<div id="cookie-status">Has Cookie: <?php echo json_encode($hasCookie) ?></div>
</body>
</html>

View file

@ -1,36 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Mouse Events Testing</title>
<style type="text/css">
.squares div {
width: 100px;
height: 100px;
border: 1px solid black;
margin-right: 4px;
float: left;
}
.squares div:hover {
height: 200px;
background-color: red;
}
</style>
<script language="javascript" type="text/javascript" src="js/jquery-1.6.2-min.js"></script>
</head>
<body>
<div class="squares">
<div id="reset-square">reset</div>
<div id="action-square">mouse action</div>
</div>
<script>
$('#action-square').bind('contextmenu', function (e) {
// Prevent opening the context menu on right click as the browser might consider the
// mouse is in the context menu rather than hovering the element
e.preventDefault();
});
</script>
</body>
</html>

View file

@ -1,65 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>ADvanced Form</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<script src="js/jquery-1.6.2-min.js"></script>
</head>
<body>
<h1>ADvanced Form Page</h1>
<form method="POST" enctype="multipart/form-data" action="advanced_form_post.php">
<input id="the-input-default" value="" />
<input type="text" id="the-input-text" value="" />
<input type="email" id="the-email" value="" />
<select id="the-select">
<option value="10">ten</option>
<option value="20" selected="selected">twenty</option>
<option value="30">thirty</option>
</select>
<label>
<span><input type="radio" name="sex" id="the-radio-m" value="m" /> m</span>
<span><input type="radio" name="sex" id="the-radio-w" value="w" checked="checked" /> w</span>
</label>
<input type="checkbox" id="the-checked-checkbox" value="cb-val" checked/>
<input type="checkbox" id="the-unchecked-checkbox" value="cb-val"/>
<textarea id="the-textarea"></textarea>
<input type="file" id="the-file" />
</form>
<ul id="results" style="border: 1px solid red;">
<li>for easy element location</li>
</ul>
<script type="text/javascript">
$(document).ready(function () {
var $change_registry = {},
$results = $('#results');
$(':input').change(function () {
var $result_id = this.id + '-result';
if (!$change_registry[this.id]) {
$change_registry[this.id] = 1;
$results.append('<li id="' + $result_id + '"></li>');
}
else {
$change_registry[this.id]++;
}
$('#' + $result_id).text($change_registry[this.id]);
});
$results.click(function () {
$results.empty();
$change_registry = {};
});
});
</script>
</body>
</html>

View file

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Empty textarea submission</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<h1>Empty textarea submission</h1>
<form method="POST" action="advanced_form_post.php">
<textarea name="textarea"></textarea>
<input type="submit" name="submit" value="Save" />
</form>
</body>
</html>

View file

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Form submission without button test</title>
</head>
<body>
<form action="basic_form_post.php" method="POST">
<input name="first_name" type="text" value="not set">
<input name="last_name" type="text" value="not set">
</form>
</body>
</html>

View file

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Headers page</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<?php print_r($_SERVER); ?>
</body>
</html>

View file

@ -1,18 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML5 form attribute test</title>
</head>
<body>
<form action="advanced_form_post.php" method="POST" id="test-form">
<input name="first_name" type="text" value="not set">
<input name="other_field" type="text" value="not submitted" form="another">
<input type="submit" value="Submit separate form" form="another">
<input type="submit" value="Submit in form">
</form>
<input name="last_name" type="text" form="test-form" value="not set">
<button type="submit" form="test-form" name="submit_button" value="test">Submit outside form</button>
<form id="another" method="post" action="advanced_form_post.php"></form>
</body>
</html>

View file

@ -1,16 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML5 form attribute test</title>
</head>
<body>
<form action="advanced_form_post.php" method="POST" id="test-form">
<input name="sex" type="radio" value="m" id="sex_m">
<input name="sex" type="radio" value="invalid" form="another" id="sex_invalid" checked="checked">
<input type="submit" value="Submit in form">
</form>
<input name="sex" type="radio" form="test-form" value="f" id="sex_f" checked="checked">
<form id="another" method="post" action="advanced_form_post.php"></form>
</body>
</html>

View file

@ -1,18 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML5 form attribute test</title>
</head>
<body>
<form action="advanced_form_post.php" method="POST">
<input name="url" type="url">
<input name="email" type="email">
<input name="number" type="number">
<input name="search" type="search">
<input name="color" type="color">
<input name="date" type="date">
<input type="submit" name="submit_button" value="Submit">
</form>
</body>
</html>

View file

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>HTML Decoding Test</title>
</head>
<body>
<div>
<span custom-attr="&amp;">some text</span>
<form method="post" action="index.html">
<input value="&amp;"/>
<input type="submit" value="Send"/>
</form>
</div>
</body>
</html>

View file

@ -1,12 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<iframe src="iframe_inner.html" name="subframe"></iframe>
<div id="text">
Main window div text
</div>
</body>
</html>

View file

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<div id="text">
iFrame div text
</div>
</body>
</html>

View file

@ -1,55 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Index page</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<h1>Extremely useless page</h1>
<div id="core">
<strong>Lorem</strong> ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim <strong>veniam</strong>, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla <strong class="super-duper">pariatur</strong>. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<div id="empty">
An empty <em></em> tag should be rendered with both open and close tags.
</div>
<div id="some-element" data-href="http://mink.behat.org">
some <div>very
</div>
<em>interesting</em> text
</div>
<div class="attribute-testing">
<input type="text" id="attr-elem[with-value]" with-value="some-value"/>
<input type="text" id="attr-elem[without-value]" without-value/>
<input type="text" id="attr-elem[with-empty-value]" with-empty-value=""/>
<input type="text" id="attr-elem[with-missing]"/>
</div>
<div class="travers">
<div class="sub">el1</div>
<div class="sub">el2</div>
<div class="sub">
<a href="some_url">some <strong>deep</strong> url</a>
</div>
</div>
<div class="sub">el4</div>
</div>
<footer>
<form id="search-form">
<input type="text" placeholder="Search site..." />
</form>
<form id="profile">
<div data-custom="something">
<label>
<input type="text" id="user-name" name="username" />
</label>
</div>
<input type="submit" />
</form>
</footer>
</body>
</html>

View file

@ -1,11 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<?php
if ('1' === $_GET['p']) {
echo '<a href="issue130.php?p=2">Go to 2</a>';
} else {
echo '<strong>'.$_SERVER['HTTP_REFERER'].'</strong>';
}
?>
</body>

View file

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Issue 131</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<h1>There is a non breaking&#160;space</h1>
<pre id="foobar">Some accentués characters</pre>
<form>
<select name="foobar">
<option value="1">Gimme some accentués characters</option>
</select>
<input type="submit" />
</form>
</body>
</html>

View file

@ -1,16 +0,0 @@
<?php
if (!empty($_POST)) {
setcookie("tc", $_POST['cookie_value'], null, '/');
} elseif (isset($_GET["show_value"])) {
echo $_COOKIE["tc"];
die();
}
?>
<!DOCTYPE html>
<html>
<body>
<form method="post">
<input name="cookie_value">
<input type="submit" value="Set cookie">
</form>
</body>

View file

@ -1,19 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Index page</title>
</head>
<body>
<form action="#">
<div>
<input type="text" name="source" id="source"
onkeyup="document.getElementById('target').innerHTML = this.value" value="bar">
</div>
</form>
<div id="target"></div>
</body>
</html>

View file

@ -1,26 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Index page</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<form action="#">
<select id="options-without-values" name="without">
<option>none selected</option>
<option id="one">One</option>
<option id="two">Two</option>
<option>Three</option>
</select>
<select id="options-with-values" name="with">
<option value="none">none selected</option>
<option value="one">One</option>
<option value="two">Two</option>
<option value="three">Three</option>
</select>
</form>
</body>
</html>

View file

@ -1,23 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Index page</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<form action="#">
<p>
<label for="phone">Téléphone</label>
<input type="text" name="phone" id="phone" />
</p>
<p>
<label for="daphone">DaPhone</label>
<input type="text" name="daphone" id="daphone" />
</p>
<input type="submit" value="Send" />
</form>
</body>
</html>

View file

@ -1,9 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<form action="/" method="post" id="user-login-form">
<input type="submit" name="toto" id="jaguar-button" value="jaguar"/>
<input type="submit" name="toto" id="poney-button" value="poney"/>
</form>
</body>
</html>

View file

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Index page</title>
</head>
<body>
<form action="#">
<textarea rows="10" cols="10" id="textarea">
foo
bar
</textarea>
</form>
</body>
</html>

View file

@ -1,20 +0,0 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Index page</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<script src="js/jquery-1.6.2-min.js"></script>
</head>
<body>
<button id="btn">Créer un compte</button>
<div id="panel"></div>
<script type="text/javascript">
$('#btn').click(function () {
$('#panel').text('OH ' + 'AIH!');
});
</script>
</body>
</html>

View file

@ -1,33 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Issue 255</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<script src="js/jquery-1.6.2-min.js"></script>
</head>
<body>
<form>
<label for="foo_select">Foo</label>
<select name="foo_select" id="foo_select">
<option value="1" selected="selected">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<input type="checkbox" id="foo_check" />
<input type="submit" />
<p id="output_foo_select"></p>
<p id="output_foo_check"></p>
</form>
<script type="text/javascript">
(function() {
$('#foo_select').change(function () {
$('#output_foo_select').text("onChangeSelect");
});
$('#foo_check').change(function () {
$('#output_foo_check').text("onChangeCheck");
});
})();
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

View file

@ -1,127 +0,0 @@
/*!
* jQuery UI 1.8.14
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI
*/
(function(c,j){function k(a,b){var d=a.nodeName.toLowerCase();if("area"===d){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&l(a)}return(/input|select|textarea|button|object/.test(d)?!a.disabled:"a"==d?a.href||b:b)&&l(a)}function l(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.14",
keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();
b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,
"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",
function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,m,n){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(m)g-=parseFloat(c.curCSS(f,"border"+this+"Width",true))||0;if(n)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,
outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h,d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){return k(a,!isNaN(c.attr(a,"tabindex")))},tabbable:function(a){var b=c.attr(a,"tabindex"),d=isNaN(b);
return(d||b>=0)&&k(a,!d)}});c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=
0;e<b.length;e++)a.options[b[e][0]]&&b[e][1].apply(a.element,d)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(a,b){if(c(a).css("overflow")==="hidden")return false;b=b&&b==="left"?"scrollLeft":"scrollTop";var d=false;if(a[b]>0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a<b+d},isOver:function(a,b,d,e,h,i){return c.ui.isOverAxis(a,d,h)&&c.ui.isOverAxis(b,e,i)}})}})(jQuery);
;/*!
* jQuery UI Widget 1.8.14
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Widget
*/
(function(b,j){if(b.cleanData){var k=b.cleanData;b.cleanData=function(a){for(var c=0,d;(d=a[c])!=null;c++)b(d).triggerHandler("remove");k(a)}}else{var l=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add([this]).each(function(){b(this).triggerHandler("remove")});return l.call(b(this),a,c)})}}b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=function(h){return!!b.data(h,
a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend(true,{},c.options);b[e][a].prototype=b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):d;if(e&&d.charAt(0)==="_")return h;
e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==j){h=i;return false}}):this.each(function(){var g=b.data(this,a);g?g.option(d||{})._init():b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){b.data(c,this.widgetName,this);this.element=b(c);this.options=b.extend(true,{},this.options,
this._getCreateOptions(),a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},
widget:function(){return this.element},option:function(a,c){var d=a;if(arguments.length===0)return b.extend({},this.options);if(typeof a==="string"){if(c===j)return this.options[a];d={};d[a]=c}this._setOptions(d);return this},_setOptions:function(a){var c=this;b.each(a,function(d,e){c._setOption(d,e)});return this},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",c);return this},
enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery);
;/*!
* jQuery UI Mouse 1.8.14
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Mouse
*
* Depends:
* jquery.ui.widget.js
*/
(function(b){var d=false;b(document).mousedown(function(){d=false});b.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var a=this;this.element.bind("mousedown."+this.widgetName,function(c){return a._mouseDown(c)}).bind("click."+this.widgetName,function(c){if(true===b.data(c.target,a.widgetName+".preventClickEvent")){b.removeData(c.target,a.widgetName+".preventClickEvent");c.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+
this.widgetName)},_mouseDown:function(a){if(!d){this._mouseStarted&&this._mouseUp(a);this._mouseDownEvent=a;var c=this,f=a.which==1,g=typeof this.options.cancel=="string"?b(a.target).closest(this.options.cancel).length:false;if(!f||g||!this._mouseCapture(a))return true;this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet)this._mouseDelayTimer=setTimeout(function(){c.mouseDelayMet=true},this.options.delay);if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a)){this._mouseStarted=this._mouseStart(a)!==
false;if(!this._mouseStarted){a.preventDefault();return true}}true===b.data(a.target,this.widgetName+".preventClickEvent")&&b.removeData(a.target,this.widgetName+".preventClickEvent");this._mouseMoveDelegate=function(e){return c._mouseMove(e)};this._mouseUpDelegate=function(e){return c._mouseUp(e)};b(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);a.preventDefault();return d=true}},_mouseMove:function(a){if(b.browser.msie&&
!(document.documentMode>=9)&&!a.button)return this._mouseUp(a);if(this._mouseStarted){this._mouseDrag(a);return a.preventDefault()}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a);return!this._mouseStarted},_mouseUp:function(a){b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=
false;a.target==this._mouseDownEvent.target&&b.data(a.target,this.widgetName+".preventClickEvent",true);this._mouseStop(a)}return false},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);
;/*
* jQuery UI Draggable 1.8.14
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Draggables
*
* Depends:
* jquery.ui.core.js
* jquery.ui.mouse.js
* jquery.ui.widget.js
*/
(function(d){d.widget("ui.draggable",d.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper==
"original"&&!/^(?:r|a|f)/.test(this.element.css("position")))this.element[0].style.position="relative";this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(a){var b=
this.options;if(this.helper||b.disabled||d(a.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(a);if(!this.handle)return false;d(b.iframeFix===true?"iframe":b.iframeFix).each(function(){d('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(d(this).offset()).appendTo("body")});return true},_mouseStart:function(a){var b=this.options;this.helper=
this._createHelper(a);this._cacheHelperProportions();if(d.ui.ddmanager)d.ui.ddmanager.current=this;this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};d.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});
this.originalPosition=this.position=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);b.containment&&this._setContainment();if(this._trigger("start",a)===false){this._clear();return false}this._cacheHelperProportions();d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(a,true);d.ui.ddmanager&&d.ui.ddmanager.dragStart(this,a);return true},
_mouseDrag:function(a,b){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute");if(!b){b=this._uiHash();if(this._trigger("drag",a,b)===false){this._mouseUp({});return false}this.position=b.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);return false},_mouseStop:function(a){var b=
false;if(d.ui.ddmanager&&!this.options.dropBehaviour)b=d.ui.ddmanager.drop(this,a);if(this.dropped){b=this.dropped;this.dropped=false}if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original")return false;if(this.options.revert=="invalid"&&!b||this.options.revert=="valid"&&b||this.options.revert===true||d.isFunction(this.options.revert)&&this.options.revert.call(this.element,b)){var c=this;d(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,
10),function(){c._trigger("stop",a)!==false&&c._clear()})}else this._trigger("stop",a)!==false&&this._clear();return false},_mouseUp:function(a){this.options.iframeFix===true&&d("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});d.ui.ddmanager&&d.ui.ddmanager.dragStop(this,a);return d.ui.mouse.prototype._mouseUp.call(this,a)},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(a){var b=!this.options.handle||
!d(this.options.handle,this.element).length?true:false;d(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==a.target)b=true});return b},_createHelper:function(a){var b=this.options;a=d.isFunction(b.helper)?d(b.helper.apply(this.element[0],[a])):b.helper=="clone"?this.element.clone().removeAttr("id"):this.element;a.parents("body").length||a.appendTo(b.appendTo=="parent"?this.element[0].parentNode:b.appendTo);a[0]!=this.element[0]&&!/(fixed|absolute)/.test(a.css("position"))&&
a.css("position","absolute");return a},_adjustOffsetFromHelper:function(a){if(typeof a=="string")a=a.split(" ");if(d.isArray(a))a={left:+a[0],top:+a[1]||0};if("left"in a)this.offset.click.left=a.left+this.margins.left;if("right"in a)this.offset.click.left=this.helperProportions.width-a.right+this.margins.left;if("top"in a)this.offset.click.top=a.top+this.margins.top;if("bottom"in a)this.offset.click.top=this.helperProportions.height-a.bottom+this.margins.top},_getParentOffset:function(){this.offsetParent=
this.helper.offsetParent();var a=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0])){a.left+=this.scrollParent.scrollLeft();a.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&d.browser.msie)a={top:0,left:0};return{top:a.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:a.left+(parseInt(this.offsetParent.css("borderLeftWidth"),
10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.element.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),
10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var a=this.options;if(a.containment=="parent")a.containment=this.helper[0].parentNode;if(a.containment=="document"||a.containment=="window")this.containment=[a.containment=="document"?0:d(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,a.containment=="document"?0:d(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,
(a.containment=="document"?0:d(window).scrollLeft())+d(a.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a.containment=="document"?0:d(window).scrollTop())+(d(a.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(a.containment)&&a.containment.constructor!=Array){a=d(a.containment);var b=a[0];if(b){a.offset();var c=d(b).css("overflow")!=
"hidden";this.containment=[(parseInt(d(b).css("borderLeftWidth"),10)||0)+(parseInt(d(b).css("paddingLeft"),10)||0),(parseInt(d(b).css("borderTopWidth"),10)||0)+(parseInt(d(b).css("paddingTop"),10)||0),(c?Math.max(b.scrollWidth,b.offsetWidth):b.offsetWidth)-(parseInt(d(b).css("borderLeftWidth"),10)||0)-(parseInt(d(b).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(c?Math.max(b.scrollHeight,b.offsetHeight):b.offsetHeight)-(parseInt(d(b).css("borderTopWidth"),
10)||0)-(parseInt(d(b).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom];this.relative_container=a}}else if(a.containment.constructor==Array)this.containment=a.containment},_convertPositionTo:function(a,b){if(!b)b=this.position;a=a=="absolute"?1:-1;var c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName);return{top:b.top+
this.offset.relative.top*a+this.offset.parent.top*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():f?0:c.scrollTop())*a),left:b.left+this.offset.relative.left*a+this.offset.parent.left*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():f?0:c.scrollLeft())*a)}},_generatePosition:function(a){var b=this.options,c=this.cssPosition=="absolute"&&
!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName),e=a.pageX,h=a.pageY;if(this.originalPosition){var g;if(this.containment){if(this.relative_container){g=this.relative_container.offset();g=[this.containment[0]+g.left,this.containment[1]+g.top,this.containment[2]+g.left,this.containment[3]+g.top]}else g=this.containment;if(a.pageX-this.offset.click.left<g[0])e=g[0]+this.offset.click.left;
if(a.pageY-this.offset.click.top<g[1])h=g[1]+this.offset.click.top;if(a.pageX-this.offset.click.left>g[2])e=g[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>g[3])h=g[3]+this.offset.click.top}if(b.grid){h=b.grid[1]?this.originalPageY+Math.round((h-this.originalPageY)/b.grid[1])*b.grid[1]:this.originalPageY;h=g?!(h-this.offset.click.top<g[1]||h-this.offset.click.top>g[3])?h:!(h-this.offset.click.top<g[1])?h-b.grid[1]:h+b.grid[1]:h;e=b.grid[0]?this.originalPageX+Math.round((e-this.originalPageX)/
b.grid[0])*b.grid[0]:this.originalPageX;e=g?!(e-this.offset.click.left<g[0]||e-this.offset.click.left>g[2])?e:!(e-this.offset.click.left<g[0])?e-b.grid[0]:e+b.grid[0]:e}}return{top:h-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():f?0:c.scrollTop()),left:e-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(d.browser.safari&&d.browser.version<
526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():f?0:c.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging");this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove();this.helper=null;this.cancelHelperRemoval=false},_trigger:function(a,b,c){c=c||this._uiHash();d.ui.plugin.call(this,a,[b,c]);if(a=="drag")this.positionAbs=this._convertPositionTo("absolute");return d.Widget.prototype._trigger.call(this,a,b,
c)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}});d.extend(d.ui.draggable,{version:"1.8.14"});d.ui.plugin.add("draggable","connectToSortable",{start:function(a,b){var c=d(this).data("draggable"),f=c.options,e=d.extend({},b,{item:c.element});c.sortables=[];d(f.connectToSortable).each(function(){var h=d.data(this,"sortable");if(h&&!h.options.disabled){c.sortables.push({instance:h,shouldRevert:h.options.revert});
h.refreshPositions();h._trigger("activate",a,e)}})},stop:function(a,b){var c=d(this).data("draggable"),f=d.extend({},b,{item:c.element});d.each(c.sortables,function(){if(this.instance.isOver){this.instance.isOver=0;c.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert)this.instance.options.revert=true;this.instance._mouseStop(a);this.instance.options.helper=this.instance.options._helper;c.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})}else{this.instance.cancelHelperRemoval=
false;this.instance._trigger("deactivate",a,f)}})},drag:function(a,b){var c=d(this).data("draggable"),f=this;d.each(c.sortables,function(){this.instance.positionAbs=c.positionAbs;this.instance.helperProportions=c.helperProportions;this.instance.offset.click=c.offset.click;if(this.instance._intersectsWith(this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=d(f).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",true);
this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return b.helper[0]};a.target=this.instance.currentItem[0];this.instance._mouseCapture(a,true);this.instance._mouseStart(a,true,true);this.instance.offset.click.top=c.offset.click.top;this.instance.offset.click.left=c.offset.click.left;this.instance.offset.parent.left-=c.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=c.offset.parent.top-this.instance.offset.parent.top;
c._trigger("toSortable",a);c.dropped=this.instance.element;c.currentItem=c.element;this.instance.fromOutside=c}this.instance.currentItem&&this.instance._mouseDrag(a)}else if(this.instance.isOver){this.instance.isOver=0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance._trigger("out",a,this.instance._uiHash(this.instance));this.instance._mouseStop(a,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();this.instance.placeholder&&
this.instance.placeholder.remove();c._trigger("fromSortable",a);c.dropped=false}})}});d.ui.plugin.add("draggable","cursor",{start:function(){var a=d("body"),b=d(this).data("draggable").options;if(a.css("cursor"))b._cursor=a.css("cursor");a.css("cursor",b.cursor)},stop:function(){var a=d(this).data("draggable").options;a._cursor&&d("body").css("cursor",a._cursor)}});d.ui.plugin.add("draggable","opacity",{start:function(a,b){a=d(b.helper);b=d(this).data("draggable").options;if(a.css("opacity"))b._opacity=
a.css("opacity");a.css("opacity",b.opacity)},stop:function(a,b){a=d(this).data("draggable").options;a._opacity&&d(b.helper).css("opacity",a._opacity)}});d.ui.plugin.add("draggable","scroll",{start:function(){var a=d(this).data("draggable");if(a.scrollParent[0]!=document&&a.scrollParent[0].tagName!="HTML")a.overflowOffset=a.scrollParent.offset()},drag:function(a){var b=d(this).data("draggable"),c=b.options,f=false;if(b.scrollParent[0]!=document&&b.scrollParent[0].tagName!="HTML"){if(!c.axis||c.axis!=
"x")if(b.overflowOffset.top+b.scrollParent[0].offsetHeight-a.pageY<c.scrollSensitivity)b.scrollParent[0].scrollTop=f=b.scrollParent[0].scrollTop+c.scrollSpeed;else if(a.pageY-b.overflowOffset.top<c.scrollSensitivity)b.scrollParent[0].scrollTop=f=b.scrollParent[0].scrollTop-c.scrollSpeed;if(!c.axis||c.axis!="y")if(b.overflowOffset.left+b.scrollParent[0].offsetWidth-a.pageX<c.scrollSensitivity)b.scrollParent[0].scrollLeft=f=b.scrollParent[0].scrollLeft+c.scrollSpeed;else if(a.pageX-b.overflowOffset.left<
c.scrollSensitivity)b.scrollParent[0].scrollLeft=f=b.scrollParent[0].scrollLeft-c.scrollSpeed}else{if(!c.axis||c.axis!="x")if(a.pageY-d(document).scrollTop()<c.scrollSensitivity)f=d(document).scrollTop(d(document).scrollTop()-c.scrollSpeed);else if(d(window).height()-(a.pageY-d(document).scrollTop())<c.scrollSensitivity)f=d(document).scrollTop(d(document).scrollTop()+c.scrollSpeed);if(!c.axis||c.axis!="y")if(a.pageX-d(document).scrollLeft()<c.scrollSensitivity)f=d(document).scrollLeft(d(document).scrollLeft()-
c.scrollSpeed);else if(d(window).width()-(a.pageX-d(document).scrollLeft())<c.scrollSensitivity)f=d(document).scrollLeft(d(document).scrollLeft()+c.scrollSpeed)}f!==false&&d.ui.ddmanager&&!c.dropBehaviour&&d.ui.ddmanager.prepareOffsets(b,a)}});d.ui.plugin.add("draggable","snap",{start:function(){var a=d(this).data("draggable"),b=a.options;a.snapElements=[];d(b.snap.constructor!=String?b.snap.items||":data(draggable)":b.snap).each(function(){var c=d(this),f=c.offset();this!=a.element[0]&&a.snapElements.push({item:this,
width:c.outerWidth(),height:c.outerHeight(),top:f.top,left:f.left})})},drag:function(a,b){for(var c=d(this).data("draggable"),f=c.options,e=f.snapTolerance,h=b.offset.left,g=h+c.helperProportions.width,n=b.offset.top,o=n+c.helperProportions.height,i=c.snapElements.length-1;i>=0;i--){var j=c.snapElements[i].left,l=j+c.snapElements[i].width,k=c.snapElements[i].top,m=k+c.snapElements[i].height;if(j-e<h&&h<l+e&&k-e<n&&n<m+e||j-e<h&&h<l+e&&k-e<o&&o<m+e||j-e<g&&g<l+e&&k-e<n&&n<m+e||j-e<g&&g<l+e&&k-e<o&&
o<m+e){if(f.snapMode!="inner"){var p=Math.abs(k-o)<=e,q=Math.abs(m-n)<=e,r=Math.abs(j-g)<=e,s=Math.abs(l-h)<=e;if(p)b.position.top=c._convertPositionTo("relative",{top:k-c.helperProportions.height,left:0}).top-c.margins.top;if(q)b.position.top=c._convertPositionTo("relative",{top:m,left:0}).top-c.margins.top;if(r)b.position.left=c._convertPositionTo("relative",{top:0,left:j-c.helperProportions.width}).left-c.margins.left;if(s)b.position.left=c._convertPositionTo("relative",{top:0,left:l}).left-c.margins.left}var t=
p||q||r||s;if(f.snapMode!="outer"){p=Math.abs(k-n)<=e;q=Math.abs(m-o)<=e;r=Math.abs(j-h)<=e;s=Math.abs(l-g)<=e;if(p)b.position.top=c._convertPositionTo("relative",{top:k,left:0}).top-c.margins.top;if(q)b.position.top=c._convertPositionTo("relative",{top:m-c.helperProportions.height,left:0}).top-c.margins.top;if(r)b.position.left=c._convertPositionTo("relative",{top:0,left:j}).left-c.margins.left;if(s)b.position.left=c._convertPositionTo("relative",{top:0,left:l-c.helperProportions.width}).left-c.margins.left}if(!c.snapElements[i].snapping&&
(p||q||r||s||t))c.options.snap.snap&&c.options.snap.snap.call(c.element,a,d.extend(c._uiHash(),{snapItem:c.snapElements[i].item}));c.snapElements[i].snapping=p||q||r||s||t}else{c.snapElements[i].snapping&&c.options.snap.release&&c.options.snap.release.call(c.element,a,d.extend(c._uiHash(),{snapItem:c.snapElements[i].item}));c.snapElements[i].snapping=false}}}});d.ui.plugin.add("draggable","stack",{start:function(){var a=d(this).data("draggable").options;a=d.makeArray(d(a.stack)).sort(function(c,f){return(parseInt(d(c).css("zIndex"),
10)||0)-(parseInt(d(f).css("zIndex"),10)||0)});if(a.length){var b=parseInt(a[0].style.zIndex)||0;d(a).each(function(c){this.style.zIndex=b+c});this[0].style.zIndex=b+a.length}}});d.ui.plugin.add("draggable","zIndex",{start:function(a,b){a=d(b.helper);b=d(this).data("draggable").options;if(a.css("zIndex"))b._zIndex=a.css("zIndex");a.css("zIndex",b.zIndex)},stop:function(a,b){a=d(this).data("draggable").options;a._zIndex&&d(b.helper).css("zIndex",a._zIndex)}})})(jQuery);
;/*
* jQuery UI Droppable 1.8.14
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Droppables
*
* Depends:
* jquery.ui.core.js
* jquery.ui.widget.js
* jquery.ui.mouse.js
* jquery.ui.draggable.js
*/
(function(d){d.widget("ui.droppable",{widgetEventPrefix:"drop",options:{accept:"*",activeClass:false,addClasses:true,greedy:false,hoverClass:false,scope:"default",tolerance:"intersect"},_create:function(){var a=this.options,b=a.accept;this.isover=0;this.isout=1;this.accept=d.isFunction(b)?b:function(c){return c.is(b)};this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight};d.ui.ddmanager.droppables[a.scope]=d.ui.ddmanager.droppables[a.scope]||[];d.ui.ddmanager.droppables[a.scope].push(this);
a.addClasses&&this.element.addClass("ui-droppable")},destroy:function(){for(var a=d.ui.ddmanager.droppables[this.options.scope],b=0;b<a.length;b++)a[b]==this&&a.splice(b,1);this.element.removeClass("ui-droppable ui-droppable-disabled").removeData("droppable").unbind(".droppable");return this},_setOption:function(a,b){if(a=="accept")this.accept=d.isFunction(b)?b:function(c){return c.is(b)};d.Widget.prototype._setOption.apply(this,arguments)},_activate:function(a){var b=d.ui.ddmanager.current;this.options.activeClass&&
this.element.addClass(this.options.activeClass);b&&this._trigger("activate",a,this.ui(b))},_deactivate:function(a){var b=d.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass);b&&this._trigger("deactivate",a,this.ui(b))},_over:function(a){var b=d.ui.ddmanager.current;if(!(!b||(b.currentItem||b.element)[0]==this.element[0]))if(this.accept.call(this.element[0],b.currentItem||b.element)){this.options.hoverClass&&this.element.addClass(this.options.hoverClass);
this._trigger("over",a,this.ui(b))}},_out:function(a){var b=d.ui.ddmanager.current;if(!(!b||(b.currentItem||b.element)[0]==this.element[0]))if(this.accept.call(this.element[0],b.currentItem||b.element)){this.options.hoverClass&&this.element.removeClass(this.options.hoverClass);this._trigger("out",a,this.ui(b))}},_drop:function(a,b){var c=b||d.ui.ddmanager.current;if(!c||(c.currentItem||c.element)[0]==this.element[0])return false;var e=false;this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function(){var g=
d.data(this,"droppable");if(g.options.greedy&&!g.options.disabled&&g.options.scope==c.options.scope&&g.accept.call(g.element[0],c.currentItem||c.element)&&d.ui.intersect(c,d.extend(g,{offset:g.element.offset()}),g.options.tolerance)){e=true;return false}});if(e)return false;if(this.accept.call(this.element[0],c.currentItem||c.element)){this.options.activeClass&&this.element.removeClass(this.options.activeClass);this.options.hoverClass&&this.element.removeClass(this.options.hoverClass);this._trigger("drop",
a,this.ui(c));return this.element}return false},ui:function(a){return{draggable:a.currentItem||a.element,helper:a.helper,position:a.position,offset:a.positionAbs}}});d.extend(d.ui.droppable,{version:"1.8.14"});d.ui.intersect=function(a,b,c){if(!b.offset)return false;var e=(a.positionAbs||a.position.absolute).left,g=e+a.helperProportions.width,f=(a.positionAbs||a.position.absolute).top,h=f+a.helperProportions.height,i=b.offset.left,k=i+b.proportions.width,j=b.offset.top,l=j+b.proportions.height;
switch(c){case "fit":return i<=e&&g<=k&&j<=f&&h<=l;case "intersect":return i<e+a.helperProportions.width/2&&g-a.helperProportions.width/2<k&&j<f+a.helperProportions.height/2&&h-a.helperProportions.height/2<l;case "pointer":return d.ui.isOver((a.positionAbs||a.position.absolute).top+(a.clickOffset||a.offset.click).top,(a.positionAbs||a.position.absolute).left+(a.clickOffset||a.offset.click).left,j,i,b.proportions.height,b.proportions.width);case "touch":return(f>=j&&f<=l||h>=j&&h<=l||f<j&&h>l)&&(e>=
i&&e<=k||g>=i&&g<=k||e<i&&g>k);default:return false}};d.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(a,b){var c=d.ui.ddmanager.droppables[a.options.scope]||[],e=b?b.type:null,g=(a.currentItem||a.element).find(":data(droppable)").andSelf(),f=0;a:for(;f<c.length;f++)if(!(c[f].options.disabled||a&&!c[f].accept.call(c[f].element[0],a.currentItem||a.element))){for(var h=0;h<g.length;h++)if(g[h]==c[f].element[0]){c[f].proportions.height=0;continue a}c[f].visible=c[f].element.css("display")!=
"none";if(c[f].visible){e=="mousedown"&&c[f]._activate.call(c[f],b);c[f].offset=c[f].element.offset();c[f].proportions={width:c[f].element[0].offsetWidth,height:c[f].element[0].offsetHeight}}}},drop:function(a,b){var c=false;d.each(d.ui.ddmanager.droppables[a.options.scope]||[],function(){if(this.options){if(!this.options.disabled&&this.visible&&d.ui.intersect(a,this,this.options.tolerance))c=c||this._drop.call(this,b);if(!this.options.disabled&&this.visible&&this.accept.call(this.element[0],a.currentItem||
a.element)){this.isout=1;this.isover=0;this._deactivate.call(this,b)}}});return c},dragStart:function(a,b){a.element.parentsUntil("body").bind("scroll.droppable",function(){a.options.refreshPositions||d.ui.ddmanager.prepareOffsets(a,b)})},drag:function(a,b){a.options.refreshPositions&&d.ui.ddmanager.prepareOffsets(a,b);d.each(d.ui.ddmanager.droppables[a.options.scope]||[],function(){if(!(this.options.disabled||this.greedyChild||!this.visible)){var c=d.ui.intersect(a,this,this.options.tolerance);if(c=
!c&&this.isover==1?"isout":c&&this.isover==0?"isover":null){var e;if(this.options.greedy){var g=this.element.parents(":data(droppable):eq(0)");if(g.length){e=d.data(g[0],"droppable");e.greedyChild=c=="isover"?1:0}}if(e&&c=="isover"){e.isover=0;e.isout=1;e._out.call(e,b)}this[c]=1;this[c=="isout"?"isover":"isout"]=0;this[c=="isover"?"_over":"_out"].call(this,b);if(e&&c=="isout"){e.isout=0;e.isover=1;e._over.call(e,b)}}}})},dragStop:function(a,b){a.element.parentsUntil("body").unbind("scroll.droppable");
a.options.refreshPositions||d.ui.ddmanager.prepareOffsets(a,b)}}})(jQuery);
;

View file

@ -1,114 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>JS elements test</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<style>
#draggable {
width: 100px; height: 100px; padding: 0.5em; float: left; margin: 10px 10px 10px 0;
background:#ccc;
opacity:0.5;
}
#droppable {
width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px;
background:#eee;
}
#waitable {
width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px;
background:#eee;
}
</style>
</head>
<body>
<div class="elements">
<div id="clicker">not clicked</div>
<div id="mouseover-detector">no mouse action detected</div>
<div id="invisible" style="display: none">invisible man</div>
<input id="focus-blur-detector" type="text" value="no action detected"/>
<input class="input first" type="text" value="" />
<input class="input second" type="text" value="" />
<input class="input third" type="text" value="" />
<div class="text-event"></div>
</div>
<div id="draggable" class="ui-widget-content"></div>
<div id="droppable" class="ui-widget-header">
<p>Drop here</p>
</div>
<div id="waitable"></div>
<script src="js/jquery-1.6.2-min.js"></script>
<script src="js/jquery-ui-1.8.14.custom.min.js"></script>
<script>
$(document).ready(function() {
var $clicker = $('#clicker');
$clicker.click(function() {
$(this).text('single clicked');
});
$clicker.dblclick(function() {
$(this).text('double clicked');
});
$clicker.bind('contextmenu', function() {
$(this).text('right clicked');
});
var $focusDetector = $('#focus-blur-detector');
$focusDetector.focus(function() {
$(this).val('focused');
});
$focusDetector.blur(function() {
$(this).val('blured');
});
$('#mouseover-detector').mouseover(function() {
$(this).text('mouse overed');
});
$('.elements input.input.first').keydown(function(ev) {
$('.text-event').text('key downed:' + ev.altKey * 1 + ' / ' + ev.ctrlKey * 1 + ' / ' + ev.shiftKey * 1 + ' / ' + ev.metaKey * 1);
});
$('.elements input.input.second').keypress(function(ev) {
$('.text-event').text('key pressed:' + ev.which + ' / ' + ev.altKey * 1 + ' / ' + ev.ctrlKey * 1 + ' / ' + ev.shiftKey * 1 + ' / ' + ev.metaKey * 1);
});
$('.elements input.input.third').keyup(function(ev) {
$('.text-event').text('key upped:' + ev.which + ' / ' + ev.altKey * 1 + ' / ' + ev.ctrlKey * 1 + ' / ' + ev.shiftKey * 1 + ' / ' + ev.metaKey * 1);
});
$( "#draggable" ).draggable();
$( "#droppable" ).droppable({
drop: function( event, ui ) {
$( this ).find( "p" ).html( "Dropped!" );
}
});
var t1, t2;
$('#waitable').click(function() {
var el = $(this);
el.html('');
clearTimeout(t1);
clearTimeout(t2);
t1 = setTimeout(function() {
el.html('<div>arrived</div>');
}, 1000);
t2 = setTimeout(function() {
el.html('<div>timeout</div>');
}, 2000);
});
});
</script>
</body>
</html>

View file

@ -1,7 +0,0 @@
<?php
echo json_encode(array(
'key1' => 'val1',
'key2' => 234,
'key3' => array(1, 2, 3)
));

View file

@ -1,15 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Links page</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<a href="redirector.php">Redirect me to</a>
<a href="randomizer.php">Random number page</a>
<a href="links.html?quoted">Link with a '</a>
<a href="basic_form.html">
<img src="basic_form" alt="basic form image"/>
</a>
</body>
</html>

View file

@ -1,27 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Multi input Test</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<h1>Multi input Test</h1>
<form method="POST" action="advanced_form_post.php">
<label>
First
<input type="text" name="tags[]" value="tag1">
</label>
<label>
Second
<input type="text" name="tags[]" value="tag2">
</label>
<label>
Third
<input type="text" name="tags[]" value="tag1">
</label>
<input type="submit" name="submit" value="Register" />
</form>
</body>
</html>

View file

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Multicheckbox Test</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<h1>Multicheckbox Test</h1>
<form method="POST" action="advanced_form_post.php">
<input type="checkbox" name="mail_types[]" checked="checked" value="update"/>
<input type="checkbox" name="mail_types[]" value="spam"/>
<input type="submit" name="submit" value="Register" />
</form>
</body>
</html>

View file

@ -1,32 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Multiselect Test</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<h1>Multiselect Test</h1>
<form method="POST" action="advanced_form_post.php">
<select name="select_number">
<option value="10">ten</option>
<option selected="selected" value="20">twenty</option>
<option value="30">thirty</option>
</select>
<select name="select_multiple_numbers[]" multiple="multiple">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>
<select name="select_multiple_values[]" multiple="multiple">
<option value="1">one</option>
<option value="2" selected="selected">two</option>
<option value="3" selected="selected">three</option>
</select>
<input type="submit" name="submit" value="Register" />
</form>
</body>
</html>

View file

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>popup_1</title>
</head>
<body>
<div id="text">
Popup#1 div text
</div>
</body>
</html>

View file

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>popup_2</title>
</head>
<body>
<div id="text">
Popup#2 div text
</div>
</body>
</html>

View file

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Cookies page</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<?php echo str_replace('>', '', var_export($_COOKIE, true)); ?>
</body>
</html>

View file

@ -1,21 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Radio group</title>
</head>
<body>
<form id="form1">
<input name="group1" type="radio" value="set" id="first" checked="checked">
<input name="group1" type="radio" value="updated" id="second">
<input name="reused" type="radio" value="test" id="reused_form1">
<input name="reused" type="radio" value="test2" id="reused2_form1" checked="checked">
</form>
<form id="form2">
<input name="reused" type="radio" value="test3" id="reused_form2" checked="checked">
<input name="reused" type="radio" value="test4" id="reused2_form2">
</form>
</body>
</html>

View file

@ -1,12 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Index page</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<h1 id="number"><?php echo rand() ?></h1>
</body>
</html>

View file

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Redirect destination</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
You were redirected!
</body>
</html>

View file

@ -1,3 +0,0 @@
<?php
header('location: redirect_destination.html');

View file

@ -1,15 +0,0 @@
<?php
header('X-Mink-Test: response-headers');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Response headers</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<h1>Response headers</h1>
</body>
</html>

View file

@ -1,18 +0,0 @@
<?php
session_name('_SESS');
session_start();
if (isset($_GET['login'])) {
session_regenerate_id();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Session Test</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<div id="session-id"><?php echo session_id() ?></div>
</body>
</html>

View file

@ -1 +0,0 @@
1 uploaded file

View file

@ -1,4 +0,0 @@
<?php
$cookieAtRootPath = false;
$cookieValue = 'srv_var_is_set_sub_folder';
require_once __DIR__ . '/../' . basename(__FILE__);

View file

@ -1,2 +0,0 @@
<?php
require_once __DIR__ . '/../' . basename(__FILE__);

View file

@ -1,26 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<script>
function newPopup(url, title) {
popupWindow = window.open(
url, title,'height=100,width=200,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes'
);
}
</script>
<a href="popup1.html" onclick="newPopup(this.href, 'popup_1'); return false;">
Popup #1
</a>
<a href="popup2.html" onclick="newPopup(this.href, 'popup_2'); return false;">
Popup #2
</a>
<div id="text">
Main window div text
</div>
</body>
</html>

View file

@ -1,110 +0,0 @@
<?php
namespace Behat\Mink\Tests\Driver;
use Behat\Mink\Element\NodeElement;
class CoreDriverTest extends \PHPUnit_Framework_TestCase
{
public function testNoExtraMethods()
{
$interfaceRef = new \ReflectionClass('Behat\Mink\Driver\DriverInterface');
$coreDriverRef = new \ReflectionClass('Behat\Mink\Driver\CoreDriver');
foreach ($coreDriverRef->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
$this->assertTrue(
$interfaceRef->hasMethod($method->getName()),
sprintf('CoreDriver should not implement methods which are not part of the DriverInterface but %s found', $method->getName())
);
}
}
public function testCreateNodeElements()
{
$driver = $this->getMockBuilder('Behat\Mink\Driver\CoreDriver')
->setMethods(array('findElementXpaths'))
->getMockForAbstractClass();
$session = $this->getMockBuilder('Behat\Mink\Session')
->disableOriginalConstructor()
->getMock();
$driver->setSession($session);
$driver->expects($this->once())
->method('findElementXpaths')
->with('xpath')
->willReturn(array('xpath1', 'xpath2'));
/** @var NodeElement[] $elements */
$elements = $driver->find('xpath');
$this->assertInternalType('array', $elements);
$this->assertCount(2, $elements);
$this->assertContainsOnlyInstancesOf('Behat\Mink\Element\NodeElement', $elements);
$this->assertSame('xpath1', $elements[0]->getXpath());
$this->assertSame('xpath2', $elements[1]->getXpath());
}
/**
* @dataProvider getDriverInterfaceMethods
*/
public function testInterfaceMethods(\ReflectionMethod $method)
{
$refl = new \ReflectionClass('Behat\Mink\Driver\CoreDriver');
$this->assertFalse(
$refl->getMethod($method->getName())->isAbstract(),
sprintf('CoreDriver should implement a dummy %s method', $method->getName())
);
if ('setSession' === $method->getName()) {
return; // setSession is actually implemented, so we don't expect an exception here.
}
$driver = $this->getMockForAbstractClass('Behat\Mink\Driver\CoreDriver');
$this->setExpectedException('Behat\Mink\Exception\UnsupportedDriverActionException');
call_user_func_array(array($driver, $method->getName()), $this->getArguments($method));
}
public function getDriverInterfaceMethods()
{
$ref = new \ReflectionClass('Behat\Mink\Driver\DriverInterface');
return array_map(function ($method) {
return array($method);
}, $ref->getMethods());
}
private function getArguments(\ReflectionMethod $method)
{
$arguments = array();
foreach ($method->getParameters() as $parameter) {
$arguments[] = $this->getArgument($parameter);
}
return $arguments;
}
private function getArgument(\ReflectionParameter $argument)
{
if ($argument->isOptional()) {
return $argument->getDefaultValue();
}
if ($argument->allowsNull()) {
return null;
}
if ($argument->getClass()) {
return $this->getMockBuilder($argument->getClass()->getName())
->disableOriginalConstructor()
->getMock();
}
return null;
}
}

View file

@ -1,449 +0,0 @@
<?php
namespace Behat\Mink\Tests\Element;
use Behat\Mink\Element\DocumentElement;
class DocumentElementTest extends ElementTest
{
/**
* Page.
*
* @var DocumentElement
*/
private $document;
protected function setUp()
{
parent::setUp();
$this->document = new DocumentElement($this->session);
}
/**
* @group legacy
*/
public function testGetSession()
{
$this->assertEquals($this->session, $this->document->getSession());
}
public function testFindAll()
{
$xpath = 'h3[a]';
$css = 'h3 > a';
$this->driver
->expects($this->exactly(2))
->method('find')
->will($this->returnValueMap(array(
array('//html/'.$xpath, array(2, 3, 4)),
array('//html/'.$css, array(1, 2)),
)));
$this->selectors
->expects($this->exactly(2))
->method('selectorToXpath')
->will($this->returnValueMap(array(
array('xpath', $xpath, $xpath),
array('css', $css, $css),
)));
$this->assertEquals(3, count($this->document->findAll('xpath', $xpath)));
$this->assertEquals(2, count($this->document->findAll('css', $css)));
}
public function testFind()
{
$this->driver
->expects($this->exactly(3))
->method('find')
->with('//html/h3[a]')
->will($this->onConsecutiveCalls(array(2, 3, 4), array(1, 2), array()));
$xpath = 'h3[a]';
$css = 'h3 > a';
$this->selectors
->expects($this->exactly(3))
->method('selectorToXpath')
->will($this->returnValueMap(array(
array('xpath', $xpath, $xpath),
array('xpath', $xpath, $xpath),
array('css', $css, $xpath),
)));
$this->assertEquals(2, $this->document->find('xpath', $xpath));
$this->assertEquals(1, $this->document->find('css', $css));
$this->assertNull($this->document->find('xpath', $xpath));
}
public function testFindField()
{
$this->mockNamedFinder(
'//field',
array('field1', 'field2', 'field3'),
array('field', 'some field')
);
$this->assertEquals('field1', $this->document->findField('some field'));
$this->assertEquals(null, $this->document->findField('some field'));
}
public function testFindLink()
{
$this->mockNamedFinder(
'//link',
array('link1', 'link2', 'link3'),
array('link', 'some link')
);
$this->assertEquals('link1', $this->document->findLink('some link'));
$this->assertEquals(null, $this->document->findLink('some link'));
}
public function testFindButton()
{
$this->mockNamedFinder(
'//button',
array('button1', 'button2', 'button3'),
array('button', 'some button')
);
$this->assertEquals('button1', $this->document->findButton('some button'));
$this->assertEquals(null, $this->document->findButton('some button'));
}
public function testFindById()
{
$xpath = '//*[@id=some-item-2]';
$this->mockNamedFinder($xpath, array(array('id2', 'id3'), array()), array('id', 'some-item-2'));
$this->assertEquals('id2', $this->document->findById('some-item-2'));
$this->assertEquals(null, $this->document->findById('some-item-2'));
}
public function testHasSelector()
{
$this->driver
->expects($this->exactly(2))
->method('find')
->with('//html/some xpath')
->will($this->onConsecutiveCalls(array('id2', 'id3'), array()));
$this->selectors
->expects($this->exactly(2))
->method('selectorToXpath')
->with('xpath', 'some xpath')
->will($this->returnValue('some xpath'));
$this->assertTrue($this->document->has('xpath', 'some xpath'));
$this->assertFalse($this->document->has('xpath', 'some xpath'));
}
public function testHasContent()
{
$this->mockNamedFinder(
'//some content',
array('item1', 'item2'),
array('content', 'some content')
);
$this->assertTrue($this->document->hasContent('some content'));
$this->assertFalse($this->document->hasContent('some content'));
}
public function testHasLink()
{
$this->mockNamedFinder(
'//link',
array('link1', 'link2', 'link3'),
array('link', 'some link')
);
$this->assertTrue($this->document->hasLink('some link'));
$this->assertFalse($this->document->hasLink('some link'));
}
public function testHasButton()
{
$this->mockNamedFinder(
'//button',
array('button1', 'button2', 'button3'),
array('button', 'some button')
);
$this->assertTrue($this->document->hasButton('some button'));
$this->assertFalse($this->document->hasButton('some button'));
}
public function testHasField()
{
$this->mockNamedFinder(
'//field',
array('field1', 'field2', 'field3'),
array('field', 'some field')
);
$this->assertTrue($this->document->hasField('some field'));
$this->assertFalse($this->document->hasField('some field'));
}
public function testHasCheckedField()
{
$checkbox = $this->getMockBuilder('Behat\Mink\Element\NodeElement')
->disableOriginalConstructor()
->getMock();
$checkbox
->expects($this->exactly(2))
->method('isChecked')
->will($this->onConsecutiveCalls(true, false));
$this->mockNamedFinder(
'//field',
array(array($checkbox), array(), array($checkbox)),
array('field', 'some checkbox'),
3
);
$this->assertTrue($this->document->hasCheckedField('some checkbox'));
$this->assertFalse($this->document->hasCheckedField('some checkbox'));
$this->assertFalse($this->document->hasCheckedField('some checkbox'));
}
public function testHasUncheckedField()
{
$checkbox = $this->getMockBuilder('Behat\Mink\Element\NodeElement')
->disableOriginalConstructor()
->getMock();
$checkbox
->expects($this->exactly(2))
->method('isChecked')
->will($this->onConsecutiveCalls(true, false));
$this->mockNamedFinder(
'//field',
array(array($checkbox), array(), array($checkbox)),
array('field', 'some checkbox'),
3
);
$this->assertFalse($this->document->hasUncheckedField('some checkbox'));
$this->assertFalse($this->document->hasUncheckedField('some checkbox'));
$this->assertTrue($this->document->hasUncheckedField('some checkbox'));
}
public function testHasSelect()
{
$this->mockNamedFinder(
'//select',
array('select'),
array('select', 'some select field')
);
$this->assertTrue($this->document->hasSelect('some select field'));
$this->assertFalse($this->document->hasSelect('some select field'));
}
public function testHasTable()
{
$this->mockNamedFinder(
'//table',
array('table'),
array('table', 'some table')
);
$this->assertTrue($this->document->hasTable('some table'));
$this->assertFalse($this->document->hasTable('some table'));
}
public function testClickLink()
{
$node = $this->getMockBuilder('Behat\Mink\Element\NodeElement')
->disableOriginalConstructor()
->getMock();
$node
->expects($this->once())
->method('click');
$this->mockNamedFinder(
'//link',
array($node),
array('link', 'some link')
);
$this->document->clickLink('some link');
$this->setExpectedException('Behat\Mink\Exception\ElementNotFoundException');
$this->document->clickLink('some link');
}
public function testClickButton()
{
$node = $this->getMockBuilder('Behat\Mink\Element\NodeElement')
->disableOriginalConstructor()
->getMock();
$node
->expects($this->once())
->method('press');
$this->mockNamedFinder(
'//button',
array($node),
array('button', 'some button')
);
$this->document->pressButton('some button');
$this->setExpectedException('Behat\Mink\Exception\ElementNotFoundException');
$this->document->pressButton('some button');
}
public function testFillField()
{
$node = $this->getMockBuilder('Behat\Mink\Element\NodeElement')
->disableOriginalConstructor()
->getMock();
$node
->expects($this->once())
->method('setValue')
->with('some val');
$this->mockNamedFinder(
'//field',
array($node),
array('field', 'some field')
);
$this->document->fillField('some field', 'some val');
$this->setExpectedException('Behat\Mink\Exception\ElementNotFoundException');
$this->document->fillField('some field', 'some val');
}
public function testCheckField()
{
$node = $this->getMockBuilder('Behat\Mink\Element\NodeElement')
->disableOriginalConstructor()
->getMock();
$node
->expects($this->once())
->method('check');
$this->mockNamedFinder(
'//field',
array($node),
array('field', 'some field')
);
$this->document->checkField('some field');
$this->setExpectedException('Behat\Mink\Exception\ElementNotFoundException');
$this->document->checkField('some field');
}
public function testUncheckField()
{
$node = $this->getMockBuilder('Behat\Mink\Element\NodeElement')
->disableOriginalConstructor()
->getMock();
$node
->expects($this->once())
->method('uncheck');
$this->mockNamedFinder(
'//field',
array($node),
array('field', 'some field')
);
$this->document->uncheckField('some field');
$this->setExpectedException('Behat\Mink\Exception\ElementNotFoundException');
$this->document->uncheckField('some field');
}
public function testSelectField()
{
$node = $this->getMockBuilder('Behat\Mink\Element\NodeElement')
->disableOriginalConstructor()
->getMock();
$node
->expects($this->once())
->method('selectOption')
->with('option2');
$this->mockNamedFinder(
'//field',
array($node),
array('field', 'some field')
);
$this->document->selectFieldOption('some field', 'option2');
$this->setExpectedException('Behat\Mink\Exception\ElementNotFoundException');
$this->document->selectFieldOption('some field', 'option2');
}
public function testAttachFileToField()
{
$node = $this->getMockBuilder('Behat\Mink\Element\NodeElement')
->disableOriginalConstructor()
->getMock();
$node
->expects($this->once())
->method('attachFile')
->with('/path/to/file');
$this->mockNamedFinder(
'//field',
array($node),
array('field', 'some field')
);
$this->document->attachFileToField('some field', '/path/to/file');
$this->setExpectedException('Behat\Mink\Exception\ElementNotFoundException');
$this->document->attachFileToField('some field', '/path/to/file');
}
public function testGetContent()
{
$expects = 'page content';
$this->driver
->expects($this->once())
->method('getContent')
->will($this->returnValue($expects));
$this->assertEquals($expects, $this->document->getContent());
}
public function testGetText()
{
$expects = 'val1';
$this->driver
->expects($this->once())
->method('getText')
->with('//html')
->will($this->returnValue($expects));
$this->assertEquals($expects, $this->document->getText());
}
public function testGetHtml()
{
$expects = 'val1';
$this->driver
->expects($this->once())
->method('getHtml')
->with('//html')
->will($this->returnValue($expects));
$this->assertEquals($expects, $this->document->getHtml());
}
public function testGetOuterHtml()
{
$expects = 'val1';
$this->driver
->expects($this->once())
->method('getOuterHtml')
->with('//html')
->will($this->returnValue($expects));
$this->assertEquals($expects, $this->document->getOuterHtml());
}
}

View file

@ -1,71 +0,0 @@
<?php
namespace Behat\Mink\Tests\Element;
use Behat\Mink\Driver\DriverInterface;
use Behat\Mink\Session;
use Behat\Mink\Selector\SelectorsHandler;
abstract class ElementTest extends \PHPUnit_Framework_TestCase
{
/**
* Session.
*
* @var Session
*/
protected $session;
/**
* @var DriverInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $driver;
/**
* Selectors.
*
* @var SelectorsHandler|\PHPUnit_Framework_MockObject_MockObject
*/
protected $selectors;
protected function setUp()
{
$this->driver = $this->getMockBuilder('Behat\Mink\Driver\DriverInterface')->getMock();
$this->driver
->expects($this->once())
->method('setSession');
$this->selectors = $this->getMockBuilder('Behat\Mink\Selector\SelectorsHandler')->getMock();
$this->session = new Session($this->driver, $this->selectors);
}
protected function mockNamedFinder($xpath, array $results, $locator, $times = 2)
{
if (!is_array($results[0])) {
$results = array($results, array());
}
// In case of empty results, a second call will be done using the partial selector
$processedResults = array();
foreach ($results as $result) {
$processedResults[] = $result;
if (empty($result)) {
$processedResults[] = $result;
++$times;
}
}
$returnValue = call_user_func_array(array($this, 'onConsecutiveCalls'), $processedResults);
$this->driver
->expects($this->exactly($times))
->method('find')
->with('//html'.$xpath)
->will($returnValue);
$this->selectors
->expects($this->exactly($times))
->method('selectorToXpath')
->with($this->logicalOr('named_exact', 'named_partial'), $locator)
->will($this->returnValue($xpath));
}
}

View file

@ -1,598 +0,0 @@
<?php
namespace Behat\Mink\Tests\Element;
use Behat\Mink\Element\NodeElement;
class NodeElementTest extends ElementTest
{
public function testGetXpath()
{
$node = new NodeElement('some custom xpath', $this->session);
$this->assertEquals('some custom xpath', $node->getXpath());
$this->assertNotEquals('not some custom xpath', $node->getXpath());
}
public function testGetText()
{
$expected = 'val1';
$node = new NodeElement('text_tag', $this->session);
$this->driver
->expects($this->once())
->method('getText')
->with('text_tag')
->will($this->returnValue($expected));
$this->assertEquals($expected, $node->getText());
}
public function testGetOuterHtml()
{
$expected = 'val1';
$node = new NodeElement('text_tag', $this->session);
$this->driver
->expects($this->once())
->method('getOuterHtml')
->with('text_tag')
->will($this->returnValue($expected));
$this->assertEquals($expected, $node->getOuterHtml());
}
public function testElementIsValid()
{
$elementXpath = 'some xpath';
$node = new NodeElement($elementXpath, $this->session);
$this->driver
->expects($this->once())
->method('find')
->with($elementXpath)
->will($this->returnValue(array($elementXpath)));
$this->assertTrue($node->isValid());
}
public function testElementIsNotValid()
{
$node = new NodeElement('some xpath', $this->session);
$this->driver
->expects($this->exactly(2))
->method('find')
->with('some xpath')
->will($this->onConsecutiveCalls(array(), array('xpath1', 'xpath2')));
$this->assertFalse($node->isValid(), 'no elements found is invalid element');
$this->assertFalse($node->isValid(), 'more then 1 element found is invalid element');
}
public function testWaitForSuccess()
{
$callCounter = 0;
$node = new NodeElement('some xpath', $this->session);
$result = $node->waitFor(5, function ($givenNode) use (&$callCounter) {
++$callCounter;
if (1 === $callCounter) {
return null;
} elseif (2 === $callCounter) {
return false;
} elseif (3 === $callCounter) {
return array();
}
return $givenNode;
});
$this->assertEquals(4, $callCounter, '->waitFor() tries to locate element several times before failing');
$this->assertSame($node, $result, '->waitFor() returns node found in callback');
}
/**
* @medium
*/
public function testWaitForTimeout()
{
$node = new NodeElement('some xpath', $this->session);
$expectedTimeout = 2;
$startTime = microtime(true);
$result = $node->waitFor($expectedTimeout, function () {
return null;
});
$endTime = microtime(true);
$this->assertNull($result, '->waitFor() returns whatever callback gives');
$this->assertEquals($expectedTimeout, round($endTime - $startTime));
}
/**
* @expectedException \InvalidArgumentException
*/
public function testWaitForFailure()
{
$node = new NodeElement('some xpath', $this->session);
$node->waitFor(5, 'not a callable');
}
public function testHasAttribute()
{
$node = new NodeElement('input_tag', $this->session);
$this->driver
->expects($this->exactly(2))
->method('getAttribute')
->with('input_tag', 'href')
->will($this->onConsecutiveCalls(null, 'http://...'));
$this->assertFalse($node->hasAttribute('href'));
$this->assertTrue($node->hasAttribute('href'));
}
public function testGetAttribute()
{
$expected = 'http://...';
$node = new NodeElement('input_tag', $this->session);
$this->driver
->expects($this->once())
->method('getAttribute')
->with('input_tag', 'href')
->will($this->returnValue($expected));
$this->assertEquals($expected, $node->getAttribute('href'));
}
public function testHasClass()
{
$node = new NodeElement('input_tag', $this->session);
$this->driver
->expects($this->exactly(6))
->method('getAttribute')
->with('input_tag', 'class')
->will($this->returnValue('
class1 class2
'));
$this->assertTrue($node->hasClass('class1'), 'The "class1" was found');
$this->assertTrue($node->hasClass('class2'), 'The "class2" was found');
$this->assertFalse($node->hasClass('class3'), 'The "class3" was not found');
}
public function testHasClassWithoutArgument()
{
$node = new NodeElement('input_tag', $this->session);
$this->driver
->expects($this->once())
->method('getAttribute')
->with('input_tag', 'class')
->will($this->returnValue(null));
$this->assertFalse($node->hasClass('class3'));
}
public function testGetValue()
{
$expected = 'val1';
$node = new NodeElement('input_tag', $this->session);
$this->driver
->expects($this->once())
->method('getValue')
->with('input_tag')
->will($this->returnValue($expected));
$this->assertEquals($expected, $node->getValue());
}
public function testSetValue()
{
$expected = 'new_val';
$node = new NodeElement('input_tag', $this->session);
$this->driver
->expects($this->once())
->method('setValue')
->with('input_tag', $expected);
$node->setValue($expected);
}
public function testClick()
{
$node = new NodeElement('link_or_button', $this->session);
$this->driver
->expects($this->once())
->method('click')
->with('link_or_button');
$node->click();
}
public function testPress()
{
$node = new NodeElement('link_or_button', $this->session);
$this->driver
->expects($this->once())
->method('click')
->with('link_or_button');
$node->press();
}
public function testRightClick()
{
$node = new NodeElement('elem', $this->session);
$this->driver
->expects($this->once())
->method('rightClick')
->with('elem');
$node->rightClick();
}
public function testDoubleClick()
{
$node = new NodeElement('elem', $this->session);
$this->driver
->expects($this->once())
->method('doubleClick')
->with('elem');
$node->doubleClick();
}
public function testCheck()
{
$node = new NodeElement('checkbox_or_radio', $this->session);
$this->driver
->expects($this->once())
->method('check')
->with('checkbox_or_radio');
$node->check();
}
public function testUncheck()
{
$node = new NodeElement('checkbox_or_radio', $this->session);
$this->driver
->expects($this->once())
->method('uncheck')
->with('checkbox_or_radio');
$node->uncheck();
}
public function testSelectOption()
{
$node = new NodeElement('select', $this->session);
$option = $this->getMockBuilder('Behat\Mink\Element\NodeElement')
->disableOriginalConstructor()
->getMock();
$option
->expects($this->once())
->method('getValue')
->will($this->returnValue('item1'));
$this->driver
->expects($this->once())
->method('getTagName')
->with('select')
->will($this->returnValue('select'));
$this->driver
->expects($this->once())
->method('find')
->with('select/option')
->will($this->returnValue(array($option)));
$this->selectors
->expects($this->once())
->method('selectorToXpath')
->with('named_exact', array('option', 'item1'))
->will($this->returnValue('option'));
$this->driver
->expects($this->once())
->method('selectOption')
->with('select', 'item1', false);
$node->selectOption('item1');
}
/**
* @expectedException \Behat\Mink\Exception\ElementNotFoundException
*/
public function testSelectOptionNotFound()
{
$node = new NodeElement('select', $this->session);
$this->driver
->expects($this->once())
->method('getTagName')
->with('select')
->will($this->returnValue('select'));
$this->driver
->expects($this->exactly(2))
->method('find')
->with('select/option')
->will($this->returnValue(array()));
$this->selectors
->expects($this->exactly(2))
->method('selectorToXpath')
->with($this->logicalOr('named_exact', 'named_partial'), array('option', 'item1'))
->will($this->returnValue('option'));
$node->selectOption('item1');
}
public function testSelectOptionOtherTag()
{
$node = new NodeElement('div', $this->session);
$this->driver
->expects($this->once())
->method('getTagName')
->with('div')
->will($this->returnValue('div'));
$this->driver
->expects($this->once())
->method('selectOption')
->with('div', 'item1', false);
$node->selectOption('item1');
}
public function testGetTagName()
{
$node = new NodeElement('html//h3', $this->session);
$this->driver
->expects($this->once())
->method('getTagName')
->with('html//h3')
->will($this->returnValue('h3'));
$this->assertEquals('h3', $node->getTagName());
}
public function testGetParent()
{
$node = new NodeElement('elem', $this->session);
$parent = $this->getMockBuilder('Behat\Mink\Element\NodeElement')
->disableOriginalConstructor()
->getMock();
$this->driver
->expects($this->once())
->method('find')
->with('elem/..')
->will($this->returnValue(array($parent)));
$this->selectors
->expects($this->once())
->method('selectorToXpath')
->with('xpath', '..')
->will($this->returnValue('..'));
$this->assertSame($parent, $node->getParent());
}
public function testAttachFile()
{
$node = new NodeElement('elem', $this->session);
$this->driver
->expects($this->once())
->method('attachFile')
->with('elem', 'path');
$node->attachFile('path');
}
public function testIsVisible()
{
$node = new NodeElement('some_xpath', $this->session);
$this->driver
->expects($this->exactly(2))
->method('isVisible')
->with('some_xpath')
->will($this->onConsecutiveCalls(true, false));
$this->assertTrue($node->isVisible());
$this->assertFalse($node->isVisible());
}
public function testIsChecked()
{
$node = new NodeElement('some_xpath', $this->session);
$this->driver
->expects($this->exactly(2))
->method('isChecked')
->with('some_xpath')
->will($this->onConsecutiveCalls(true, false));
$this->assertTrue($node->isChecked());
$this->assertFalse($node->isChecked());
}
public function testIsSelected()
{
$node = new NodeElement('some_xpath', $this->session);
$this->driver
->expects($this->exactly(2))
->method('isSelected')
->with('some_xpath')
->will($this->onConsecutiveCalls(true, false));
$this->assertTrue($node->isSelected());
$this->assertFalse($node->isSelected());
}
public function testFocus()
{
$node = new NodeElement('some-element', $this->session);
$this->driver
->expects($this->once())
->method('focus')
->with('some-element');
$node->focus();
}
public function testBlur()
{
$node = new NodeElement('some-element', $this->session);
$this->driver
->expects($this->once())
->method('blur')
->with('some-element');
$node->blur();
}
public function testMouseOver()
{
$node = new NodeElement('some-element', $this->session);
$this->driver
->expects($this->once())
->method('mouseOver')
->with('some-element');
$node->mouseOver();
}
public function testDragTo()
{
$node = new NodeElement('some_tag1', $this->session);
$target = $this->getMock('Behat\Mink\Element\ElementInterface');
$target->expects($this->any())
->method('getXPath')
->will($this->returnValue('some_tag2'));
$this->driver
->expects($this->once())
->method('dragTo')
->with('some_tag1', 'some_tag2');
$node->dragTo($target);
}
public function testKeyPress()
{
$node = new NodeElement('elem', $this->session);
$this->driver
->expects($this->once())
->method('keyPress')
->with('elem', 'key');
$node->keyPress('key');
}
public function testKeyDown()
{
$node = new NodeElement('elem', $this->session);
$this->driver
->expects($this->once())
->method('keyDown')
->with('elem', 'key');
$node->keyDown('key');
}
public function testKeyUp()
{
$node = new NodeElement('elem', $this->session);
$this->driver
->expects($this->once())
->method('keyUp')
->with('elem', 'key');
$node->keyUp('key');
}
public function testSubmitForm()
{
$node = new NodeElement('some_xpath', $this->session);
$this->driver
->expects($this->once())
->method('submitForm')
->with('some_xpath');
$node->submit();
}
public function testFindAllUnion()
{
$node = new NodeElement('some_xpath', $this->session);
$xpath = "some_tag1 | some_tag2[@foo =\n 'bar|'']\n | some_tag3[foo | bar]";
$expected = "some_xpath/some_tag1 | some_xpath/some_tag2[@foo =\n 'bar|''] | some_xpath/some_tag3[foo | bar]";
$this->driver
->expects($this->exactly(1))
->method('find')
->will($this->returnValueMap(array(
array($expected, array(2, 3, 4)),
)));
$this->selectors
->expects($this->exactly(1))
->method('selectorToXpath')
->will($this->returnValueMap(array(
array('xpath', $xpath, $xpath),
)));
$this->assertEquals(3, count($node->findAll('xpath', $xpath)));
}
public function testFindAllParentUnion()
{
$node = new NodeElement('some_xpath | another_xpath', $this->session);
$xpath = 'some_tag1 | some_tag2';
$expectedPrefixed = '(some_xpath | another_xpath)/some_tag1 | (some_xpath | another_xpath)/some_tag2';
$this->driver
->expects($this->exactly(1))
->method('find')
->will($this->returnValueMap(array(
array($expectedPrefixed, array(2, 3, 4)),
)));
$this->selectors
->expects($this->exactly(1))
->method('selectorToXpath')
->will($this->returnValueMap(array(
array('xpath', $xpath, $xpath),
)));
$this->assertEquals(3, count($node->findAll('xpath', $xpath)));
}
}

View file

@ -1,42 +0,0 @@
<?php
namespace Behat\Mink\Tests\Exception;
use Behat\Mink\Exception\ElementException;
/**
* @group legacy
*/
class ElementExceptionTest extends \PHPUnit_Framework_TestCase
{
public function testMessage()
{
$exception = new ElementException($this->getElementMock(), new \Exception('Something went wrong'));
$expectedMessage = "Exception thrown by element XPath\nSomething went wrong";
$this->assertEquals($expectedMessage, $exception->getMessage());
$this->assertEquals($expectedMessage, (string) $exception);
}
public function testElement()
{
$element = $this->getElementMock();
$exception = new ElementException($element, new \Exception('Something went wrong'));
$this->assertSame($element, $exception->getElement());
}
private function getElementMock()
{
$mock = $this->getMockBuilder('Behat\Mink\Element\Element')
->disableOriginalConstructor()
->getMock();
$mock->expects($this->any())
->method('getXPath')
->will($this->returnValue('element XPath'));
return $mock;
}
}

View file

@ -1,50 +0,0 @@
<?php
namespace Behat\Mink\Tests\Exception;
use Behat\Mink\Exception\ElementHtmlException;
class ElementHtmlExceptionTest extends \PHPUnit_Framework_TestCase
{
public function testExceptionToString()
{
$driver = $this->getMock('Behat\Mink\Driver\DriverInterface');
$element = $this->getElementMock();
$driver->expects($this->any())
->method('getStatusCode')
->will($this->returnValue(200));
$driver->expects($this->any())
->method('getCurrentUrl')
->will($this->returnValue('http://localhost/test'));
$element->expects($this->any())
->method('getOuterHtml')
->will($this->returnValue("<div>\n <h1>Hello world</h1>\n <p>Test</p>\n</div>"));
$expected = <<<'TXT'
Html error
+--[ HTTP/1.1 200 | http://localhost/test | %s ]
|
| <div>
| <h1>Hello world</h1>
| <p>Test</p>
| </div>
|
TXT;
$expected = sprintf($expected.' ', get_class($driver));
$exception = new ElementHtmlException('Html error', $driver, $element);
$this->assertEquals($expected, $exception->__toString());
}
private function getElementMock()
{
return $this->getMockBuilder('Behat\Mink\Element\NodeElement')
->disableOriginalConstructor()
->getMock();
}
}

View file

@ -1,50 +0,0 @@
<?php
namespace Behat\Mink\Tests\Exception;
use Behat\Mink\Exception\ElementNotFoundException;
class ElementNotFoundExceptionTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider provideExceptionMessage
*/
public function testBuildMessage($message, $type, $selector = null, $locator = null)
{
$driver = $this->getMock('Behat\Mink\Driver\DriverInterface');
$exception = new ElementNotFoundException($driver, $type, $selector, $locator);
$this->assertEquals($message, $exception->getMessage());
}
public function provideExceptionMessage()
{
return array(
array('Tag not found.', null),
array('Field not found.', 'field'),
array('Tag matching locator "foobar" not found.', null, null, 'foobar'),
array('Tag matching css "foobar" not found.', null, 'css', 'foobar'),
array('Field matching xpath "foobar" not found.', 'Field', 'xpath', 'foobar'),
array('Tag with name "foobar" not found.', null, 'name', 'foobar'),
);
}
/**
* @group legacy
*/
public function testConstructWithSession()
{
$driver = $this->getMock('Behat\Mink\Driver\DriverInterface');
$session = $this->getMockBuilder('Behat\Mink\Session')
->disableOriginalConstructor()
->getMock();
$session->expects($this->any())
->method('getDriver')
->will($this->returnValue($driver));
$exception = new ElementNotFoundException($session);
$this->assertEquals('Tag not found.', $exception->getMessage());
}
}

View file

@ -1,48 +0,0 @@
<?php
namespace Behat\Mink\Tests\Exception;
use Behat\Mink\Exception\ElementTextException;
class ElementTextExceptionTest extends \PHPUnit_Framework_TestCase
{
public function testExceptionToString()
{
$driver = $this->getMock('Behat\Mink\Driver\DriverInterface');
$element = $this->getElementMock();
$driver->expects($this->any())
->method('getStatusCode')
->will($this->returnValue(200));
$driver->expects($this->any())
->method('getCurrentUrl')
->will($this->returnValue('http://localhost/test'));
$element->expects($this->any())
->method('getText')
->will($this->returnValue("Hello world\nTest\n"));
$expected = <<<'TXT'
Text error
+--[ HTTP/1.1 200 | http://localhost/test | %s ]
|
| Hello world
| Test
|
TXT;
$expected = sprintf($expected.' ', get_class($driver));
$exception = new ElementTextException('Text error', $driver, $element);
$this->assertEquals($expected, $exception->__toString());
}
private function getElementMock()
{
return $this->getMockBuilder('Behat\Mink\Element\NodeElement')
->disableOriginalConstructor()
->getMock();
}
}

View file

@ -1,114 +0,0 @@
<?php
namespace Behat\Mink\Tests\Exception;
use Behat\Mink\Exception\ExpectationException;
class ExpectationExceptionTest extends \PHPUnit_Framework_TestCase
{
public function testEmptyMessageAndPreviousException()
{
$exception = new ExpectationException('', $this->getMock('Behat\Mink\Driver\DriverInterface'), new \Exception('Something failed'));
$this->assertEquals('Something failed', $exception->getMessage());
}
public function testExceptionToString()
{
$driver = $this->getMock('Behat\Mink\Driver\DriverInterface');
$driver->expects($this->any())
->method('getStatusCode')
->will($this->returnValue(200));
$driver->expects($this->any())
->method('getCurrentUrl')
->will($this->returnValue('http://localhost/test'));
$html = "<html><head><title>Hello</title></head>\n<body>\n<h1>Hello world</h1>\n<p>Test</p>\n</body></html>";
$driver->expects($this->any())
->method('getContent')
->will($this->returnValue($html));
$expected = <<<'TXT'
Expectation failure
+--[ HTTP/1.1 200 | http://localhost/test | %s ]
|
| <body>
| <h1>Hello world</h1>
| <p>Test</p>
| </body>
|
TXT;
$expected = sprintf($expected.' ', get_class($driver));
$exception = new ExpectationException('Expectation failure', $driver);
$this->assertEquals($expected, $exception->__toString());
}
public function testBigContent()
{
$driver = $this->getMock('Behat\Mink\Driver\DriverInterface');
$driver->expects($this->any())
->method('getStatusCode')
->will($this->returnValue(200));
$driver->expects($this->any())
->method('getCurrentUrl')
->will($this->returnValue('http://localhost/test'));
$body = str_repeat('a', 1001 - strlen('<body></body>'));
$html = sprintf("<html><head><title>Hello</title></head>\n<body>%s</body></html>", $body);
$driver->expects($this->any())
->method('getContent')
->will($this->returnValue($html));
$expected = <<<'TXT'
Expectation failure
+--[ HTTP/1.1 200 | http://localhost/test | %s ]
|
| <body>%s</b...
|
TXT;
$expected = sprintf($expected.' ', get_class($driver), $body);
$exception = new ExpectationException('Expectation failure', $driver);
$this->assertEquals($expected, $exception->__toString());
}
public function testExceptionWhileRenderingString()
{
$driver = $this->getMock('Behat\Mink\Driver\DriverInterface');
$driver->expects($this->any())
->method('getContent')
->will($this->throwException(new \Exception('Broken page')));
$exception = new ExpectationException('Expectation failure', $driver);
$this->assertEquals('Expectation failure', $exception->__toString());
}
/**
* @group legacy
*/
public function testConstructWithSession()
{
$driver = $this->getMock('Behat\Mink\Driver\DriverInterface');
$session = $this->getMockBuilder('Behat\Mink\Session')
->disableOriginalConstructor()
->getMock();
$session->expects($this->any())
->method('getDriver')
->will($this->returnValue($driver));
$exception = new ExpectationException('', $session, new \Exception('Something failed'));
$this->assertEquals('Something failed', $exception->getMessage());
}
}

View file

@ -1,40 +0,0 @@
<?php
namespace Behat\Mink\Tests\Exception;
use Behat\Mink\Exception\ResponseTextException;
class ResponseTextExceptionTest extends \PHPUnit_Framework_TestCase
{
public function testExceptionToString()
{
$driver = $this->getMock('Behat\Mink\Driver\DriverInterface');
$driver->expects($this->any())
->method('getStatusCode')
->will($this->returnValue(200));
$driver->expects($this->any())
->method('getCurrentUrl')
->will($this->returnValue('http://localhost/test'));
$driver->expects($this->any())
->method('getText')
->with('//html')
->will($this->returnValue("Hello world\nTest\n"));
$expected = <<<'TXT'
Text error
+--[ HTTP/1.1 200 | http://localhost/test | %s ]
|
| Hello world
| Test
|
TXT;
$expected = sprintf($expected.' ', get_class($driver));
$exception = new ResponseTextException('Text error', $driver);
$this->assertEquals($expected, $exception->__toString());
}
}

View file

@ -1,246 +0,0 @@
<?php
namespace Behat\Mink\Tests;
use Behat\Mink\Mink;
class MinkTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Mink
*/
private $mink;
protected function setUp()
{
$this->mink = new Mink();
}
public function testRegisterSession()
{
$session = $this->getSessionMock();
$this->assertFalse($this->mink->hasSession('not_registered'));
$this->assertFalse($this->mink->hasSession('js'));
$this->assertFalse($this->mink->hasSession('my'));
$this->mink->registerSession('my', $session);
$this->assertTrue($this->mink->hasSession('my'));
$this->assertFalse($this->mink->hasSession('not_registered'));
$this->assertFalse($this->mink->hasSession('js'));
}
public function testRegisterSessionThroughConstructor()
{
$mink = new Mink(array('my' => $this->getSessionMock()));
$this->assertTrue($mink->hasSession('my'));
}
public function testSessionAutostop()
{
$session1 = $this->getSessionMock();
$session2 = $this->getSessionMock();
$this->mink->registerSession('my1', $session1);
$this->mink->registerSession('my2', $session2);
$session1
->expects($this->once())
->method('isStarted')
->will($this->returnValue(true));
$session1
->expects($this->once())
->method('stop');
$session2
->expects($this->once())
->method('isStarted')
->will($this->returnValue(false));
$session2
->expects($this->never())
->method('stop');
unset($this->mink);
}
public function testNotStartedSession()
{
$session = $this->getSessionMock();
$session
->expects($this->once())
->method('isStarted')
->will($this->returnValue(false));
$session
->expects($this->once())
->method('start');
$this->mink->registerSession('mock_session', $session);
$this->assertSame($session, $this->mink->getSession('mock_session'));
$this->setExpectedException('InvalidArgumentException');
$this->mink->getSession('not_registered');
}
public function testGetAlreadyStartedSession()
{
$session = $this->getSessionMock();
$session
->expects($this->once())
->method('isStarted')
->will($this->returnValue(true));
$session
->expects($this->never())
->method('start');
$this->mink->registerSession('mock_session', $session);
$this->assertSame($session, $this->mink->getSession('mock_session'));
}
public function testSetDefaultSessionName()
{
$this->assertNull($this->mink->getDefaultSessionName());
$session = $this->getSessionMock();
$this->mink->registerSession('session_name', $session);
$this->mink->setDefaultSessionName('session_name');
$this->assertEquals('session_name', $this->mink->getDefaultSessionName());
$this->setExpectedException('InvalidArgumentException');
$this->mink->setDefaultSessionName('not_registered');
}
public function testGetDefaultSession()
{
$session1 = $this->getSessionMock();
$session2 = $this->getSessionMock();
$this->assertNotSame($session1, $session2);
$this->mink->registerSession('session_1', $session1);
$this->mink->registerSession('session_2', $session2);
$this->mink->setDefaultSessionName('session_2');
$this->assertSame($session1, $this->mink->getSession('session_1'));
$this->assertSame($session2, $this->mink->getSession('session_2'));
$this->assertSame($session2, $this->mink->getSession());
$this->mink->setDefaultSessionName('session_1');
$this->assertSame($session1, $this->mink->getSession());
}
public function testGetNoDefaultSession()
{
$session1 = $this->getSessionMock();
$this->mink->registerSession('session_1', $session1);
$this->setExpectedException('InvalidArgumentException');
$this->mink->getSession();
}
public function testIsSessionStarted()
{
$session_1 = $this->getSessionMock();
$session_2 = $this->getSessionMock();
$session_1
->expects($this->any())
->method('isStarted')
->will($this->returnValue(false));
$session_1
->expects($this->never())
->method('start');
$session_2
->expects($this->any())
->method('isStarted')
->will($this->returnValue(true));
$session_2
->expects($this->never())
->method('start');
$this->mink->registerSession('not_started', $session_1);
$this->assertFalse($this->mink->isSessionStarted('not_started'));
$this->mink->registerSession('started', $session_2);
$this->assertTrue($this->mink->isSessionStarted('started'));
$this->setExpectedException('InvalidArgumentException');
$this->mink->getSession('not_registered');
}
public function testAssertSession()
{
$session = $this->getSessionMock();
$this->mink->registerSession('my', $session);
$this->assertInstanceOf('Behat\Mink\WebAssert', $this->mink->assertSession('my'));
}
public function testAssertSessionNotRegistered()
{
$session = $this->getSessionMock();
$this->assertInstanceOf('Behat\Mink\WebAssert', $this->mink->assertSession($session));
}
public function testResetSessions()
{
$session1 = $this->getSessionMock();
$session1->expects($this->once())
->method('isStarted')
->will($this->returnValue(false));
$session1->expects($this->never())
->method('reset');
$session2 = $this->getSessionMock();
$session2->expects($this->once())
->method('isStarted')
->will($this->returnValue(true));
$session2->expects($this->once())
->method('reset');
$this->mink->registerSession('not started', $session1);
$this->mink->registerSession('started', $session2);
$this->mink->resetSessions();
}
public function testRestartSessions()
{
$session1 = $this->getSessionMock();
$session1->expects($this->once())
->method('isStarted')
->will($this->returnValue(false));
$session1->expects($this->never())
->method('restart');
$session2 = $this->getSessionMock();
$session2->expects($this->once())
->method('isStarted')
->will($this->returnValue(true));
$session2->expects($this->once())
->method('restart');
$this->mink->registerSession('not started', $session1);
$this->mink->registerSession('started', $session2);
$this->mink->restartSessions();
}
private function getSessionMock()
{
return $this->getMockBuilder('Behat\Mink\Session')
->disableOriginalConstructor()
->getMock();
}
}

View file

@ -1,41 +0,0 @@
<?php
namespace Behat\Mink\Tests\Selector;
use Behat\Mink\Selector\CssSelector;
class CssSelectorTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
if (!class_exists('Symfony\Component\CssSelector\CssSelector')) {
$this->markTestSkipped('Symfony2 CssSelector component not installed');
}
}
public function testSelector()
{
$selector = new CssSelector();
$this->assertEquals('descendant-or-self::h3', $selector->translateToXPath('h3'));
$this->assertEquals('descendant-or-self::h3/span', $selector->translateToXPath('h3 > span'));
if (interface_exists('Symfony\Component\CssSelector\XPath\TranslatorInterface')) {
// The rewritten component of Symfony 2.3 checks for attribute existence first for the class.
$expectation = "descendant-or-self::h3/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' my_div ')]";
} else {
$expectation = "descendant-or-self::h3/*[contains(concat(' ', normalize-space(@class), ' '), ' my_div ')]";
}
$this->assertEquals($expectation, $selector->translateToXPath('h3 > .my_div'));
}
/**
* @expectedException \InvalidArgumentException
*/
public function testThrowsForArrayLocator()
{
$selector = new CssSelector();
$selector->translateToXPath(array('h3'));
}
}

View file

@ -1,18 +0,0 @@
<?php
namespace Behat\Mink\Tests\Selector;
use Behat\Mink\Selector\ExactNamedSelector;
class ExactNamedSelectorTest extends NamedSelectorTest
{
protected function getSelector()
{
return new ExactNamedSelector();
}
protected function allowPartialMatch()
{
return false;
}
}

View file

@ -1,168 +0,0 @@
<?php
namespace Behat\Mink\Tests\Selector;
use Behat\Mink\Selector\NamedSelector;
use Behat\Mink\Selector\Xpath\Escaper;
abstract class NamedSelectorTest extends \PHPUnit_Framework_TestCase
{
public function testRegisterXpath()
{
$selector = $this->getSelector();
$selector->registerNamedXpath('some', 'my_xpath');
$this->assertEquals('my_xpath', $selector->translateToXPath('some'));
$this->setExpectedException('InvalidArgumentException');
$selector->translateToXPath('custom');
}
/**
* @expectedException \InvalidArgumentException
*/
public function testInvalidLocator()
{
$namedSelector = $this->getSelector();
$namedSelector->translateToXPath(array('foo', 'bar', 'baz'));
}
/**
* @dataProvider getSelectorTests
*/
public function testSelectors($fixtureFile, $selector, $locator, $expectedExactCount, $expectedPartialCount = null)
{
$expectedCount = $this->allowPartialMatch() && null !== $expectedPartialCount
? $expectedPartialCount
: $expectedExactCount;
// Don't use "loadHTMLFile" due HHVM 3.3.0 issue.
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->loadHTML(file_get_contents(__DIR__.'/fixtures/'.$fixtureFile));
$namedSelector = $this->getSelector();
$xpath = $namedSelector->translateToXPath(array($selector, $locator));
$domXpath = new \DOMXPath($dom);
$nodeList = $domXpath->query($xpath);
$this->assertEquals($expectedCount, $nodeList->length);
}
/**
* @dataProvider getSelectorTests
* @group legacy
*/
public function testEscapedSelectors($fixtureFile, $selector, $locator, $expectedExactCount, $expectedPartialCount = null)
{
// Escape the locator as Mink 1.x expects the caller of the NamedSelector to handle it
$escaper = new Escaper();
$locator = $escaper->escapeLiteral($locator);
$this->testSelectors($fixtureFile, $selector, $locator, $expectedExactCount, $expectedPartialCount);
}
public function getSelectorTests()
{
$fieldCount = 8; // fields without `type` attribute
$fieldCount += 4; // fields with `type=checkbox` attribute
$fieldCount += 4; // fields with `type=radio` attribute
$fieldCount += 4; // fields with `type=file` attribute
// Fixture file, selector name, locator, expected number of exact matched elements, expected number of partial matched elements if different
return array(
'fieldset' => array('test.html', 'fieldset', 'fieldset-text', 2, 3),
'field (name/placeholder/label)' => array('test.html', 'field', 'the-field', $fieldCount),
'field (input, with-id)' => array('test.html', 'field', 'the-field-input', 1),
'field (textarea, with-id)' => array('test.html', 'field', 'the-field-textarea', 1),
'field (select, with-id)' => array('test.html', 'field', 'the-field-select', 1),
'field (input type=submit, with-id) ignored' => array('test.html', 'field', 'the-field-submit-button', 0),
'field (input type=image, with-id) ignored' => array('test.html', 'field', 'the-field-image-button', 0),
'field (input type=button, with-id) ignored' => array('test.html', 'field', 'the-field-button-button', 0),
'field (input type=reset, with-id) ignored' => array('test.html', 'field', 'the-field-reset-button', 0),
'field (input type=hidden, with-id) ignored' => array('test.html', 'field', 'the-field-hidden', 0),
'link (with-href)' => array('test.html', 'link', 'link-text', 5, 9),
'link (without-href) ignored' => array('test.html', 'link', 'bad-link-text', 0),
'link* (role=link)' => array('test.html', 'link', 'link-role-text', 4, 7),
'button (input, name/value/title)' => array('test.html', 'button', 'button-text', 25, 42),
'button (type=image, with-alt)' => array('test.html', 'button', 'button-alt-text', 1, 2),
'button (input type=submit, with-id)' => array('test.html', 'button', 'input-submit-button', 1),
'button (input type=image, with-id)' => array('test.html', 'button', 'input-image-button', 1),
'button (input type=button, with-id)' => array('test.html', 'button', 'input-button-button', 1),
'button (input type=reset, with-id)' => array('test.html', 'button', 'input-reset-button', 1),
'button (button type=submit, with-id)' => array('test.html', 'button', 'button-submit-button', 1),
'button (button type=image, with-id)' => array('test.html', 'button', 'button-image-button', 1),
'button (button type=button, with-id)' => array('test.html', 'button', 'button-button-button', 1),
'button (button type=reset, with-id)' => array('test.html', 'button', 'button-reset-button', 1),
'button* (role=button, name/value/title)' => array('test.html', 'button', 'button-role-text', 12, 20),
'button* (role=button type=submit, with-id)' => array('test.html', 'button', 'role-button-submit-button', 1),
'button* (role=button type=image, with-id)' => array('test.html', 'button', 'role-button-image-button', 1),
'button* (role=button type=button, with-id)' => array('test.html', 'button', 'role-button-button-button', 1),
'button* (role=button type=reset, with-id)' => array('test.html', 'button', 'role-button-reset-button', 1),
'link_or_button (with-href)' => array('test.html', 'link_or_button', 'link-text', 5, 9),
'link_or_button (without-href) ignored' => array('test.html', 'link_or_button', 'bad-link-text', 0),
'link_or_button* (role=link)' => array('test.html', 'link_or_button', 'link-role-text', 4, 7),
// bug in selector: 17 instead of 25 and 34 instead of 42, because 8 buttons with `name` attribute were not matched
'link_or_button (input, name/value/title)' => array('test.html', 'link_or_button', 'button-text', 17, 34),
'link_or_button (type=image, with-alt)' => array('test.html', 'link_or_button', 'button-alt-text', 1, 2),
'link_or_button (input type=submit, with-id)' => array('test.html', 'link_or_button', 'input-submit-button', 1),
'link_or_button (input type=image, with-id)' => array('test.html', 'link_or_button', 'input-image-button', 1),
'link_or_button (input type=button, with-id)' => array('test.html', 'link_or_button', 'input-button-button', 1),
'link_or_button (input type=reset, with-id)' => array('test.html', 'link_or_button', 'input-reset-button', 1),
'link_or_button (button type=submit, with-id)' => array('test.html', 'link_or_button', 'button-submit-button', 1),
'link_or_button (button type=image, with-id)' => array('test.html', 'link_or_button', 'button-image-button', 1),
'link_or_button (button type=button, with-id)' => array('test.html', 'link_or_button', 'button-button-button', 1),
'link_or_button (button type=reset, with-id)' => array('test.html', 'link_or_button', 'button-reset-button', 1),
// bug in selector: 8 instead of 12 and 16 instead of 20, because 4 buttons with `name` attribute were not matched
'link_or_button* (role=button, name/value/title)' => array('test.html', 'link_or_button', 'button-role-text', 8, 16),
'link_or_button* (role=button type=submit, with-id)' => array('test.html', 'link_or_button', 'role-button-submit-button', 1),
'link_or_button* (role=button type=image, with-id)' => array('test.html', 'link_or_button', 'role-button-image-button', 1),
'link_or_button* (role=button type=button, with-id)' => array('test.html', 'link_or_button', 'role-button-button-button', 1),
'link_or_button* (role=button type=reset, with-id)' => array('test.html', 'link_or_button', 'role-button-reset-button', 1),
// 3 matches, because matches every HTML node in path: html > body > div
'content' => array('test.html', 'content', 'content-text', 1, 4),
'content with quotes' => array('test.html', 'content', 'some "quoted" content', 1, 3),
'select (name/label)' => array('test.html', 'select', 'the-field', 3),
'select (with-id)' => array('test.html', 'select', 'the-field-select', 1),
'checkbox (name/label)' => array('test.html', 'checkbox', 'the-field', 3),
'checkbox (with-id)' => array('test.html', 'checkbox', 'the-field-checkbox', 1),
'radio (name/label)' => array('test.html', 'radio', 'the-field', 3),
'radio (with-id)' => array('test.html', 'radio', 'the-field-radio', 1),
'file (name/label)' => array('test.html', 'file', 'the-field', 3),
'file (with-id)' => array('test.html', 'file', 'the-field-file', 1),
'optgroup' => array('test.html', 'optgroup', 'group-label', 1, 2),
'option' => array('test.html', 'option', 'option-value', 2, 3),
'table' => array('test.html', 'table', 'the-table', 2, 3),
'id' => array('test.html', 'id', 'bad-link-text', 1),
'id or name' => array('test.html', 'id_or_name', 'the-table', 2),
);
}
/**
* @return NamedSelector
*/
abstract protected function getSelector();
/**
* @return bool
*/
abstract protected function allowPartialMatch();
}

View file

@ -1,18 +0,0 @@
<?php
namespace Behat\Mink\Tests\Selector;
use Behat\Mink\Selector\PartialNamedSelector;
class PartialNamedSelectorTest extends NamedSelectorTest
{
protected function getSelector()
{
return new PartialNamedSelector();
}
protected function allowPartialMatch()
{
return true;
}
}

View file

@ -1,96 +0,0 @@
<?php
namespace Behat\Mink\Tests\Selector;
use Behat\Mink\Selector\SelectorsHandler;
class SelectorsHandlerTest extends \PHPUnit_Framework_TestCase
{
public function testRegisterSelector()
{
$selector = $this->getMockBuilder('Behat\Mink\Selector\SelectorInterface')->getMock();
$handler = new SelectorsHandler();
$this->assertFalse($handler->isSelectorRegistered('custom'));
$handler->registerSelector('custom', $selector);
$this->assertTrue($handler->isSelectorRegistered('custom'));
$this->assertSame($selector, $handler->getSelector('custom'));
}
public function testRegisterSelectorThroughConstructor()
{
$selector = $this->getMockBuilder('Behat\Mink\Selector\SelectorInterface')->getMock();
$handler = new SelectorsHandler(array('custom' => $selector));
$this->assertTrue($handler->isSelectorRegistered('custom'));
$this->assertSame($selector, $handler->getSelector('custom'));
}
public function testRegisterDefaultSelectors()
{
$handler = new SelectorsHandler();
$this->assertTrue($handler->isSelectorRegistered('css'));
$this->assertTrue($handler->isSelectorRegistered('named_exact'));
$this->assertTrue($handler->isSelectorRegistered('named_partial'));
}
/**
* @expectedException \InvalidArgumentException
*/
public function testXpathSelectorThrowsExceptionForArrayLocator()
{
$handler = new SelectorsHandler();
$handler->selectorToXpath('xpath', array('some_xpath'));
}
public function testXpathSelectorIsReturnedAsIs()
{
$handler = new SelectorsHandler();
$this->assertEquals('some_xpath', $handler->selectorToXpath('xpath', 'some_xpath'));
}
public function testSelectorToXpath()
{
$selector = $this->getMockBuilder('Behat\Mink\Selector\SelectorInterface')->getMock();
$handler = new SelectorsHandler();
$handler->registerSelector('custom_selector', $selector);
$selector
->expects($this->once())
->method('translateToXPath')
->with($locator = 'some[locator]')
->will($this->returnValue($ret = '[]some[]locator'));
$this->assertEquals($ret, $handler->selectorToXpath('custom_selector', $locator));
$this->setExpectedException('InvalidArgumentException');
$handler->selectorToXpath('undefined', 'asd');
}
/**
* @group legacy
*/
public function testXpathLiteral()
{
$handler = new SelectorsHandler();
$this->assertEquals("'some simple string'", $handler->xpathLiteral('some simple string'));
}
/**
* @group legacy
*/
public function testBcLayer()
{
$selector = $this->getMockBuilder('Behat\Mink\Selector\SelectorInterface')->getMock();
$handler = new SelectorsHandler();
$handler->registerSelector('named_partial', $selector);
$this->assertSame($selector, $handler->getSelector('named'));
}
}

View file

@ -1,31 +0,0 @@
<?php
namespace Behat\Mink\Tests\Selector\Xpath;
use Behat\Mink\Selector\Xpath\Escaper;
class EscaperTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider getXpathLiterals
*/
public function testXpathLiteral($string, $expected)
{
$escaper = new Escaper();
$this->assertEquals($expected, $escaper->escapeLiteral($string));
}
public function getXpathLiterals()
{
return array(
array('some simple string', "'some simple string'"),
array('some "d-brackets" string', "'some \"d-brackets\" string'"),
array('some \'s-brackets\' string', "\"some 's-brackets' string\""),
array(
'some \'s-brackets\' and "d-brackets" string',
'concat(\'some \',"\'",\'s-brackets\',"\'",\' and "d-brackets" string\')',
),
);
}
}

View file

@ -1,64 +0,0 @@
<?php
namespace Behat\Mink\Tests\Selector\Xpath;
use Behat\Mink\Selector\Xpath\Manipulator;
class ManipulatorTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider getPrependedXpath
*/
public function testPrepend($prefix, $xpath, $expectedXpath)
{
$manipulator = new Manipulator();
$this->assertEquals($expectedXpath, $manipulator->prepend($xpath, $prefix));
}
public function getPrependedXpath()
{
return array(
'simple' => array(
'some_xpath',
'some_tag1',
'some_xpath/some_tag1',
),
'with slash' => array(
'some_xpath',
'/some_tag1',
'some_xpath/some_tag1',
),
'union' => array(
'some_xpath',
'some_tag1 | some_tag2',
'some_xpath/some_tag1 | some_xpath/some_tag2',
),
'wrapped union' => array(
'some_xpath',
'(some_tag1 | some_tag2)/some_child',
'(some_xpath/some_tag1 | some_xpath/some_tag2)/some_child',
),
'multiple wrapped union' => array(
'some_xpath',
'( ( some_tag1 | some_tag2)/some_child | some_tag3)/leaf',
'( ( some_xpath/some_tag1 | some_xpath/some_tag2)/some_child | some_xpath/some_tag3)/leaf',
),
'parent union' => array(
'some_xpath | another_xpath',
'some_tag1 | some_tag2',
'(some_xpath | another_xpath)/some_tag1 | (some_xpath | another_xpath)/some_tag2',
),
'complex condition' => array(
'some_xpath',
'some_tag1 | some_tag2[@foo = "bar|"] | some_tag3[foo | bar]',
'some_xpath/some_tag1 | some_xpath/some_tag2[@foo = "bar|"] | some_xpath/some_tag3[foo | bar]',
),
'multiline' => array(
'some_xpath',
"some_tag1 | some_tag2[@foo =\n 'bar|'']\n | some_tag3[foo | bar]",
"some_xpath/some_tag1 | some_xpath/some_tag2[@foo =\n 'bar|''] | some_xpath/some_tag3[foo | bar]",
),
);
}
}

Some files were not shown because too many files have changed in this diff Show more