Page MenuHomeWickedGov Phorge

PHPUnitDeprecationHelper.php
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

PHPUnitDeprecationHelper.php

<?php
namespace Eris;
use PHPUnit\Framework\TestCase;
final class PHPUnitDeprecationHelper
{
public static function assertIsString($actual, string $message = ''): void
{
if (method_exists(TestCase::class, 'assertIsString')) {
TestCase::assertIsString($actual, $message);
} elseif (method_exists(TestCase::class, 'assertInternalType')) {
TestCase::assertInternalType('string', $actual, $message);
} else {
TestCase::fail('Unable to find the assertion method');
}
}
public static function assertIsInt($actual, string $message = ''): void
{
if (method_exists(TestCase::class, 'assertIsInt')) {
TestCase::assertIsInt($actual, $message);
} elseif (method_exists(TestCase::class, 'assertInternalType')) {
TestCase::assertInternalType('int', $actual, $message);
} else {
TestCase::fail('Unable to find the assertion method');
}
}
public static function assertIsArray($actual, string $message = ''): void
{
if (method_exists(TestCase::class, 'assertIsArray')) {
TestCase::assertIsArray($actual, $message);
} elseif (method_exists(TestCase::class, 'assertInternalType')) {
TestCase::assertInternalType('array', $actual, $message);
} else {
TestCase::fail('Unable to find the assertion method');
}
}
public static function assertIsBool($actual, string $message = ''): void
{
if (method_exists(TestCase::class, 'assertIsBool')) {
TestCase::assertIsBool($actual, $message);
} elseif (method_exists(TestCase::class, 'assertInternalType')) {
TestCase::assertInternalType('bool', $actual, $message);
} else {
TestCase::fail('Unable to find the assertion method');
}
}
public static function assertIsFloat($actual, string $message = ''): void
{
if (method_exists(TestCase::class, 'assertIsFloat')) {
TestCase::assertIsFloat($actual, $message);
} elseif (method_exists(TestCase::class, 'assertInternalType')) {
TestCase::assertInternalType('float', $actual, $message);
} else {
TestCase::fail('Unable to find the assertion method');
}
}
public static function assertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void
{
if (method_exists(TestCase::class, 'assertMatchesRegularExpression')) {
TestCase::assertMatchesRegularExpression($pattern, $string, $message);
} elseif (method_exists(TestCase::class, 'assertInternalType')) {
TestCase::assertRegExp($pattern, $string, $message);
} else {
TestCase::fail('Unable to find the assertion method');
}
}
public static function assertStringNotContainsString(string $needle, string $haystack, string $message = ''): void
{
if (method_exists(TestCase::class, 'assertStringNotContainsString')) {
TestCase::assertStringNotContainsString($needle, $haystack, $message);
} elseif (method_exists(TestCase::class, 'assertNotContains')) {
TestCase::assertNotContains($needle, $haystack, $message);
} else {
TestCase::fail('Unable to find the assertion method');
}
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, Oct 3, 05:37 (2 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
2e/0e/f225aa3bb938b70f5f613811f071
Default Alt Text
PHPUnitDeprecationHelper.php (3 KB)

Event Timeline