function ExternalCommandRequirementTest::testMethodRequiresUnavailable

Same name and namespace in other branches
  1. 9 core/tests/Drupal/BuildTests/Framework/Tests/ExternalCommandRequirementTest.php \Drupal\BuildTests\Framework\Tests\ExternalCommandRequirementTest::testMethodRequiresUnavailable()
  2. 8.9.x core/tests/Drupal/BuildTests/Framework/Tests/ExternalCommandRequirementTest.php \Drupal\BuildTests\Framework\Tests\ExternalCommandRequirementTest::testMethodRequiresUnavailable()

@covers ::checkMethodCommandRequirements

File

core/tests/Drupal/BuildTests/Framework/Tests/ExternalCommandRequirementTest.php, line 119

Class

ExternalCommandRequirementTest
@coversDefaultClass <a href="/api/drupal/core%21tests%21Drupal%21BuildTests%21Framework%21ExternalCommandRequirementsTrait.php/trait/ExternalCommandRequirementsTrait/10" title="Allows test classes to require external command line applications." class="local">\Drupal\BuildTests\Framework\ExternalCommandRequirementsTrait</a> @group Build @group legacy

Namespace

Drupal\BuildTests\Framework\Tests

Code

public function testMethodRequiresUnavailable() : void {
    $this->expectDeprecation('Drupal\\BuildTests\\Framework\\ExternalCommandRequirementsTrait::checkMethodCommandRequirements() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use Drupal\\TestTools\\Extension\\RequiresComposerTrait instead. See https://www.drupal.org/node/3362239');
    $requires = new MethodRequires();
    $ref_check = new \ReflectionMethod($requires, 'checkMethodCommandRequirements');
    // Use a try/catch block because otherwise PHPUnit might think this test is
    // legitimately skipped.
    try {
        $this->assertNull($ref_check->invoke($requires, 'testRequiresUnavailable'));
        $this->fail('Unavailable external command requirement should throw a skipped test error exception.');
    } catch (SkippedTestError $exception) {
        $this->assertEquals('Required external commands: unavailable_command', $exception->getMessage());
    }
}

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