class ExternalCommandRequirementTest
@coversDefaultClass \Drupal\BuildTests\Framework\ExternalCommandRequirementsTrait
      
    
@group Build
Hierarchy
- class \Drupal\BuildTests\Framework\Tests\ExternalCommandRequirementTest extends \PHPUnit\Framework\TestCase
Expanded class hierarchy of ExternalCommandRequirementTest
File
- 
              core/tests/ Drupal/ BuildTests/ Framework/ Tests/ ExternalCommandRequirementTest.php, line 13 
Namespace
Drupal\BuildTests\Framework\TestsView source
class ExternalCommandRequirementTest extends TestCase {
  
  /**
   * @covers ::checkExternalCommandRequirements
   */
  public function testCheckExternalCommandRequirementsNotAvailable() {
    $requires = new UsesCommandRequirements();
    $ref_check_requirements = new \ReflectionMethod($requires, 'checkExternalCommandRequirements');
    $ref_check_requirements->setAccessible(TRUE);
    // Use a try/catch block because otherwise PHPUnit might think this test is
    // legitimately skipped.
    try {
      $ref_check_requirements->invokeArgs($requires, [
        [
          'externalCommand not_available',
          'externalCommand available_command',
        ],
      ]);
      $this->fail('Unavailable external command requirement should throw a skipped test error exception.');
    } catch (SkippedTestError $exception) {
      $this->assertEquals('Required external commands: not_available', $exception->getMessage());
    }
  }
  
  /**
   * @covers ::checkExternalCommandRequirements
   */
  public function testCheckExternalCommandRequirementsAvailable() {
    $requires = new UsesCommandRequirements();
    $ref_check_requirements = new \ReflectionMethod($requires, 'checkExternalCommandRequirements');
    $ref_check_requirements->setAccessible(TRUE);
    // Use a try/catch block because otherwise PHPUnit might think this test is
    // legitimately skipped.
    try {
      $this->assertNull($ref_check_requirements->invokeArgs($requires, [
        [
          'externalCommand available_command',
        ],
      ]));
    } catch (SkippedTestError $exception) {
      $this->fail(sprintf('The external command should be available: %s', $exception->getMessage()));
    }
  }
  
  /**
   * @covers ::checkClassCommandRequirements
   */
  public function testClassRequiresAvailable() {
    $requires = new ClassRequiresAvailable();
    $ref_check = new \ReflectionMethod($requires, 'checkClassCommandRequirements');
    $ref_check->setAccessible(TRUE);
    // Use a try/catch block because otherwise PHPUnit might think this test is
    // legitimately skipped.
    try {
      $this->assertNull($ref_check->invoke($requires));
    } catch (SkippedTestError $exception) {
      $this->fail(sprintf('The external command should be available: %s', $exception->getMessage()));
    }
  }
  
  /**
   * @covers ::checkClassCommandRequirements
   */
  public function testClassRequiresUnavailable() {
    $requires = new ClassRequiresUnavailable();
    $ref_check = new \ReflectionMethod($requires, 'checkClassCommandRequirements');
    $ref_check->setAccessible(TRUE);
    // Use a try/catch block because otherwise PHPUnit might think this test is
    // legitimately skipped.
    try {
      $this->assertNull($ref_check->invoke($requires));
      $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());
    }
  }
  
  /**
   * @covers ::checkMethodCommandRequirements
   */
  public function testMethodRequiresAvailable() {
    $requires = new MethodRequires();
    $ref_check = new \ReflectionMethod($requires, 'checkMethodCommandRequirements');
    $ref_check->setAccessible(TRUE);
    // Use a try/catch block because otherwise PHPUnit might think this test is
    // legitimately skipped.
    try {
      $this->assertNull($ref_check->invoke($requires, 'testRequiresAvailable'));
    } catch (SkippedTestError $exception) {
      $this->fail(sprintf('The external command should be available: %s', $exception->getMessage()));
    }
  }
  
  /**
   * @covers ::checkMethodCommandRequirements
   */
  public function testMethodRequiresUnavailable() {
    $requires = new MethodRequires();
    $ref_check = new \ReflectionMethod($requires, 'checkMethodCommandRequirements');
    $ref_check->setAccessible(TRUE);
    // 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());
    }
  }
}Members
| Title Sort descending | Modifiers | Object type | Summary | 
|---|---|---|---|
| ExternalCommandRequirementTest::testCheckExternalCommandRequirementsAvailable | public | function | @covers ::checkExternalCommandRequirements[[api-linebreak]] | 
| ExternalCommandRequirementTest::testCheckExternalCommandRequirementsNotAvailable | public | function | @covers ::checkExternalCommandRequirements[[api-linebreak]] | 
| ExternalCommandRequirementTest::testClassRequiresAvailable | public | function | @covers ::checkClassCommandRequirements[[api-linebreak]] | 
| ExternalCommandRequirementTest::testClassRequiresUnavailable | public | function | @covers ::checkClassCommandRequirements[[api-linebreak]] | 
| ExternalCommandRequirementTest::testMethodRequiresAvailable | public | function | @covers ::checkMethodCommandRequirements[[api-linebreak]] | 
| ExternalCommandRequirementTest::testMethodRequiresUnavailable | public | function | @covers ::checkMethodCommandRequirements[[api-linebreak]] | 
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
