File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,13 +24,12 @@ If codeception was not previously set up:
2424Provides full bootstrapping in to Drupal before test. Allows using drupal API in test cases.
2525
2626### Configuration
27- - root: Drupal root. Defaults to codeception root + ` /web ` .
2827- server: Server and execution environment information.
28+ - root: Drupal root. Uses DrupalFinder to detect the Drupal root. Falls back to codeception root + ` /web ` . (optional)
2929
3030```
3131modules:
3232 - DrupalBootstrap:
33- root: './web'
3433 server:
3534 SERVER_PORT: null
3635 REQUEST_URI: '/'
@@ -229,7 +228,7 @@ Includes:
229228 - FormField: Fields that can be set to cardinality unlimited
230229 - MTOFormField: Single value fields.
231230 - ParagraphFormField: Paragraph form fields.
232-
231+
233232### Usage
234233
235234Create paragraph field with machine name field_page_elements.
Original file line number Diff line number Diff line change 99 }
1010 ],
1111 "require" : {
12- "codeception/codeception" : " ^2.3 || ^3.0" ,
13- "fzaninotto/faker" : " ^1.8"
12+ "codeception/codeception" : " ^4.0" ,
13+ "fzaninotto/faker" : " ^1.8" ,
14+ "codeception/module-webdriver" : " ^1.1" ,
15+ "webflo/drupal-finder" : " ^1.2"
1416 },
1517 "require-dev" : {
1618 "composer/installers" : " ^1" ,
Original file line number Diff line number Diff line change 88use Codeception \TestDrupalKernel ;
99use Symfony \Component \HttpFoundation \Request ;
1010use Drupal \Core \DrupalKernel ;
11+ use DrupalFinder \DrupalFinder ;
12+
1113
1214/**
1315 * Class DrupalBootstrap.
@@ -46,7 +48,19 @@ class DrupalBootstrap extends Module {
4648 public function __construct (ModuleContainer $ container , $ config = NULL ) {
4749 parent ::__construct ($ container , $ config );
4850 if (!isset ($ this ->config ['root ' ])) {
49- $ this ->_setConfig (['root ' => Configuration::projectDir () . 'web ' ]);
51+
52+ $ drupalFinder = new DrupalFinder ();
53+
54+ $ drupalFinder ->locateRoot (getcwd ());
55+ $ drupalRoot = $ drupalFinder ->getDrupalRoot ();
56+
57+ // Autodetect Drupal root.
58+ if ($ drupalRoot ) {
59+ $ this ->_setConfig (['root ' => $ drupalRoot ]);
60+ }
61+ else {
62+ $ this ->_setConfig (['root ' => Configuration::projectDir () . 'web ' ]);
63+ }
5064 }
5165 chdir ($ this ->_getConfig ('root ' ));
5266 $ request = Request::createFromGlobals ();
You can’t perform that action at this time.
0 commit comments