I'm new to PHPUnit. I have php files that don't have any classes in them. What I came to understand from reading documentation, PHPUnit considers a class as a single unit. So Does PHPUnit considers a class as a unit? Is it possible to test php files that don't have any class in them?
PHPUnit is a unit testing framework for the PHP programming language. It is an instance of the xUnit design for unit testing systems that began with SUnit and became popular with JUnit. Even a small software development project usually takes hours of hard work.
The <testsuite> Element.
From the Menu-bar, select Run | Run As | PHPUnit Test . To debug the PHPUnit Test Case, click the arrow next to the debug button on the toolbar, and select Debug As | PHPUnit Test . From the Main Menu, select Run | Debug As | PHPUnit Test . The unit test will be run and a PHP Unit view will open.
Sure, you can absolutely test other PHP scripts.
class MyScriptTest extends PHPUnit_Framework_TestCase {
public function testMyFunction() {
include_once 'path/to/script.php';
$result = someFunction();
$this->assertEquals('expected result', $result);
}
}
So write PHPUnit test classes, and inside a test run whatever code you wish to test and make assertions against it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With