Skip to content

Instantly share code, notes, and snippets.

Feature: As a user of the drupal-extension and drupal driver
I want to properly set term references on content
So that I may reliably conduct tests
@api
Scenario: Duplicate terms in different vocabs
Given "category" terms:
| name |
| A |
| B |
<?php
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
/**
* Defines application features from the specific context.
*/
class FeatureContext implements Context, SnippetAcceptingContext {
@kerasai
kerasai / Vagrantfile
Last active March 20, 2017 20:20
Kerasai LAMP Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.manage_guest = true
config.vm.define 'mywebsite' do |box|
box.vm.box = "kerasai/lamp"
@kerasai
kerasai / FailureContext.php
Last active August 3, 2017 11:05
Behat context for obtaining screenshots on step failure.
<?php
use Behat\Mink\Driver\Selenium2Driver;
use Behat\Behat\Hook\Scope\AfterStepScope;
use Behat\Mink\Mink;
use Behat\MinkExtension\Context\MinkAwareContext;
/**
* Class FailureContext.
*
@kerasai
kerasai / Search API Reindex
Last active June 27, 2017 22:58
Drupal 8, populates the Search API queue for indexing all entities. Needed in cases where the entity does not populate the index queue on its own.
<?php
$index = \Drupal\search_api\Entity\Index::load('index_name');
foreach ($index->getDatasources() as $id => $datasource) {
$index->trackItemsInserted($id, $datasource->getItemIds());
}
@kerasai
kerasai / File Context
Created June 28, 2017 20:52
Behat context for working with files in Drupal 8.
<?php
use Behat\Gherkin\Node\PyStringNode;
use Behat\Mink\Element\NodeElement;
use Behat\Mink\Mink;
use Behat\MinkExtension\Context\MinkAwareContext;
/**
* Class FileContext.
*/
@kerasai
kerasai / php_error_reporting.php
Last active January 25, 2019 12:09
PHP/Drupal Error Reporting
<?php
# Error reporting.
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
ini_set('memory_limit', '64M');
# Drupal mail system to DevelMailLog.
$conf['mail_system'] = array(
@kerasai
kerasai / EntityReferenceContext.php
Last active July 31, 2017 19:00
Sets and clears values from a Drupal entity reference field widget.
<?php
use Behat\Mink\Mink;
use Behat\MinkExtension\Context\MinkAwareContext;
/**
* Class EntityReferenceContext.
*/
class EntityReferenceContext implements MinkAwareContext {
@kerasai
kerasai / FieldContext.php
Created August 25, 2017 17:48
Behat Context for checking field configuration in Drupal 8
<?php
use Behat\Behat\Context\Context;
/**
* Defines application features from the specific context.
*/
class FieldContext implements Context {
/**
@kerasai
kerasai / content_type_rename.sh
Created August 23, 2018 14:21
Renames Drupal content type configuration
# rename files & strip uuids
for f in *.yml; do mv "$f" "$(echo "$f" | sed s/node.experience/node.event/)"; done
for f in *.yml; do sed -i '' -e '/^uuid: /d' "$f"; done
# search/replace contents
for f in *.yml; do sed -i '' -e 's/node\.experience/node\.event/' "$f"; done
for f in *.yml; do sed -i '' -e 's/node\.type\.experience/node\.type\.event/' "$f"; done
for f in *.yml; do sed -i '' -e 's/bundle: experience/bundle: event/' "$f"; done