View source
<?php
namespace Drupal\TestTools\PhpUnitCompatibility\PhpUnit7;
trait TestCompatibilityTrait {
public static function assertTrue($actual, string $message = '') : void {
if (is_bool($actual)) {
parent::assertTrue($actual, $message);
}
else {
@trigger_error('Support for asserting against non-boolean values in ::assertTrue is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use a different assert method, for example, ::assertNotEmpty(). See https://www.drupal.org/node/3082086', E_USER_DEPRECATED);
parent::assertNotEmpty($actual, $message);
}
}
public static function assertFalse($actual, string $message = '') : void {
if (is_bool($actual)) {
parent::assertFalse($actual, $message);
}
else {
@trigger_error('Support for asserting against non-boolean values in ::assertFalse is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use a different assert method, for example, ::assertEmpty(). See https://www.drupal.org/node/3082086', E_USER_DEPRECATED);
parent::assertEmpty($actual, $message);
}
}
public static function assertStringContainsString(string $needle, string $haystack, string $message = '') : void {
static::assertContains($needle, $haystack, $message);
}
public static function assertStringContainsStringIgnoringCase(string $needle, string $haystack, string $message = '') : void {
static::assertContains($needle, $haystack, $message, TRUE);
}
public static function assertStringNotContainsString(string $needle, string $haystack, string $message = '') : void {
static::assertNotContains($needle, $haystack, $message);
}
public static function assertStringNotContainsStringIgnoringCase(string $needle, string $haystack, string $message = '') : void {
static::assertNotContains($needle, $haystack, $message, TRUE);
}
public static function assertEqualsCanonicalizing($expected, $actual, string $message = '') : void {
static::assertEquals($expected, $actual, $message, 0.0, 10, TRUE);
}
public static function assertNotEqualsCanonicalizing($expected, $actual, string $message = '') : void {
static::assertNotEquals($expected, $actual, $message, 0.0, 10, TRUE);
}
public static function assertIsArray($actual, string $message = '') : void {
static::assertInternalType('array', $actual, $message);
}
public static function assertIsBool($actual, string $message = '') : void {
static::assertInternalType('bool', $actual, $message);
}
public static function assertIsFloat($actual, string $message = '') : void {
static::assertInternalType('float', $actual, $message);
}
public static function assertIsInt($actual, string $message = '') : void {
static::assertInternalType('int', $actual, $message);
}
public static function assertIsNumeric($actual, string $message = '') : void {
static::assertInternalType('numeric', $actual, $message);
}
public static function assertIsObject($actual, string $message = '') : void {
static::assertInternalType('object', $actual, $message);
}
public static function assertIsResource($actual, string $message = '') : void {
static::assertInternalType('resource', $actual, $message);
}
public static function assertIsString($actual, string $message = '') : void {
static::assertInternalType('string', $actual, $message);
}
public static function assertIsScalar($actual, string $message = '') : void {
static::assertInternalType('scalar', $actual, $message);
}
public static function assertIsCallable($actual, string $message = '') : void {
static::assertInternalType('callable', $actual, $message);
}
public static function assertIsNotArray($actual, string $message = '') : void {
static::assertNotInternalType('array', $actual, $message);
}
public static function assertIsNotBool($actual, string $message = '') : void {
static::assertNotInternalType('bool', $actual, $message);
}
public static function assertIsNotFloat($actual, string $message = '') : void {
static::assertNotInternalType('float', $actual, $message);
}
public static function assertIsNotInt($actual, string $message = '') : void {
static::assertNotInternalType('int', $actual, $message);
}
public static function assertIsNotNumeric($actual, string $message = '') : void {
static::assertNotInternalType('numeric', $actual, $message);
}
public static function assertIsNotObject($actual, string $message = '') : void {
static::assertNotInternalType('object', $actual, $message);
}
public static function assertIsNotResource($actual, string $message = '') : void {
static::assertNotInternalType('resource', $actual, $message);
}
public static function assertIsNotString($actual, string $message = '') : void {
static::assertNotInternalType('string', $actual, $message);
}
public static function assertIsNotScalar($actual, string $message = '') : void {
static::assertNotInternalType('scalar', $actual, $message);
}
public static function assertIsNotCallable($actual, string $message = '') : void {
static::assertNotInternalType('callable', $actual, $message);
}
}