Completed
Push — taxon-parent-form ( 63b2c2 )
by Kamil
21:22
created

AutocompleteHelper   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 37
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B chooseValue() 0 30 1
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\Element\NodeElement;
15
16
/**
17
 * @author Kamil Kokot <[email protected]>
18
 */
19
abstract class AutocompleteHelper
0 ignored issues
show
Coding Style introduced by
AutocompleteHelper does not seem to conform to the naming convention (Utils?$).

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.

Loading history...
20
{
21
    /**
22
     * @param NodeElement $element
23
     * @param string $value
24
     */
25
    public static function chooseValue(NodeElement $element, $value)
26
    {
27
        $isAnyAsyncActionInProgressScript = 'jQuery.active';
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $isAnyAsyncActionInProgressScript exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
28
        $isVisibleScript = sprintf(
29
            '$(document.evaluate("%s", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue).dropdown("is visible")',
30
            $element->getXpath()
31
        );
32
33
        $element->waitFor(5, function () use ($isAnyAsyncActionInProgressScript) {
34
            return !(bool) $this->getDriver()->evaluateScript($isAnyAsyncActionInProgressScript);
0 ignored issues
show
Bug introduced by
The method getDriver() does not seem to exist on object<Sylius\Behat\Service\AutocompleteHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
        });
36
37
        $element->click();
38
39
        $element->waitFor(5, function () use ($isAnyAsyncActionInProgressScript) {
40
            return !(bool) $this->getDriver()->evaluateScript($isAnyAsyncActionInProgressScript);
0 ignored issues
show
Bug introduced by
The method getDriver() does not seem to exist on object<Sylius\Behat\Service\AutocompleteHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
        });
42
43
        $element->waitFor(5, function () use ($isVisibleScript) {
44
            return $this->getDriver()->evaluateScript($isVisibleScript);
0 ignored issues
show
Bug introduced by
The method getDriver() does not seem to exist on object<Sylius\Behat\Service\AutocompleteHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
        });
46
47
        $elementItem = $element->find('css', sprintf('div.item:contains("%s")', $value));
48
49
        $elementItem->click();
50
51
        $element->waitFor(5, function () use ($isVisibleScript) {
52
            return !$this->getDriver()->evaluateScript($isVisibleScript);
0 ignored issues
show
Bug introduced by
The method getDriver() does not seem to exist on object<Sylius\Behat\Service\AutocompleteHelper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
53
        });
54
    }
55
}
56