1: <?php
2:
3: class WebDriverMock
4: {
5: protected $url = "";
6: protected $title = "";
7:
8: public function url($url = null)
9: {
10: if (is_null($url)) {
11: return $this->url;
12: }
13:
14: $this->url = $url;
15: }
16:
17: public function title($title = null)
18: {
19: if (is_null($title)) {
20: return $this->title;
21: }
22:
23: $this->title = $title;
24: }
25:
26: public function getBrowserUrl()
27: {
28: return $this->url();
29: }
30:
31: public function byCss($css)
32: {
33: return true;
34: }
35:
36: public function updateHash($hash)
37: {
38: $url = $this->url;
39:
40: if(($hashPos = strpos($url, "#")) !== false) {
41:
42: $url = substr($url, 0, $hashPos);
43: }
44:
45: $url .= "#" . $hash;
46:
47: $this->url = $url;
48: }
49:
50: public function execute($actions = array())
51: {
52: if (isset($actions['script'])) {
53: $script = $actions['script'];
54: if (stripos($script, "window.location.hash = '") !== false) {
55: $hash = str_replace("window.location.hash = '", "", $script);
56: $hash = substr($hash, 0, strlen($hash) - 1);
57: $this->updateHash($hash);
58: }
59: }
60: return true;
61: }
62: }
63: ?>