-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathTestModule.php
More file actions
67 lines (54 loc) · 1.76 KB
/
TestModule.php
File metadata and controls
67 lines (54 loc) · 1.76 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace DrupalCodeBuilder\Generator;
use CaseConverter\CaseString;
use DrupalCodeBuilder\Definition\PropertyDefinition;
use MutableTypedData\Definition\DefaultDefinition;
/**
* Generator for a module that is used for testing.
*/
class TestModule extends Module {
/**
* {@inheritdoc}
*/
public static function getPropertyDefinition(): PropertyDefinition {
$definition = parent::getPropertyDefinition();
// Remove properties for components that test modules don't need.
foreach ([
'module_help_text',
'api',
'readme',
// 'phpunit_tests',
'tests',
] as $property) {
$definition->removeProperty($property);
}
// Acuisition hack to work in the UI stage.
$definition->addProperty(PropertyDefinition::create('string')
->setName('test_class_name')
->setInternal(TRUE)
->setExpressionDefault("get('..:..:..:plain_class_name')")
);
$definition->getProperty('root_name')->setDefault(
DefaultDefinition::create()
->setExpression("classToMachine(get('..:test_class_name'))")
->setDependencies('..:test_class_name')
);
// The package is always 'Testing' for test modules, so set this to
// computed.
$definition->getProperty('module_package')
->setLiteralDefault('Testing')
->setInternal(TRUE);
// Don't need this, but info file generators expect it.
$definition->getProperty('module_dependencies')
->setInternal(TRUE);
$definition->getProperty('component_base_path')
->setExpressionDefault('"tests/modules/" ~get("..:root_name")');
return $definition;
}
/**
* {@inheritdoc}
*/
public static function rootComponentPropertyDefinitionAlter(PropertyDefinition $definition): void {
// Do nothing.
}
}