Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
73
vendor/behat/mink/driver-testsuite/tests/Form/CheckboxTest.php
vendored
Normal file
73
vendor/behat/mink/driver-testsuite/tests/Form/CheckboxTest.php
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?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());
|
||||
}
|
||||
}
|
312
vendor/behat/mink/driver-testsuite/tests/Form/GeneralTest.php
vendored
Normal file
312
vendor/behat/mink/driver-testsuite/tests/Form/GeneralTest.php
vendored
Normal file
|
@ -0,0 +1,312 @@
|
|||
<?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);
|
||||
}
|
||||
}
|
||||
}
|
128
vendor/behat/mink/driver-testsuite/tests/Form/Html5Test.php
vendored
Normal file
128
vendor/behat/mink/driver-testsuite/tests/Form/Html5Test.php
vendored
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?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());
|
||||
}
|
||||
}
|
84
vendor/behat/mink/driver-testsuite/tests/Form/RadioTest.php
vendored
Normal file
84
vendor/behat/mink/driver-testsuite/tests/Form/RadioTest.php
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?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');
|
||||
}
|
||||
}
|
134
vendor/behat/mink/driver-testsuite/tests/Form/SelectTest.php
vendored
Normal file
134
vendor/behat/mink/driver-testsuite/tests/Form/SelectTest.php
vendored
Normal file
|
@ -0,0 +1,134 @@
|
|||
<?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());
|
||||
}
|
||||
}
|
Reference in a new issue