You are here

private function Tests::setModules in Drupal 7 to 8/9 Module Upgrader 8

Sets the test's $modules property.

Parameters

\Pharborist\Objects\ClassNode $test:

2 calls to Tests::setModules()
Tests::convertAjax in src/Plugin/DMU/Converter/Tests.php
Converts a single Ajax test.
Tests::convertWeb in src/Plugin/DMU/Converter/Tests.php
Converts a single web test.

File

src/Plugin/DMU/Converter/Tests.php, line 129

Class

Tests
Plugin annotation @Converter( id = "tests", description = @Translation("Modifies test classes.") )

Namespace

Drupal\drupalmoduleupgrader\Plugin\DMU\Converter

Code

private function setModules(ClassNode $test) {
  $modules = $this
    ->extractModules($test);
  if ($modules) {

    // @todo Use ClassNode::createProperty() when #124 lands in Pharborist
    $property = Parser::parseSnippet('class Foo { public static $modules = ["' . implode('", "', $modules) . '"]; }')
      ->getBody()
      ->firstChild()
      ->remove();
    $test
      ->appendProperty($property);
  }
}