Skip to content

Commit

Permalink
Upgrading behat to 2.4 and additional required changes
Browse files Browse the repository at this point in the history
remove initialization of mink and behat bundles
add project directory level behat.yml initial spec
remove behat mink configuration from symfony config files
remove old composer.lock and update vendors
add composer lock file for upgrade
fix travis call for behat script and make behat-ci script executable
move behat-ci.sh inside bin directory
fix behat-ci script
adapt Behat Contexts to running state
add mink selenium driver
enable minkcontext steps
ignore behat.yml and make dist version of configuration
embed behat deps on require-dev
shorten namespaces
remove nulls from declaration of kernel vars
remove useless if
remove sellenium, sahi
  • Loading branch information
cordoval committed Jun 27, 2012
1 parent c9191b1 commit 76b083c
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 85 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ composer.phar
bin/*
!bin/launch-rabit-consumers.sh
!bin/prepare-*.sh

!bin/behat-*.sh
build
behat.yml
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ before_script:
- ./bin/prepare-test-solr.sh
- ./bin/prepare-test-gd.sh

script: phpunit -c app/ && php app/console --env=test behat --format progress
script:
- phpunit -c app/
- ./bin/behat-ci.sh

branches:
except:
Expand Down
5 changes: 0 additions & 5 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ public function registerBundles()
new Knp\Bundle\SitemapBundle\KnpSitemapBundle(),
);

if ('test' === $this->getEnvironment()) {
$bundles[] = new Behat\BehatBundle\BehatBundle();
$bundles[] = new Behat\MinkBundle\MinkBundle();
}

if ($this->isDebug()) {
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
}
Expand Down
Empty file removed app/config/config_behat.yml
Empty file.
3 changes: 0 additions & 3 deletions app/config/config_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,3 @@ framework:
web_profiler:
toolbar: false
intercept_redirects: false

mink:
show_cmd: firefox %s
12 changes: 12 additions & 0 deletions behat.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
default:
formatter:
name: progress
extensions:
Behat\Symfony2Extension\Extension:
mink_driver: true
kernel:
env: test
debug: true
Behat\MinkExtension\Extension:
base_url: 'http://knpbundles.local/app_test.php/'
default_session: symfony2
42 changes: 42 additions & 0 deletions bin/behat-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# ./bin/behat-ci.sh

project_dir=$(dirname $(readlink -f $0))"/.."
logs_path=${1:-"./build/logs/behat"}
reports_path=${2:-"./build/behat"}

check_and_create_dir() {
path=$1
echo $path
if [[ -d "$path" ]]; then
# Directory already exists, do nothing
: echo "Directory already exists"
elif [[ -e "$path" ]]; then
echo "$path exists and is not a directory";
else
mkdir -p $path
fi
}

check_and_create_dir $reports_path
check_and_create_dir $logs_path

cd $project_dir

logs_path=${logs_path##$(pwd)/}
reports_path=${reports_path##$(pwd)/}

for feature_path in `find src/ -path '*/Features'`; do
var=`echo $feature_path`;
var2=${var%Bundle*};
bundle=`echo "${var2##*/}Bundle"`
reports_dir=$reports_path"/$bundle.html"

echo "Running suite for $bundle";

./bin/behat --format=progress,junit,html --out=,$logs_path,$reports_dir "@$bundle";
echo "<a href=\"$bundle.html\">$bundle</a><br />" >> $reports_path"/index.html"
done

cd -
18 changes: 7 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
"symfony/monolog-bundle": "*",
"sensio/distribution-bundle": "*",
"jms/i18n-routing-bundle": "*",

"behat/behat": "2.3.*",
"behat/behat-bundle": "*",
"behat/mink-bundle": "*",
"behat/common-contexts": "1.1.*",

"doctrine/doctrine-fixtures-bundle": "*",
"doctrine/doctrine-migrations-bundle": "*",
"stof/doctrine-extensions-bundle": "*",
Expand Down Expand Up @@ -47,12 +41,14 @@

"mbontemps/oauth-bundle": "*"
},

"require-dev": {
"behat/behat": "*",
"behat/symfony2-extension": "*",
"behat/mink-extension": "*",
"behat/mink-browserkit-driver": "*",
"behat/common-contexts": "*"
},
"repositories": [
{
"type": "composer",
"url": "behat.org"
},
{
"type": "package",
"package": {
Expand Down
108 changes: 56 additions & 52 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 35 additions & 10 deletions src/Knp/Bundle/KnpBundlesBundle/Features/Context/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

namespace Knp\Bundle\KnpBundlesBundle\Features\Context;

use Behat\BehatBundle\Context\BehatContext,
Behat\BehatBundle\Context\MinkContext;

use Behat\MinkBundle\Driver\SymfonyDriver;

use Behat\Behat\Context\ClosuredContextInterface,
Behat\Behat\Context\Step,
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Exception\PendingException;
use Behat\CommonContexts\SymfonyDoctrineContext;
use Behat\MinkExtension\Context\MinkContext;
use Behat\Symfony2Extension\Context\KernelAwareInterface;
use Behat\MinkExtension\Context\RawMinkContext;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;

Expand All @@ -21,6 +20,8 @@
Behat\Mink\Exception\ElementTextException,
Behat\Mink\Exception\UnsupportedDriverActionException;

use Symfony\Component\HttpKernel\KernelInterface;

use Etcpasswd\OAuthBundle\Security\Core\Authentication\Token\OAuthToken,
Etcpasswd\OAuthBundle\Provider\Token\GithubToken;

Expand All @@ -33,18 +34,22 @@
/**
* Feature context.
*/
class FeatureContext extends MinkContext
class FeatureContext extends RawMinkContext implements KernelAwareInterface
{
private $users;
private $bundles;
private $keywords;

/**
* @var \Symfony\Component\HttpKernel\KernelInterface $kernel
*/
private $kernel;

public function __construct($kernel)
{
$this->useContext('symfony_doctrine', new \Behat\CommonContexts\SymfonyDoctrineContext($kernel));
$this->useContext('solr', new \Knp\Bundle\KnpBundlesBundle\Features\Context\SolrContext($kernel));

parent::__construct($kernel);
$this->useContext('symfony_doctrine', new SymfonyDoctrineContext());
$this->useContext('solr', new SolrContext());
$this->useContext('mink', new MinkContext());
}

/**
Expand Down Expand Up @@ -353,4 +358,24 @@ protected function getRouter()
{
return $this->getContainer()->get('router');
}

/**
* gets container from kernel
*
* @return \Symfony\Component\DependencyInjection\ContainerInterface
*/
protected function getContainer()
{
return $this->kernel->getContainer();
}

/**
* Sets Kernel instance.
*
* @param KernelInterface $kernel HttpKernel instance
*/
public function setKernel(KernelInterface $kernel)
{
$this->kernel = $kernel;
}
}
Loading

0 comments on commit 76b083c

Please sign in to comment.