1 | <?php |
||
23 | class RawMinkContext implements MinkAwareContext |
||
24 | { |
||
25 | private $mink; |
||
26 | private $minkParameters; |
||
27 | |||
28 | /** |
||
29 | * Sets Mink instance. |
||
30 | * |
||
31 | * @param Mink $mink Mink session manager |
||
32 | */ |
||
33 | public function setMink(Mink $mink) |
||
37 | |||
38 | /** |
||
39 | * Returns Mink instance. |
||
40 | * |
||
41 | * @return Mink |
||
42 | */ |
||
43 | public function getMink() |
||
44 | { |
||
45 | if (null === $this->mink) { |
||
46 | throw new \RuntimeException( |
||
47 | 'Mink instance has not been set on Mink context class. ' . |
||
48 | 'Have you enabled the Mink Extension?' |
||
49 | ); |
||
50 | } |
||
51 | |||
52 | return $this->mink; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Returns the parameters provided for Mink. |
||
57 | * |
||
58 | * @return array |
||
59 | */ |
||
60 | public function getMinkParameters() |
||
64 | |||
65 | /** |
||
66 | * Sets parameters provided for Mink. |
||
67 | * |
||
68 | * @param array $parameters |
||
69 | */ |
||
70 | public function setMinkParameters(array $parameters) |
||
74 | |||
75 | /** |
||
76 | * Returns specific mink parameter. |
||
77 | * |
||
78 | * @param string $name |
||
79 | * |
||
80 | * @return mixed |
||
81 | */ |
||
82 | public function getMinkParameter($name) |
||
86 | |||
87 | /** |
||
88 | * Applies the given parameter to the Mink configuration. Consider that all parameters get reset for each |
||
89 | * feature context. |
||
90 | * |
||
91 | * @param string $name The key of the parameter |
||
92 | * @param string $value The value of the parameter |
||
93 | */ |
||
94 | public function setMinkParameter($name, $value) |
||
98 | |||
99 | /** |
||
100 | * Returns Mink session. |
||
101 | * |
||
102 | * @param string|null $name name of the session OR active session will be used |
||
103 | * |
||
104 | * @return Session |
||
105 | */ |
||
106 | public function getSession($name = null) |
||
110 | |||
111 | /** |
||
112 | * Returns Mink session assertion tool. |
||
113 | * |
||
114 | * @param string|null $name name of the session OR active session will be used |
||
115 | * |
||
116 | * @return WebAssert |
||
117 | */ |
||
118 | public function assertSession($name = null) |
||
122 | |||
123 | /** |
||
124 | * Visits provided relative path using provided or default session. |
||
125 | * |
||
126 | * @param string $path |
||
127 | * @param string|null $sessionName |
||
128 | */ |
||
129 | public function visitPath($path, $sessionName = null) |
||
130 | { |
||
131 | $this->getSession($sessionName)->visit($this->locatePath($path)); |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * Locates url, based on provided path. |
||
136 | * Override to provide custom routing mechanism. |
||
137 | * |
||
138 | * @param string $path |
||
139 | * |
||
140 | * @return string |
||
141 | */ |
||
142 | public function locatePath($path) |
||
148 | |||
149 | /** |
||
150 | * Save a screenshot of the current window to the file system. |
||
151 | * |
||
152 | * @param string $filename Desired filename, defaults to |
||
153 | * <browser_name>_<ISO 8601 date>_<randomId>.png |
||
154 | * @param string $filepath Desired filepath, defaults to |
||
155 | * upload_tmp_dir, falls back to sys_get_temp_dir() |
||
156 | */ |
||
157 | public function saveScreenshot($filename = null, $filepath = null) |
||
165 | } |
||
166 |