Skip to content

Instantly share code, notes, and snippets.

@everzet
everzet / FeatureContext.php
Created January 26, 2012 16:28
Describing your Symfony2 console commands with BehatBundle
<?php
namespace Acme\DemoBundle\Features\Context;
use Behat\BehatBundle\Context\BehatContext,
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
@everzet
everzet / FeatureContext.php
Created August 13, 2011 15:00
How to use MinkContext inside BehatBundle as subcontext
<?php
namespace Acme\DemoBundle\Features\Context;
use Behat\BehatBundle\Context\BehatContext,
Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
/**
@everzet
everzet / console
Created December 5, 2012 13:33
Why, php? WHY???
PHP Fatal error: Uncaught exception 'LogicException' with message 'The parent constructor was not called: the object is in an invalid state ' in splfileobject.php:16
Stack trace:
splfileobject.php(16): SplFileInfo->_bad_state_ex()
#1 {main}
thrown in splfileobject.php on line 16
Fatal error: Uncaught exception 'LogicException' with message 'The parent constructor was not called: the object is in an invalid state ' in splfileobject.php:16
Stack trace:
#0 splfileobject.php(16): SplFileInfo->_bad_state_ex()
#1 {main}
@everzet
everzet / behat.yml
Created March 31, 2014 09:22
Registering custom context initializers with behat 3
default:
extensions:
custom_extension.php: ~
@everzet
everzet / RethrowExceptionListener.php
Last active February 27, 2017 12:18
Rethrow non-HTTP exceptions in the test environment (aka functional tester saver)
<?php
namespace App\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
class ExceptionRethrowListener
{
public function onKernelException(GetResponseForExceptionEvent $event)
@everzet
everzet / rspec_in.php
Created May 19, 2011 21:13
Why RSpec is not possible in PHP
<?php
/*
Why i think, that "RSpec is not possible in PHP"?
Cuz Ruby's syntax abilities can represent
natural language constructions:
object should equals 2
@everzet
everzet / gist:5722238
Last active December 18, 2015 03:59 — forked from gquemener/gist:5722064
<?php
//PHPUnit
public function testApply() {
$mock = $this->getMock('My\Foo\Class', array('apply'));
$mock->expects($this->any())
->method('apply')
->with('foo')
->will($this->returnValue('bar'));
@everzet
everzet / sauce_connect_setup.sh
Last active December 18, 2015 00:39
Non-verbose SauceLabs connect setup for Travis
#!/bin/bash
# Setup and start Sauce Connect for your TravisCI build
# This script requires your .travis.yml to include the following two private env variables:
# SAUCE_USERNAME
# SAUCE_ACCESS_KEY
# Follow the steps at https://saucelabs.com/opensource/travis to set that up.
#
# Curl and run this script as part of your .travis.yml before_script section:
# before_script:
@everzet
everzet / phpspec_a3.php
Created November 1, 2012 14:19
Per-specification custom matchers support in phpspec2 alpha3
<?php
namespace spec\Bank\Controller;
use PHPSpec2\ObjectBehavior;
use PHPSpec2\Matcher\CustomMatchersProviderInterface;
use PHPSpec2\Matcher\InlineMatcher;
class PaymentController extends ObjectBehavior implements CustomMatchersProviderInterface
{
@everzet
everzet / BasicRepresenter.php
Created September 22, 2012 15:15
How BasicRepresenter object specification looks inside PHPSpec2
<?php
namespace spec\PHPSpec2\Formatter\Representer;
use PHPSpec2\ObjectBehavior;
use PHPSpec2\MethodBehavior;
class BasicRepresenter extends ObjectBehavior
{
function it_should_represent_any_value()