1. Go to this page and download the library: Download williams/testtube library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
williams / testtube example snippets
//tests/demo/calculator.php
return new class extends BaseTest{
};
use Demo\Calculator;
return new class extends BaseTest{
public function boot(){
return new Calculator;
}
};
return [ new Foo, new Bar ];
use Demo\Calculator;
return new class extends BaseTest{
public function boot(){
return new Calculator;
}
public function testAdd($calculator){
}
};
public function testAdd($calculator){
$output = $calculator->add(2,3);
$this->assertEquals(5,$output);
}
return new class extends BaseTest {
protected $useMethods = ['customTest'];
protected $useTestMethods = false;
public function customTest() {
// This is a valid test method.
}
public function testExample() {
// This method will not be treated as a test due to $useTestMethods being false.
}
};
// templates/CalculatorBaseTest.php
use Demo\Calculator;
class CalculatorBaseTest extends BaseTest{
public function boot(){
return new Calculator;
}
}
// tests/demo/calculator.php
return new class extends CalculatorBaseTest{
public function testAdd($calculator){
$output = $calculator->add(2,3);
$this->assertEquals(5,$output);
}
};
return new class extends CalculatorBaseTest {
public function setup($calculator) {
$calculator->useRadians();
$calculator->roundDecimalPlaces(2);
}
};
bash
composer dump-autoload
bash
php test
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.