Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt Glaman mglaman

View GitHub Profile
@mglaman
mglaman / phpunit.xml
Last active Sep 11, 2020
My Drupal project phpunit.xml configuration
View phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
<!-- PHPUnit expects functional tests to be run with either a privileged user
or your current system user. See core/tests/README.md and
https://www.drupal.org/node/2116263 for details.
-->
<phpunit bootstrap="web/core/tests/bootstrap.php" colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
@mglaman
mglaman / commerce-modules-d7.json
Created May 22, 2020
Drupal Commerce Ecosystem
View commerce-modules-d7.json
[
{
"nid": "3125281",
"machine_name": "commerce_stripe_ideal",
"url": "https:\/\/www.drupal.org\/project\/commerce_stripe_ideal"
},
{
"nid": "3120253",
"machine_name": "commerce_ship_to_pssc",
"url": "https:\/\/www.drupal.org\/project\/commerce_ship_to_pssc"
@mglaman
mglaman / OrderEventsSubscriber.php
Created Aug 13, 2019
Destructable performance wins
View OrderEventsSubscriber.php
<?php
namespace Drupal\commerce_stripe\EventSubscriber;
use Drupal\commerce_order\Event\OrderEvent;
use Drupal\commerce_order\Event\OrderEvents;
use Drupal\commerce_price\Calculator;
use Drupal\commerce_price\Price;
use Drupal\commerce_stripe\Plugin\Commerce\PaymentGateway\StripeInterface;
use Drupal\Core\DestructableInterface;
@mglaman
mglaman / drush-loop.php
Created Jul 7, 2019
ReactPHP Drupal Tasks
View drush-loop.php
<?php declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
function run_command(string $command): void {
$loop = React\EventLoop\Factory::create();
$process = new React\ChildProcess\Process($command);
$process->start($loop);
$process->on('exit', function ($exitCode) use ($command) {
// Trigger alerts that the command finished.
View FeatureContext.php
<?php
/**
* @When I switch to the frame by selector "[title=:arg1]"
*/
public function switchToIFrameFromSelector($iframeSelector) {
$function = <<<JS
(function(){var iframe = document.querySelector("$iframeSelector");iframe.name = "iframeToSwitchTo";})()
JS;
try {
View FeatureContext.php
<?php
use Behat\Mink\Driver\GoutteDriver;
use Behat\Mink\Exception\ElementNotFoundException;
use Behat\Mink\Exception\ExpectationException;
use Drupal\DrupalExtension\Context\RawDrupalContext;
use Behat\Behat\Context\SnippetAcceptingContext;
/**
* Defines application features from the specific context.
View BigPipeContext.php
<?php
use Drupal\DrupalExtension\Context\RawDrupalContext;
use Behat\Mink\Exception\UnsupportedDriverActionException;
/**
* Big Pipe context.
*/
class BigPipeContext extends RawDrupalContext {
View gist:67af898f0f51ad9de1e1d3d3041200ff
{
"branch": "8.x-2.x",
"total": 222,
"contributors": {
"bojanz": 694,
"mglaman": 196,
"joshuataylorx": 69,
"vasike": 58,
"jelle.bekker": 40,
"agoradesign": 34,
View contributor-parser.php
<?php
$git_command = 'git --git-dir=./.git log 8.x-2.x --format="%ae||%s" -s --no-merges --reverse';
$contributors = [];
$commits = [];
$fallback_commits = [];
$regex = [
'issue' => '/by (\w+\,?.*?):/',
View gist:8faddd08c00f34a98bca94fda267ef55
Verifying my Blockstack ID is secured with the address 16iSpbgeCNSYQQB91HkiPvVtDxHDx1Ct9d https://explorer.blockstack.org/address/16iSpbgeCNSYQQB91HkiPvVtDxHDx1Ct9d
You can’t perform that action at this time.