PHPUnit is launched only from the command line. What for?

I have the following code:

<?php
    class MyTest extends PHPUnit_Framework_TestCase
    {
        public function testCalculate()
        {
            $this->assertEquals(2, 1 + 1);
        }
    }
?>

When I open a PHP file in a browser, I get the following error:

Fatal error: class 'PHPUnit_Framework_TestCase' not found

However, if I use the command line, it works fine: phpunit [local_path_here] /testcase.php

Result:

.

Time: 0 seconds, Memory: 5.00Mb

OK (1 test, 1 assertion)

Why? How can I run it in a browser?

+5
source share
4 answers

You can integrate the add-in to run unit tests through its own web interface:

https://github.com/NSinopoli/VisualPHPUnit

+4
source

. , : http://sebastian-bergmann.de/archives/638-PHPUnit-3.0.html#c4983

phpunit --coverage-html=coverage testcase.php

index.html .

.

+2

. , php-cli.ini php.ini. PHP . , include_path. PEAR, , PHPUnit PEAR.

0

All Articles