1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Sylius\Behat\Service; |
13
|
|
|
|
14
|
|
|
use Behat\Mink\Driver\Selenium2Driver; |
15
|
|
|
use Behat\Mink\Element\NodeElement; |
16
|
|
|
use Behat\Mink\Session; |
17
|
|
|
use Webmozart\Assert\Assert; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Kamil Kokot <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
abstract class AutocompleteHelper |
|
|
|
|
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @param Session $session |
26
|
|
|
* @param NodeElement $element |
27
|
|
|
* @param string $value |
28
|
|
|
*/ |
29
|
|
|
public static function chooseValue(Session $session, NodeElement $element, $value) |
30
|
|
|
{ |
31
|
|
|
Assert::isInstanceOf($session->getDriver(), Selenium2Driver::class); |
32
|
|
|
|
33
|
|
|
static::waitForAsynchronousActionsToFinish($session); |
|
|
|
|
34
|
|
|
|
35
|
|
|
$element->click(); |
36
|
|
|
|
37
|
|
|
static::waitForAsynchronousActionsToFinish($session); |
|
|
|
|
38
|
|
|
static::waitForElementToBeVisible($session, $element); |
|
|
|
|
39
|
|
|
|
40
|
|
|
$element->find('css', sprintf('div.item:contains("%s")', $value))->click(); |
41
|
|
|
|
42
|
|
|
static::waitForElementToBeVisible($session, $element); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param Session $session |
47
|
|
|
*/ |
48
|
|
|
private static function waitForAsynchronousActionsToFinish(Session $session) |
49
|
|
|
{ |
50
|
|
|
$session->wait(5000, '0 === jQuery.active'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param Session $session |
55
|
|
|
* @param NodeElement $element |
56
|
|
|
*/ |
57
|
|
|
private static function waitForElementToBeVisible(Session $session, NodeElement $element) |
58
|
|
|
{ |
59
|
|
|
$session->wait(5000, sprintf( |
60
|
|
|
'$(document.evaluate("%s", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue).dropdown("is visible")', |
61
|
|
|
$element->getXpath() |
62
|
|
|
)); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.