Skip to content

Instantly share code, notes, and snippets.

View dwickstrom's full-sized avatar
🐎

David Wickström dwickstrom

🐎
View GitHub Profile
@dwickstrom
dwickstrom / phpunit.xml
Last active September 18, 2015 07:54
phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
@dwickstrom
dwickstrom / AssertState.php
Created March 30, 2015 11:01
Assert state, hidden or else
/**
* @author David Wickström <davidwickstrom@gmail.com>
*/
trait AssertState
{
/**
* Access any value off any object given a property with any visibility mode
*
* @param $field
@dwickstrom
dwickstrom / composer.json
Last active August 29, 2015 14:18
Magento testing composer.json
{
"require-dev": {
"phpunit/phpunit": "~4.5",
"MageTest/Manager": "~1.0"
},
"repositories": [
{
"type": "vcs",
"url": "git@github.com:dwickstrom/Manager.git"
}
DB_USER=root
DB_HOST=localhost
DB_PASSWORD=topsecret
DB_NAME=foo_bar_test
FRONT_NAME=admin
SESSION_SAVE=db
MAGENTO_ROOT=vendor/magento/core
HOST_NAME=localhost:8787
<?php
class MageEnvironmentTrait
{
public function setEnvironment($env = null)
{
if (!$env) {
$env = Mage_Core_Model_App_Area::AREA_FRONTEND;
}
Mage::getSingleton('core/session', array('name' => $env));
<?php
use Mage;
trait HandleAttributes
{
/**
* @param Mage_Catalog_Model_Product $simple
* @param Mage_Catalog_Model_Product $configurable
* @param array $attributeIds
@dwickstrom
dwickstrom / settings.py
Created September 30, 2015 08:47
Include python-dotenv
from os.path import join, dirname
from dotenv import load_dotenv
dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)
@dwickstrom
dwickstrom / environment.py
Created September 30, 2015 09:22
environment.py
import threading
from wsgiref import simple_server
from selenium import webdriver
from my_application import model
from my_application import web_app
def before_all(context):
context.server = simple_server.WSGIServer(('', 8000))
context.server.set_app(web_app.main(environment='test'))
context.thread = threading.Thread(target=context.server.serve_forever)
@dwickstrom
dwickstrom / functions.php
Created October 13, 2015 14:28
WordPress getenv
<?php
/**
* Get option value, unless we are in debug mode && that key is set in the environment
*/
function get_environment_variable($varname) {
if (!is_string($varname)) throw new Exception('Strings only.');
if (getenv('WP_DEBUG')) {
return (getenv(strtoupper($varname))) ? : get_option($varname);
}
@dwickstrom
dwickstrom / nightmare.sh
Last active December 22, 2018 01:27
NightmareJS - install Electron on Ubuntu 14.04
apt-get -y update
apt-get -y upgrade
apt-get -y --force-yes install make unzip g++ libssl-dev git xvfb x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps clang libdbus-1-dev libgtk2.0-dev libnotify-dev libgnome-keyring-dev libgconf2-dev libasound2-dev libcap-dev libcups2-dev libxtst-dev libxss1 libnss3-dev gcc-multilib g++-multilib
npm -f init
npm i -S nightmare
xvfb-run nodejs index.js