Skip to content

Instantly share code, notes, and snippets.

View msonnabaum's full-sized avatar

Mark Sonnabaum msonnabaum

  • Lithic
  • San Diego, CA
View GitHub Profile
<?php
namespace Drupal\block\Controller;
use Symfony\Component\HttpFoundation\Response;
class AddressableBlock {
public function respond($block_id, $route) {
$build = array();
$entity = block_load($block_id);
<?php
require './tests/bootstrap.php';
function lib_files() {
$module_roots = array();
foreach (scandir('./modules') as $module) {
if (!in_array($module, array('.', '..')) && is_dir("./modules/$module")) {
$module_roots[$module] = "./modules/$module/lib";
}
}
diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index fd3b719..e9afc2c 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -2289,6 +2289,8 @@ function _drupal_bootstrap_configuration() {
* Attempts to serve a page from the cache.
*/
function _drupal_bootstrap_page_cache() {
+ // Not sure what to do with all this yet, but the whole phase most likely
+ // needs to be removed.
<?php
class SelectorTest extends PHPUnit_Framework_TestCase {
protected function setUp() {
$this->xml = new DomDocument;
$this->xml->loadXML('<div id="wtf"><div class="blah"></div></div>');
}
public function testSelectors() {
$this->assertSelectCount('#wtf', 1, $this->xml);
require "mechanize"
# your email
email = ""
loop do
@agent = Mechanize.new
page = @agent.get "https://secure.hilton.com/en/hhonors/optout/unsubscribe.jhtml"
form = page.form_with id: "nwsltrWidget"
form['/atg/userprofiling/Profile.crm.emailOptOut.email'] = email
<?php
namespace Drupal\Tests\Core;
use Drupal\Tests\UnitTestCase;
class SomeClass {
function someMethod() {
$executable = \Drupal\views\Views::executableFactory();
$item = $executable->getItem('somedisplayid', 'sometype', 'someid');
# Kata Eight: Conflicting Objectives
# by Mark, Mark, and Lance
def words
@words ||= File.read('./wordsEn.txt').split("\r\n")
end
def six_letter_words(words)
words.reject do |word|
word.length != 6
<?php
require 'mink.phar';
class TestForChx extends PHPUnit_Framework_TestCase {
function testProveToChxWeAreNotCrazy() {
$clientOptions = array();
$client = new \Behat\Mink\Driver\Goutte\Client();
$client->setClient(new \Guzzle\Http\Client('', $clientOptions));
<?php
namespace Drupal\Core\Routing;
use Drupal\Core\Access\AccessCheckInterface;
use Drupal\Core\Entity\EntityInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Tests\UnitTestCase;
#!/bin/sh
convert_test() {
FILE=$1
sed -i '' -e's/simpletest\\UnitTestBase/Tests\\UnitTestCase/' "$FILE"
sed -i '' -e's/UnitTestBase/UnitTestCase/' "$FILE"
sed -i '' -e's/assertIdentical/assertSame/' "$FILE"
sed -i '' -e's/assertNotIdentical/assertNotSame/' "$FILE"
sed -i '' -e's/assertEqual(/assertEquals(/' "$FILE"
sed -i '' -e's/assertNotEqual(/assertNotEquals(/' "$FILE"