Code Duplication    Length = 15-15 lines in 2 locations

src/Context/FormstoneContext.php 1 location

@@ 59-73 (lines=15) @@
56
     * @param string          $field
57
     * @throws \Exception
58
     */
59
    private function openComponent(DocumentElement $page, $component, $field)
60
    {
61
        $select = $page->find('css', sprintf('#%s', $field));
62
        if (!$select) {
63
            throw new \Exception(sprintf('No select "%s" found', $field));
64
        }
65
66
        $fieldName = sprintf('.fs-%1$s .fs-%1$s-selected', $component);
67
        $choices   = $select->getParent()->find('css', $fieldName);
68
        if (!$choices) {
69
            throw new \Exception(sprintf('No field "%s" found', $field));
70
        }
71
72
        $choices->press();
73
    }
74
75
    /**
76
     * Select value in choice list

src/Context/Select2Context.php 1 location

@@ 69-83 (lines=15) @@
66
     * @param string          $field
67
     * @throws \Exception
68
     */
69
    private function openField(DocumentElement $page, $field)
70
    {
71
        $fieldName = sprintf('select[name="%s"] + .select2-container', $field);
72
73
        $inputField = $page->find('css', $fieldName);
74
        if (!$inputField) {
75
            throw new \Exception(sprintf('No field "%s" found', $field));
76
        }
77
78
        $choice = $inputField->find('css', '.select2-selection');
79
        if (!$choice) {
80
            throw new \Exception(sprintf('No select2 choice found for "%s"', $field));
81
        }
82
        $choice->press();
83
    }
84
85
    /**
86
     * Fill Select2 search field