Files
whoops/tests/Whoops/TestCase.php
T
2025-11-25 20:36:46 +01:00

83 lines
1.9 KiB
PHP

<?php
/**
* Whoops - php errors for cool kids
* @author Filipe Dobreira <http://github.com/filp>
*/
namespace Whoops;
use PHPUnit\Framework\TestCase as BaseTestCase;
class TestCase extends BaseTestCase
{
/**
* @return Run
*/
protected function getRunInstance()
{
$run = new Run();
$run->allowQuit(false);
return $run;
}
/**
* @param string $class
* @return void
*/
protected function expectExceptionOfType($class)
{
if (method_exists($this, 'expectException')) {
$this->expectException($class);
} else {
$this->setExpectedException($class);
}
}
/**
* @param string $a
* @param string $b
* @return void
*/
protected function assertStringContains($a, $b)
{
if (method_exists($this, 'assertStringContainsString')) {
$this->assertStringContainsString($a, $b);
} else {
$this->assertContains($a, $b);
}
}
/**
* @param string $a
* @param string $b
* @return void
*/
protected function assertStringNotContains($a, $b)
{
if (method_exists($this, 'assertStringNotContainsString')) {
$this->assertStringNotContainsString($a, $b);
} else {
$this->assertNotContains($a, $b);
}
}
/**
* @param object|string $class_or_object
* @param string $method
* @param mixed[] $args
* @return mixed
*/
public static function callPrivateMethod($class_or_object, $method, $args = [])
{
$ref = new \ReflectionMethod($class_or_object, $method);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$object = is_object($class_or_object) ? $class_or_object : null;
return $ref->invokeArgs($object, $args);
}
}