Skip to content

Instantly share code, notes, and snippets.

@everzet
everzet / bdd_in_phpunit__vs__phpspec.php
Created May 19, 2011 20:58
comparison of BDD-style PHPUnit VS PHPSpec1 (has almost nothing to do with phpspec2)
<?php
// how that:
class DescribeContextZend extends PHPSpec_Context
{
public function itShouldSetControllerNameUsingContextClass()
{
$context = new DescribeFooController;
$this->spec($context->getController())->should->be('Foo');
@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 / bad_steps_proposition.php
Created June 7, 2011 19:12 — forked from alexandresalome/gist:1012539
Explaining why classes are not possible in Behat as step definitions
<?php
/*
You can't use classes like this to define steps by the simple reason:
in Behat and Cucumber, step definitions and test contexts ARE two
splitted logical elements, not one. Different step definitions
can be used together in different scenarios and each scenario will
have it's own context (environment) object. That's the main logical
idea behind Behat - define step once - use it everywhere.
@everzet
everzet / AppKernel.php
Created June 27, 2011 12:07
How to configure BehatBundle and MinkBundle to run goutte sessions efficiently
<?php
public function registerBundles()
{
// ...
if ('test' === $this->getEnvironment()) {
$bundles[] = new Behat\MinkBundle\BehatMinkBundle();
$bundles[] = new Behat\BehatBundle\BehatBundle();
}
// ...
@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 / php.rb
Created August 23, 2011 20:30
brew formula for php 5.3.8
require 'formula'
def mysql_installed?
`which mysql_config`.length > 0
end
class Php < Formula
url 'http://www.php.net/get/php-5.3.8.tar.gz/from/this/mirror'
homepage 'http://php.net/'
md5 'f4ce40d5d156ca66a996dbb8a0e7666a'
@everzet
everzet / GeekyMinkContext.php
Created October 3, 2011 11:48
Geeky context for Behat + Mink
<?php
use Behat\Mink\Behat\Context\MinkContext;
/**
* Provides basic steps to test your web app from the geek perspective.
*/
class GeekyMinkContext extends MinkContext
{
/**
@everzet
everzet / resource_watcher_usage.php
Created November 29, 2011 22:40
Symfony2.1 ResourceWatcher usage example
<?php
$watcher = new Symfony\Component\ResourceWatcher\ResourceWatcher;
// track any change inside directory:
$watcher->track('some/folder1', function($event) {
echo '['.$event->getType().'] '.$event->getResource()."\n"
});
@everzet
everzet / composer.json
Created December 14, 2011 14:09
Composer package to install Behat
{
"require": {
"behat/behat": ">=2.2.0"
}
}
@everzet
everzet / download_and_fix_selenium.sh
Created December 20, 2011 10:58
Get selenium 2.15 with latest Firefox fix
#!/bin/sh
wget http://selenium.googlecode.com/files/selenium-server-standalone-2.15.0.jar
jar xf selenium-server-standalone-2.15.0.jar core/scripts/atoms.js
ed -- "core/scripts/atoms.js" <<-PATCH
9423s|a.|XPCNativeWrapper(a).|
w
q
PATCH