Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / tests / src / Unit / ModuleMockerTrait.php
1 <?php
2
3 namespace Drupal\Tests\drupalmoduleupgrader\Unit;
4
5 use org\bovigo\vfs\vfsStream;
6
7 /**
8  * A trait for tests that need a mock module to work on.
9  */
10 trait ModuleMockerTrait {
11
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);
22
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);
27
28     return $dir;
29   }
30
31 }