PHPUnit: How to run tests from browser?
phpunit, zend-framework
Solution
I have found a solution that works well:
<?php
define("PHPUNIT_COMPOSER_INSTALL","vendor/autoload.php");
require PHPUNIT_COMPOSER_INSTALL;
$query = $_SERVER["QUERY_STRING"];
//$_SERVER["QUERY_STRING"] to $_SERVER['argv'];
$_SERVER['argv'] = explode("&",$query);
//PHPUnit use $_SERVER['argv'] for input value
PHPUnit\TextUI\Command::main(false);
/*Use
command line "./vendor/bin/phpunit param1 param2 param..."
browser URI "localhost?param1¶m2¶m..."
*/
Problem
I know PHPUnit tests can be executed from the command line, but is there an easy way to run it from the browser. For example, I have: ``` class testsSuite extends PHPUnit_Framework_TestSuite { public function __construct () { $this->setName('testsSuite'); $this->addTestSuite('MyFirstTest'); } public static function suite () { return new self(); } } ``` And then I have: ``` class MyFirstTest extends PHPUnit_Framework_TestCase { protected function setUp () { parent::setUp(); } protected function tearDown () { parent::tearDown(); } public function __construct () { } public function test__construct () { } public function test__destruct () { } public function testCalculateCost () { print 1; die(); } } ``` Is there a URL I can enter in my browser to execute this test? Something like: ``` http://localhost/tests/testsSuite/calculateCost ``` Or something similar