Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. VerifyDeprecations.php

trait VerifyDeprecations

Hierarchy

  • trait \Doctrine\Deprecations\PHPUnit\VerifyDeprecations

File

vendor/doctrine/deprecations/lib/Doctrine/Deprecations/PHPUnit/VerifyDeprecations.php, line 11

Namespace

Doctrine\Deprecations\PHPUnit
View source
trait VerifyDeprecations {
    
    /** @var array<string,int> */
    private $doctrineDeprecationsExpectations = [];
    
    /** @var array<string,int> */
    private $doctrineNoDeprecationsExpectations = [];
    public function expectDeprecationWithIdentifier(string $identifier) : void {
        $this->doctrineDeprecationsExpectations[$identifier] = Deprecation::getTriggeredDeprecations()[$identifier] ?? 0;
    }
    public function expectNoDeprecationWithIdentifier(string $identifier) : void {
        $this->doctrineNoDeprecationsExpectations[$identifier] = Deprecation::getTriggeredDeprecations()[$identifier] ?? 0;
    }
    
    /**
     * @before
     */
    public function enableDeprecationTracking() : void {
        Deprecation::enableTrackingDeprecations();
    }
    
    /**
     * @after
     */
    public function verifyDeprecationsAreTriggered() : void {
        foreach ($this->doctrineDeprecationsExpectations as $identifier => $expectation) {
            $actualCount = Deprecation::getTriggeredDeprecations()[$identifier] ?? 0;
            $this->assertTrue($actualCount > $expectation, sprintf("Expected deprecation with identifier '%s' was not triggered by code executed in test.", $identifier));
        }
        foreach ($this->doctrineNoDeprecationsExpectations as $identifier => $expectation) {
            $actualCount = Deprecation::getTriggeredDeprecations()[$identifier] ?? 0;
            $this->assertTrue($actualCount === $expectation, sprintf("Expected deprecation with identifier '%s' was triggered by code executed in test, but expected not to.", $identifier));
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary
VerifyDeprecations::$doctrineDeprecationsExpectations private property @var array&lt;string,int&gt;
VerifyDeprecations::$doctrineNoDeprecationsExpectations private property @var array&lt;string,int&gt;
VerifyDeprecations::enableDeprecationTracking public function @before
VerifyDeprecations::expectDeprecationWithIdentifier public function
VerifyDeprecations::expectNoDeprecationWithIdentifier public function
VerifyDeprecations::verifyDeprecationsAreTriggered public function @after

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal