Completed
Push — master ( f62170...97a51f )
by Ivan
01:55
created

BrowserSession::setCookie()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 9.4286
cc 1
eloc 3
nc 1
nop 3
crap 2
1
<?php
2
3
namespace SP\Spiderling;
4
5
use Countable;
6
use SP\Spiderling\Query;
7
8
/**
9
 * @author    Ivan Kerin <[email protected]>
10
 * @copyright 2015, Clippings Ltd.
11
 * @license   http://spdx.org/licenses/BSD-3-Clause
12
 */
13
class BrowserSession extends Session
14
{
15
    /**
16
     * @var BrowserInterface
17
     */
18
    private $browser;
19
20
    /**
21
     * @param BrowserInterface $browser
22
     */
23 1
    public function __construct(BrowserInterface $browser) {
24
25 1
        $this->browser = $browser;
26
27 1
        parent::__construct($browser);
28 1
    }
29
30
    /**
31
     * @return BrowserInterface
32
     */
33 1
    public function getBrowser()
34
    {
35 1
        return $this->browser;
36
    }
37
38
    /**
39
     * @return string
40
     */
41 1
    public function getAlertText()
42
    {
43 1
        return $this->browser->getAlertText();
44
    }
45
46
    /**
47
     * @param  string $confirm
48
     */
49 1
    public function confirm($confirm)
50
    {
51 1
        $this->browser->confirm($confirm);
52
53 1
        return $this;
54
    }
55
56
    /**
57
     * @return self
58
     */
59 1
    public function removeAllCookies()
60
    {
61 1
        $this->browser->removeAllCookies();
62
63 1
        return $this;
64
    }
65
66
    /**
67
     * @param  string $javascript
68
     * @return mixed
69
     */
70 1
    public function executeJs($javascript)
71
    {
72 1
        return $this->browser->executeJs($javascript);
73
    }
74
75
    /**
76
     * @return array
77
     */
78 1
    public function getJsErrors()
79
    {
80 1
        return $this->browser->getJsErrors();
81
    }
82
83
    /**
84
     * @return array
85
     */
86 1
    public function getJsMessages()
87
    {
88 1
        return $this->browser->getJsMessages();
89
    }
90
91
    /**
92
     * @param  string $file
93
     * @return self
94
     */
95 1
    public function saveScreenshot($file)
96
    {
97 1
        $this->browser->saveScreenshot($file);
98
99 1
        return $this;
100
    }
101
102
    /**
103
     * @param  Node   $node
104
     * @return self
105
     */
106 1
    public function hoverNode(Node $node)
107
    {
108 1
        $this->browser->moveMouseTo($node->getId());
109
110 1
        return $this;
111
    }
112
113
    /**
114
     * @param  string $selector
115
     * @return self
116
     */
117 1
    public function hover($selector)
118
    {
119 1
        $this->hoverNode($this->get($selector));
120
121 1
        return $this;
122
    }
123
124
    /**
125
     * @param  string $selector
126
     * @return self
127
     */
128 1
    public function hoverButton($selector)
129
    {
130 1
        $this->hoverNode($this->getButton($selector));
131
132 1
        return $this;
133
    }
134
135
    /**
136
     * @param  string $selector
137
     * @return self
138
     */
139 1
    public function hoverField($selector)
140
    {
141 1
        $this->hoverNode($this->getField($selector));
142
143 1
        return $this;
144
    }
145
}
146