public function testBaseUrl()
 {
     $client = new Client(require __DIR__ . '/../app.php');
     $driver = new BrowserKitDriver($client, 'http://localhost/foo/');
     $session = new Session($driver);
     $session->visit('http://localhost/foo/index.html');
     $this->assertEquals(200, $session->getStatusCode());
     $this->assertEquals('http://localhost/foo/index.html', $session->getCurrentUrl());
 }
Example #2
0
 /**
  * Returns response information string.
  *
  * @return  string
  */
 protected function getResponseInfo()
 {
     $driver = basename(str_replace('\\', '/', get_class($this->session->getDriver())));
     $info = '+--[ ';
     if (!in_array($driver, array('SahiDriver', 'SeleniumDriver'))) {
         $info .= 'HTTP/1.1 ' . $this->session->getStatusCode() . ' | ';
     }
     $info .= $this->session->getCurrentUrl() . ' | ' . $driver . " ]\n|\n";
     return $info;
 }
Example #3
0
 /**
  * Test record tabs for a particular ID.
  *
  * @param Session $session  Session
  * @param string  $id       ID to load
  * @param bool    $encodeId Should we URL encode the ID?
  *
  * @return void
  */
 protected function tryRecordTabsOnId(Session $session, $id, $encodeId = true)
 {
     $url = $this->getVuFindUrl('/Record/' . ($encodeId ? rawurlencode($id) : $id));
     $session->visit($url);
     $this->assertEquals(200, $session->getStatusCode());
     $page = $session->getPage();
     $staffViewTab = $page->findById('details');
     $this->assertTrue(is_object($staffViewTab));
     $this->assertEquals('Staff View', $staffViewTab->getText());
     $staffViewTab->click();
     $this->assertEquals($url . '#details', $session->getCurrentUrl());
     $staffViewTable = $page->find('css', '#details-tab table.citation');
     $this->assertTrue(is_object($staffViewTable));
     $this->assertEquals('LEADER', substr($staffViewTable->getText(), 0, 6));
 }
 /**
  * @param $not
  * @param TableNode $paths
  *
  * @throws \Exception
  *
  * @Given /^user should(| not) have an access to the following pages:$/
  */
 public function checkUserAccessToPages($not, TableNode $paths)
 {
     $result = [];
     $code = $not ? 403 : 200;
     // Use "GoutteDriver" to have an ability to check answer code.
     $driver = new Mink\Driver\GoutteDriver();
     $session = new Mink\Session($driver);
     $session->start();
     foreach (array_keys($paths->getRowsHash()) as $path) {
         $path = trim($path, '/');
         $session->visit($this->locatePath($path));
         if ($session->getStatusCode() !== $code) {
             $result[] = $path;
         }
     }
     if (!empty($result)) {
         throw new \Exception(sprintf('The following paths: "%s" are %s accessible!', implode(', ', $result), $not ? '' : 'not'));
     }
 }
 public function testGetStatusCode()
 {
     $this->driver->expects($this->once())->method('getStatusCode')->will($this->returnValue($ret = 404));
     $this->assertEquals($ret, $this->session->getStatusCode());
 }
Example #6
0
 public function _getResponseCode()
 {
     return $this->session->getStatusCode();
 }
 /**
  * @param string $name
  * @param Session  $subject
  * @param array  $arguments
  *
  * @return FailureException
  */
 protected function getNegativeFailureException($name, $subject, array $arguments)
 {
     return new FailureException(sprintf('Expected session not to have status code %s, but it is.', $this->presenter->presentValue($subject->getStatusCode())));
 }