Skip to content

Instantly share code, notes, and snippets.

@jhedstrom
jhedstrom / notes.md
Created November 1, 2016 20:34
PHPUnit based tests in Drupal 8

Local setup

  • Environment variables:

    export SIMPLETEST_DB=mysql://user:pass@localhost/db_name
    export SIMPLETEST_BASE_URL=http://d8.dev
    
  • or copy core/phpunit.xml.dist to core/phpunit.xml and edit accordingly

@crittermike
crittermike / IntegerDropdownWidget.php
Created October 17, 2016 20:14
Drupal 8 form widget example: creates a select dropdown for integer fields. Place in src/Plugin/Field/FieldWidget
<?php
/**
* @file
* Defines a dropdown widget for integer fields.
*/
namespace Drupal\nba_content_core\Plugin\Field\FieldWidget;
use Drupal\Core\Field\FieldFilteredMarkup;
use Drupal\Core\Field\FieldItemListInterface;
@jonpugh
jonpugh / FeatureContext.php
Last active November 21, 2018 14:21
This custom Behat FeatureContext includes a step called "Then every link should work". It checks every visitable link on a page for a 200 code.
<?php
use Drupal\DrupalExtension\Context\RawDrupalContext;
use Drupal\DrupalExtension\Context\DrupalContext;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;