PhpUnitBridgeRequiresTest.php 1.06 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
<?php

namespace Drupal\Tests\Core\Test;

use Drupal\Tests\UnitTestCase;
use Drupal\deprecation_test\Deprecation\FixtureDeprecatedClass;

/**
 * Test how unit tests interact with deprecation errors.
 *
 * If a test requires an extension that does not exist and has a data provider
 * the interaction between Drupal and Symfony's deprecation testing can cause
 * errors. This test proves this is not broken.
 *
 * This test will be skipped and should not cause the test suite to fail.
 *
 * @group Test
 * @requires extension will_hopefully_never_exist
 * @see \Drupal\Tests\Listeners\DrupalListener
 */
class PhpUnitBridgeRequiresTest extends UnitTestCase {

  /**
   * Tests the @requires annotation.
   *
   * @dataProvider providerTestWillNeverRun
   */
  public function testWillNeverRun(): void {
    $deprecated = new FixtureDeprecatedClass();
    $this->assertEquals('test', $deprecated->testFunction());
  }

  /**
   * Data provider for ::testWillNeverRun().
   */
  public function providerTestWillNeverRun(): array {
    return [
      ['this_will_never_run'],
    ];
  }

}