I couldn't find any such thing, and I'm guessing it doesn't exist..
class Test extends PHPUnit_Framework_TestCase {
public function setUp() {
echo $current_test; // Output a string "testOne"
}
public function testOne() {
// This is the first test; before this test is ran setUp() is called.
// The question is, is there any way to know within setUp() what the
// current test is?
}
}
$this->name
should contain the current testcase method name. You can access it (as David kindly pointed out) with $this->getName()
.
Check out the API for TestCase at https://github.com/sebastianbergmann/phpunit/blob/3.6/PHPUnit/Framework/TestCase.php. Skim over the properties and their comments to get an idea of what's available.
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