Skip to content

Instantly share code, notes, and snippets.

View wouterj's full-sized avatar

Wouter de Jong wouterj

View GitHub Profile
<?php
describe('StringCalculator', function () {
it('requires string output', function () {
$this->shouldThrow('\InvalidArgumentException')->during('add', [null]);
});
it('adds 2 numbers separated by comma', function () {
$this->add('1,2')->shouldReturn(3);
and(A, A, A).
and(A, B, 0) :- A \= B.
or(1, 0, 1).
or(0, 1, 1).
or(1, 1, 1).
or(0, 0, 0).
xor(1, 0, 1).
xor(0, 1, 1).
<?hh
/*-------------------------*\
PROGRAMMING
WITH
NOTHING
\*-------------------------*/
/*
* A heavily based on http://codon.com/programming-with-nothing
*/
default:
suites:
portal:
contexts: [Behat\MinkExtension\Context\MinkContext, PortalContext]
path: %paths.base%/features
extensions:
Behat\MinkExtension:
base_url: http://st3hoekcp-acc.wonenportaal.nl/
sessions:
default:
{
"require": {
"behat/mink-goutte-driver": "~1.0"
}
}
<?xml version="1.0" ?>
<xliff version='1.1' xmlns='urn:oasis:names:tc:xliff:document:1.1'>
<file original='NoName' source-language='en' datatype='plaintext'>
<body>
<!-- In Symfony -->
<trans-unit id="apples">
<source>I have %number% apples</source>
<target>{0} I have no apples|{1} I have one apple|]1,Inf] I have %count% apples</target>
</trans-unit>
<?php
// ...
class SiteController extends Controller
{
public function searchAction(Request $request)
{
$query = $request->query->get('query');
import Data.List (groupBy, sortBy)
getQuantity xs = let countQuantity acc (_, "registered") = succ acc
countQuantity acc (_, "sold") = pred acc
compareASC (i1, _) (i2, _)
| i1 < i2 = LT
| i1 > i2 = GT
| i1 == i2 = EQ
in map (foldl (countQuantity) 0) $ groupBy (\x y -> (fst x) == (fst y)) $ sortBy (compareASC) xs
<?php
// BEFORE
// ...
class FeatureContext
{
public function assertFieldHasErrorMessage($message, $locator)
{
// find fieldset by locator for field
<?php
$response = new \Response();
try {
$client->buy('sofa');
} catch (\Exception $e) {
foreach ($this->exceptionHandlers as $handler) {
if ($handler->accepts($e)) {
$response = $handler->handle($e, $response);