3 namespace Drupal\Tests\drupalmoduleupgrader\Unit;
5 use org\bovigo\vfs\vfsStream;
8 * A trait for tests that need a mock module to work on.
10 trait ModuleMockerTrait {
12 protected function mockModule($id) {
13 // Create a virtual (in-memory) directory for the module, and touch
14 // a few empty files. Tests should fill in the code of the module
15 // according to their own needs.
16 $dir = vfsStream::setup($id);
17 vfsStream::newFile($id . '.module')->at($dir);
18 vfsStream::newFile($id . '.info')->at($dir);
19 vfsStream::newFile($id . '.install')->at($dir);
20 vfsStream::newFile($id . '.test')->at($dir);
21 vfsStream::newDirectory('src')->at($dir);
23 $config_dir = vfsStream::newDirectory('config')->at($dir);
24 vfsStream::newDirectory('install')->at($config_dir);
25 vfsStream::newDirectory('optional')->at($config_dir);
26 vfsStream::newDirectory('schema')->at($config_dir);