There are many test modules in Drupal 8 such as entity_test and off_canvas_test. To allow you to run these locally and test manually, add the following to settings.php:

$settings['extension_discovery_scan_tests'] = TRUE;

Debugging tests can often be a pain, but using this snippet it's possible to get the HTML of a page when using BrowserTestBase.


There are times, often in tests or upgrade paths, where we want to programmatically install a module. Here's how:


Place this code within .htaccess underneath RewriteEngine on.

RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


This is especially useful in kernel tests.

$node = \Drupal\node\Entity\Node::create([
  'type' => 'article',
  'title' => 'Example Node'