Permalink
Browse files

Configure Behat and its extensions and fix bundle name

rename BossaBundleTrainingBundle
rename BossaBundleTrainingExtension
$> vim app/AppKernel.php
$> vim app/autoload.php
$> vim behat.yml
$> bin/behat --init BossaTrainingBundle
$> bin/behat

First, we fix broken bundle name, because of generator.
Next, we're configuring our `behat.yml` and updating
app/autoload.php to support in-Behat initialization.
Then, we generate feature suite for our bundle.
  • Loading branch information...
1 parent 1be8db4 commit 7302287449b876ebf1d47d01ec43e66d6a9f0f75 @everzet committed Sep 14, 2012
View
2 app/AppKernel.php
@@ -19,7 +19,7 @@ public function registerBundles()
new JMS\AopBundle\JMSAopBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
- new Bossa\Bundle\TrainingBundle\BossaBundleTrainingBundle(),
+ new Bossa\Bundle\TrainingBundle\BossaTrainingBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
View
9 app/autoload.php
@@ -2,7 +2,12 @@
use Doctrine\Common\Annotations\AnnotationRegistry;
-$loader = require __DIR__.'/../vendor/autoload.php';
+if (!class_exists('Composer\\Autoload\\ClassLoader', false)) {
+ $loader = require __DIR__.'/../vendor/autoload.php';
+} else {
+ $loader = new Composer\Autoload\ClassLoader();
+ $loader->register();
+}
// intl
if (!function_exists('intl_get_error_code')) {
@@ -11,6 +16,6 @@
$loader->add('', __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs');
}
-AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
+AnnotationRegistry::registerLoader('class_exists');
return $loader;
View
6 behat.yml
@@ -0,0 +1,6 @@
+default:
+ extensions:
+ Behat\MinkExtension\Extension:
+ default_session: symfony2
+ Behat\Symfony2Extension\Extension:
+ bundle: @BossaTrainingBundle
View
2 ...iningBundle/BossaBundleTrainingBundle.php → ...le/TrainingBundle/BossaTrainingBundle.php
@@ -4,6 +4,6 @@
use Symfony\Component\HttpKernel\Bundle\Bundle;
-class BossaBundleTrainingBundle extends Bundle
+class BossaTrainingBundle extends Bundle
{
}
View
2 ...njection/BossaBundleTrainingExtension.php → ...dencyInjection/BossaTrainingExtension.php
@@ -12,7 +12,7 @@
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
-class BossaBundleTrainingExtension extends Extension
+class BossaTrainingExtension extends Extension
{
/**
* {@inheritDoc}
View
63 src/Bossa/Bundle/TrainingBundle/Features/Context/FeatureContext.php
@@ -0,0 +1,63 @@
+<?php
+
+namespace Bossa\Bundle\TrainingBundle\Features\Context;
+
+use Symfony\Component\HttpKernel\KernelInterface;
+use Behat\Symfony2Extension\Context\KernelAwareInterface;
+use Behat\MinkExtension\Context\MinkContext;
+
+use Behat\Behat\Context\BehatContext,
+ Behat\Behat\Exception\PendingException;
+use Behat\Gherkin\Node\PyStringNode,
+ Behat\Gherkin\Node\TableNode;
+
+//
+// Require 3rd-party libraries here:
+//
+// require_once 'PHPUnit/Autoload.php';
+// require_once 'PHPUnit/Framework/Assert/Functions.php';
+//
+
+/**
+ * Feature context.
+ */
+class FeatureContext extends BehatContext //MinkContext if you want to test web
+ implements KernelAwareInterface
+{
+ private $kernel;
+ private $parameters;
+
+ /**
+ * Initializes context with parameters from behat.yml.
+ *
+ * @param array $parameters
+ */
+ public function __construct(array $parameters)
+ {
+ $this->parameters = $parameters;
+ }
+
+ /**
+ * Sets HttpKernel instance.
+ * This method will be automatically called by Symfony2Extension ContextInitializer.
+ *
+ * @param KernelInterface $kernel
+ */
+ public function setKernel(KernelInterface $kernel)
+ {
+ $this->kernel = $kernel;
+ }
+
+//
+// Place your definition and hook methods here:
+//
+// /**
+// * @Given /^I have done something with "([^"]*)"$/
+// */
+// public function iHaveDoneSomethingWith($argument)
+// {
+// $container = $this->kernel->getContainer();
+// $container->get('some_service')->doSomethingWith($argument);
+// }
+//
+}

0 comments on commit 7302287

Please sign in to comment.