Run a PHPUnit Selenium test case programatically ("within PHP")
Just use the Driver that's included.
require_once 'PHPUnit/Extensions/SeleniumTestCase/Driver.php';//You may need to load a few other libraries. Try it.
Then you need to set it up like SeleniumTestCase does:
$driver = new PHPUnit_Extensions_SeleniumTestCase_Driver;$driver->setName($browser['name']);$driver->setBrowser($browser['browser']);$driver->setHost($browser['host']);$driver->setPort($browser['port']);$driver->setTimeout($browser['timeout']);$driver->setHttpTimeout($browser['httpTimeout']);
Then just:
$driver->open('/');$driver->click("//a[@href='/contact/']");
Here's an example from the phpunit docs:
<?phprequire_once 'PHPUnit/Framework.php';require_once 'ArrayTest.php';require_once 'SimpleTestListener.php';// Create a test suite that contains the tests// from the ArrayTest class.$suite = new PHPUnit_Framework_TestSuite('ArrayTest');// Create a test result and attach a SimpleTestListener// object as an observer to it.$result = new PHPUnit_Framework_TestResult;$result->addListener(new SimpleTestListener);// Run the tests.$suite->run($result);?>
The code for SimpleTestListener is on the same page.