1: <?php
2: require_once __DIR__."/../autoload.php";
3: require_once __DIR__."/mocks/WebDriverMock.php";
4: require_once __DIR__."/classes/SimpleView.php";
5: require_once __DIR__."/classes/SimpleViewWithNoHash.php";
6: require_once __DIR__."/classes/SimpleViewWithArgs.php";
7:
8: 9: 10: 11:
12: class ViewTest extends PHPUnit_Framework_TestCase
13: {
14: public function setUp()
15: {
16: $this->driver = new WebDriverMock();
17: }
18:
19: public function testLoadingViewWithNoHash()
20: {
21: $driver = $this->driver;
22: $driver->url("http://www.example.com/");
23:
24: $view = SimpleViewWithNoHash::get($driver);
25: $this->assertEquals("http://www.example.com/", $driver->url());
26: }
27:
28: public function testLoadingViewFromNoHash()
29: {
30: $driver = $this->driver;
31: $driver->url("http://www.example.com/");
32:
33: $view = SimpleView::get($driver);
34: $this->assertEquals("http://www.example.com/#patients", $driver->url());
35: }
36:
37: public function testLoadingViewFromHash()
38: {
39: $driver = $this->driver;
40: $driver->url("http://www.example.com/#encounters");
41:
42: $view = SimpleView::get($driver);
43: $this->assertEquals("http://www.example.com/#patients", $driver->url());
44: }
45:
46: public function testLoadViewWithArgs()
47: {
48: $driver = $this->driver;
49: $driver->url("http://www.example.com/");
50:
51: $view = SimpleViewWithArgs::get($driver, array('patient' => "123"));
52: $this->assertEquals("http://www.example.com/#/patients/p/123", $driver->url());
53: }
54:
55: public function testViewSelectorWithNoArgs()
56: {
57: $driver = $this->driver;
58: $driver->url("http://www.example.com/");
59:
60: $view = new SimpleView($driver);
61: $this->assertEquals("#patient", $view->getViewSelector());
62: }
63:
64: public function testViewSelectorWithArgs()
65: {
66: $driver = $this->driver;
67: $driver->url("http://www.example.com/");
68:
69: $view = new SimpleViewWithArgs($driver);
70: $this->assertEquals("#patient123", $view->getViewSelector(array("patient" => 123)));
71: }
72: }
73: ?>