ExpectDeprecationTest.php

Same filename and directory in other branches
  1. 11.x core/tests/Drupal/Tests/ExpectDeprecationTest.php
  2. 10 core/tests/Drupal/Tests/ExpectDeprecationTest.php
  3. 9 core/tests/Drupal/Tests/ExpectDeprecationTest.php
  4. 8.9.x core/tests/Drupal/Tests/ExpectDeprecationTest.php

Namespace

Drupal\Tests

File

core/tests/Drupal/Tests/ExpectDeprecationTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests;

use Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use PHPUnit\Framework\TestCase;

/**
 * Ensures test coverage for deprecation testing.
 */
class ExpectDeprecationTest extends TestCase {
  use ExpectDeprecationTrait;
  
  /**
   * Tests expectDeprecation.
   */
  public function testExpectDeprecation() : void {
    $this->expectDeprecation('Test deprecation');
    // phpcs:ignore Drupal.Semantics.FunctionTriggerError
    @trigger_error('Test deprecation', E_USER_DEPRECATED);
  }
  
  /**
   * Tests expectDeprecation in isolated test.
   */
  public function testExpectDeprecationInIsolation() : void {
    $this->expectDeprecation('Test isolated deprecation');
    // phpcs:ignore Drupal.Semantics.FunctionTriggerError
    @trigger_error('Test isolated deprecation', E_USER_DEPRECATED);
  }

}

Classes

Title Deprecated Summary
ExpectDeprecationTest Ensures test coverage for deprecation testing.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.