<?php
class MyTest extends PHPUnit_Extensions_Selenium2TestCase{
function setUp(){
$this->setBrowser("phantomjs");
$this->setBrowserUrl('http://localhost');
$this->setHost("127.0.0.1");
$this->setPort(4444);
}
function testForm(){
$this->url('/test.html');
$form = $this->byId('login-form');
$this->assertEquals('/post/login', $this->getRelativeFormAction($form));
}
function getRelativeFormAction($form){
$action = $form->attribute('action');
$action = str_replace($this->getBaseUrl(), '', $action);
return $action;
}
function getBaseUrl(){
$urlComponents = parse_url($this->url());
$url = "{$urlComponents['scheme']}://{$urlComponents['host']}";
return $url;
}
}