Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use behat CommonContexts and exclude behat from phpunit

  • Loading branch information...
commit d249b361f3c7eb1a61107a59c8b0d35c0085a6e7 1 parent b298fef
@tvlooy tvlooy authored
Showing with 167 additions and 137 deletions.
  1. +15 −14 app/autoload.php
  2. +1 −0  app/phpunit.xml.dist
  3. +1 −1  build.xml
  4. +4 −0 deps
  5. +107 −2 src/Ctors/ReadingCornerBundle/Features/Context/FeatureContext.php
  6. +0 −120 src/Ctors/ReadingCornerBundle/Features/Context/ReadingCornerContext.php
  7. +3 −0  src/Ctors/ReadingCornerBundle/Tests/Feature/Calendar/ListScenariosTest.php
  8. +3 −0  src/Ctors/ReadingCornerBundle/Tests/Feature/Calendar/StatusScenariosTest.php
  9. +3 −0  src/Ctors/ReadingCornerBundle/Tests/Feature/Catalog/SearchScenariosTest.php
  10. +3 −0  src/Ctors/ReadingCornerBundle/Tests/Feature/Student/EditScenariosTest.php
  11. +3 −0  src/Ctors/ReadingCornerBundle/Tests/Feature/Student/NewScenariosTest.php
  12. +3 −0  src/Ctors/ReadingCornerBundle/Tests/Feature/Student/RemoveScenariosTest.php
  13. +3 −0  src/Ctors/ReadingCornerBundle/Tests/Feature/Student/SearchScenariosTest.php
  14. +3 −0  src/Ctors/ReadingCornerBundle/Tests/Feature/User/EditScenariosTest.php
  15. +3 −0  src/Ctors/ReadingCornerBundle/Tests/Feature/User/LoginScenariosTest.php
  16. +3 −0  src/Ctors/ReadingCornerBundle/Tests/Feature/User/NewScenariosTest.php
  17. +3 −0  src/Ctors/ReadingCornerBundle/Tests/Feature/User/PasswordScenariosTest.php
  18. +3 −0  src/Ctors/ReadingCornerBundle/Tests/Feature/User/RemoveScenariosTest.php
  19. +3 −0  src/Ctors/ReadingCornerBundle/Tests/Feature/User/SearchScenariosTest.php
View
29 app/autoload.php
@@ -5,21 +5,22 @@
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
- 'Symfony' => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
- 'Sensio' => __DIR__.'/../vendor/bundles',
- 'JMS' => __DIR__.'/../vendor/bundles',
+ 'Symfony' => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
+ 'Sensio' => __DIR__.'/../vendor/bundles',
+ 'JMS' => __DIR__.'/../vendor/bundles',
'Doctrine\\Common\\DataFixtures' => __DIR__.'/../vendor/doctrine-fixtures/lib',
- 'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
- 'Doctrine\\DBAL' => __DIR__.'/../vendor/doctrine-dbal/lib',
- 'Doctrine' => __DIR__.'/../vendor/doctrine/lib',
- 'Monolog' => __DIR__.'/../vendor/monolog/src',
- 'Assetic' => __DIR__.'/../vendor/assetic/src',
- 'Metadata' => __DIR__.'/../vendor/metadata/src',
- 'Behat\Gherkin' => __DIR__.'/../vendor/behat/gherkin/src',
- 'Behat\Behat' => __DIR__.'/../vendor/behat/behat/src',
- 'Behat\BehatBundle'=> __DIR__.'/../vendor/bundles',
- 'Behat\Mink' => __DIR__.'/../vendor/behat/mink/src',
- 'Behat\MinkBundle' => __DIR__.'/../vendor/bundles',
+ 'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
+ 'Doctrine\\DBAL' => __DIR__.'/../vendor/doctrine-dbal/lib',
+ 'Doctrine' => __DIR__.'/../vendor/doctrine/lib',
+ 'Monolog' => __DIR__.'/../vendor/monolog/src',
+ 'Assetic' => __DIR__.'/../vendor/assetic/src',
+ 'Metadata' => __DIR__.'/../vendor/metadata/src',
+ 'Behat\Gherkin' => __DIR__.'/../vendor/behat/gherkin/src',
+ 'Behat\Behat' => __DIR__.'/../vendor/behat/behat/src',
+ 'Behat\BehatBundle' => __DIR__.'/../vendor/bundles',
+ 'Behat\Mink' => __DIR__.'/../vendor/behat/mink/src',
+ 'Behat\MinkBundle' => __DIR__.'/../vendor/bundles',
+ 'Behat\CommonContexts' => __DIR__.'/../vendor/behat/CommonContexts',
));
$loader->registerPrefixes(array(
'Twig_Extensions_' => __DIR__.'/../vendor/twig-extensions/lib',
View
1  app/phpunit.xml.dist
@@ -31,6 +31,7 @@
<directory>../src</directory>
<exclude>
<directory>../src/*/*Bundle/Resources</directory>
+ <directory>../src/*/*Bundle/Features</directory>
<directory>../src/*/*Bundle/Tests</directory>
<directory>../src/*/Bundle/*Bundle/Resources</directory>
<directory>../src/*/Bundle/*Bundle/Tests</directory>
View
2  build.xml
@@ -7,7 +7,7 @@
<exec command="mysql -u root -p -e 'create database readingCorner_test default character set utf8 COLLATE utf8_general_ci'" passthru="true" />
<exec command="php app/console -e=test doctrine:schema:update --force" passthru="true" />
<exec command="php app/console -e=test doctrine:fixtures:load" passthru="true" />
- <exec command="phpunit -c app --coverage-html testReports" passthru="true" />
+ <exec command="phpunit -c app --exclude-group behat --coverage-html testReports" passthru="true" />
<exec command="firefox testReports/index.html" />
</target>
View
4 deps
@@ -82,6 +82,10 @@
git=https://github.com/Behat/MinkBundle.git
target=/bundles/Behat/MinkBundle
+[BehatCommonContexts]
+ git=https://github.com/Behat/CommonContexts.git
+ target=/behat/CommonContexts
+
[doctrine-fixtures]
git=http://github.com/doctrine/data-fixtures.git
View
109 src/Ctors/ReadingCornerBundle/Features/Context/FeatureContext.php
@@ -9,14 +9,119 @@
Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
+use Behat\CommonContexts\SymfonyDoctrineContext;
+use Symfony\Component\HttpKernel\HttpKernelInterface;
+use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken,
+ Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
+use Behat\Behat\Context\Step;
/**
* Feature context.
*/
-class FeatureContext extends BehatContext
+class FeatureContext extends MinkContext
{
public function __construct($kernel)
{
- $this->useContext('readingcorner', new ReadingCornerContext($kernel));
+ $this->useContext('doctrine', new SymfonyDoctrineContext($kernel));
+ parent::__construct($kernel);
+ }
+
+ /**
+ * @Given /^ik ben ingelogd als "([^"]*)"$/
+ */
+ public function ikBenIngelogdAls($role)
+ {
+ switch ($role) {
+ case 'beheerder':
+ $user = 'tvl';
+ $pass = 'g3h$im';
+ $page = '/';
+ break;
+ case 'leerkracht':
+ $user = 'lue';
+ $pass = 'g3h$im';
+ $page = '/';
+ break;
+ case 'uitgeschakeld':
+ $user = 'tst';
+ $pass = 'g3h$im';
+ $page = '/login';
+ break;
+ default:
+ $user = '';
+ $pass = '';
+ $page = '/login';
+ }
+
+ return array(
+ new Step\Given('I am on "/login"'),
+ new Step\When('I fill in "username" with "' . $user . '"'),
+ new Step\When('I fill in "password" with "' . $pass . '"'),
+ new Step\When('I press "Inloggen"'),
+ new Step\Then('I should be on "' . $page . '"'),
+ );
+ }
+
+ /**
+ * @Given /^moet ik op "([^"]*)" belanden$/
+ */
+ public function moetIkOpBelanden($page)
+ {
+ return array(
+ new Step\Given('I am on "' . $page . '"'),
+ );
+ }
+
+ /**
+ * @Given /^er een gebruiker "([^"]*)" is met naam "([^"]*)"$/
+ */
+ public function erEenGebruikerIsMetNaam($id, $username)
+ {
+ $this->getContainer()->get('doctrine')->getEntityManager()->getConnection()->executeUpdate(
+ "insert into User values ($id, '$username', 'xyz', 'NaCl', 'secret', 3)"
+ );
+ }
+
+ /**
+ * @Given /^er een student "([^"]*)" is met naam "([^"]*)"$/
+ */
+ public function erEenStudentIsMetNaam($id, $firstname)
+ {
+ $this->getContainer()->get('doctrine')->getEntityManager()->getConnection()->executeUpdate(
+ "insert into Student values ($id, '1111', '$firstname', 'Tester', '1111Tester', '9Q1', 0, 0)"
+ );
+ }
+
+ /**
+ * @Given /^de datum is "([^"]*)"$/
+ */
+ public function deDatumIs($date)
+ {
+ $this->getContainer()->get('today')->setDate($date);
+ }
+
+ /**
+ * @Given /^ik post naar "([^"]*)"$/
+ */
+ public function ikPostNaar($target)
+ {
+ $client = $this->getSession()->getDriver()->getClient();
+ $client->request('POST', $target);
+ }
+
+ /**
+ * @Given /^heeft element "([^"]*)" klasse "([^"]*)"$/
+ */
+ public function heeftElementKlasse($id, $class)
+ {
+ $page = $this->getSession()->getPage();
+ $element = $page->findById($id);
+ if ($element->getAttribute('class') != $class) {
+ throw new \Exception(
+ 'Element "' . $id . '" ' .
+ 'heeft klasse "' . $element->getAttribute('class') .
+ '" in plaats van "' . $class . '"'
+ );
+ }
}
}
View
120 src/Ctors/ReadingCornerBundle/Features/Context/ReadingCornerContext.php
@@ -1,120 +0,0 @@
-<?php
-
-namespace Ctors\ReadingCornerBundle\Features\Context;
-
-use Behat\BehatBundle\Context\BehatContext,
- Behat\BehatBundle\Context\MinkContext;
-use Behat\Behat\Context\ClosuredContextInterface,
- Behat\Behat\Context\TranslatedContextInterface,
- Behat\Behat\Exception\PendingException;
-use Behat\Gherkin\Node\PyStringNode,
- Behat\Gherkin\Node\TableNode;
-use Symfony\Component\HttpKernel\HttpKernelInterface;
-use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken,
- Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
-use Behat\Behat\Context\Step;
-
-/**
- * User login context.
- */
-class ReadingCornerContext extends MinkContext
-{
- /**
- * @Given /^ik ben ingelogd als "([^"]*)"$/
- */
- public function ikBenIngelogdAls($role)
- {
- switch ($role) {
- case 'beheerder':
- $user = 'tvl';
- $pass = 'g3h$im';
- $page = '/';
- break;
- case 'leerkracht':
- $user = 'lue';
- $pass = 'g3h$im';
- $page = '/';
- break;
- case 'uitgeschakeld':
- $user = 'tst';
- $pass = 'g3h$im';
- $page = '/login';
- break;
- default:
- $user = '';
- $pass = '';
- $page = '/login';
- }
-
- return array(
- new Step\Given('I am on "/login"'),
- new Step\When('I fill in "username" with "' . $user . '"'),
- new Step\When('I fill in "password" with "' . $pass . '"'),
- new Step\When('I press "Inloggen"'),
- new Step\Then('I should be on "' . $page . '"'),
- );
- }
-
- /**
- * @Given /^moet ik op "([^"]*)" belanden$/
- */
- public function moetIkOpBelanden($page)
- {
- return array(
- new Step\Given('I am on "' . $page . '"'),
- );
- }
-
- /**
- * @Given /^er een gebruiker "([^"]*)" is met naam "([^"]*)"$/
- */
- public function erEenGebruikerIsMetNaam($id, $username)
- {
- $this->getContainer()->get('doctrine')->getEntityManager()->getConnection()->executeUpdate(
- "insert into User values ($id, '$username', 'xyz', 'NaCl', 'secret', 3)"
- );
- }
-
- /**
- * @Given /^er een student "([^"]*)" is met naam "([^"]*)"$/
- */
- public function erEenStudentIsMetNaam($id, $firstname)
- {
- $this->getContainer()->get('doctrine')->getEntityManager()->getConnection()->executeUpdate(
- "insert into Student values ($id, '1111', '$firstname', 'Tester', '1111Tester', '9Q1', 0, 0)"
- );
- }
-
- /**
- * @Given /^de datum is "([^"]*)"$/
- */
- public function deDatumIs($date)
- {
- $this->getContainer()->get('today')->setDate($date);
- }
-
- /**
- * @Given /^ik post naar "([^"]*)"$/
- */
- public function ikPostNaar($target)
- {
- $client = $this->getSession()->getDriver()->getClient();
- $client->request('POST', $target);
- }
-
- /**
- * @Given /^heeft element "([^"]*)" klasse "([^"]*)"$/
- */
- public function heeftElementKlasse($id, $class)
- {
- $page = $this->getSession()->getPage();
- $element = $page->findById($id);
- if ($element->getAttribute('class') != $class) {
- throw new \Exception(
- 'Element "' . $id . '" ' .
- 'heeft klasse "' . $element->getAttribute('class') .
- '" in plaats van "' . $class . '"'
- );
- }
- }
-}
View
3  src/Ctors/ReadingCornerBundle/Tests/Feature/Calendar/ListScenariosTest.php
@@ -6,6 +6,9 @@
class ListScenariosTest extends BehatFeature
{
+ /**
+ * @group behat
+ */
public function testScenarios()
{
parent::runScenarios('Calendar/list.feature');
View
3  src/Ctors/ReadingCornerBundle/Tests/Feature/Calendar/StatusScenariosTest.php
@@ -6,6 +6,9 @@
class StatusScenariosTest extends BehatFeature
{
+ /**
+ * @group behat
+ */
public function testScenarios()
{
parent::runScenarios('Calendar/status.feature');
View
3  src/Ctors/ReadingCornerBundle/Tests/Feature/Catalog/SearchScenariosTest.php
@@ -6,6 +6,9 @@
class SearchScenariosTest extends BehatFeature
{
+ /**
+ * @group behat
+ */
public function testScenarios()
{
parent::runScenarios('Catalog/search.feature');
View
3  src/Ctors/ReadingCornerBundle/Tests/Feature/Student/EditScenariosTest.php
@@ -6,6 +6,9 @@
class EditScenariosTest extends BehatFeature
{
+ /**
+ * @group behat
+ */
public function testScenarios()
{
parent::runScenarios('Student/edit.feature');
View
3  src/Ctors/ReadingCornerBundle/Tests/Feature/Student/NewScenariosTest.php
@@ -6,6 +6,9 @@
class NewScenariosTest extends BehatFeature
{
+ /**
+ * @group behat
+ */
public function testScenarios()
{
parent::runScenarios('Student/new.feature');
View
3  src/Ctors/ReadingCornerBundle/Tests/Feature/Student/RemoveScenariosTest.php
@@ -6,6 +6,9 @@
class RemoveScenariosTest extends BehatFeature
{
+ /**
+ * @group behat
+ */
public function testScenarios()
{
parent::runScenarios('Student/remove.feature');
View
3  src/Ctors/ReadingCornerBundle/Tests/Feature/Student/SearchScenariosTest.php
@@ -6,6 +6,9 @@
class SearchScenariosTest extends BehatFeature
{
+ /**
+ * @group behat
+ */
public function testScenarios()
{
parent::runScenarios('Student/search.feature');
View
3  src/Ctors/ReadingCornerBundle/Tests/Feature/User/EditScenariosTest.php
@@ -6,6 +6,9 @@
class EditScenariosTest extends BehatFeature
{
+ /**
+ * @group behat
+ */
public function testScenarios()
{
parent::runScenarios('User/edit.feature');
View
3  src/Ctors/ReadingCornerBundle/Tests/Feature/User/LoginScenariosTest.php
@@ -6,6 +6,9 @@
class LoginScenariosTest extends BehatFeature
{
+ /**
+ * @group behat
+ */
public function testScenarios()
{
parent::runScenarios('User/login.feature');
View
3  src/Ctors/ReadingCornerBundle/Tests/Feature/User/NewScenariosTest.php
@@ -6,6 +6,9 @@
class NewScenariosTest extends BehatFeature
{
+ /**
+ * @group behat
+ */
public function testScenarios()
{
parent::runScenarios('User/new.feature');
View
3  src/Ctors/ReadingCornerBundle/Tests/Feature/User/PasswordScenariosTest.php
@@ -6,6 +6,9 @@
class PasswordScenariosTest extends BehatFeature
{
+ /**
+ * @group behat
+ */
public function testScenarios()
{
parent::runScenarios('User/password.feature');
View
3  src/Ctors/ReadingCornerBundle/Tests/Feature/User/RemoveScenariosTest.php
@@ -6,6 +6,9 @@
class RemoveScenariosTest extends BehatFeature
{
+ /**
+ * @group behat
+ */
public function testScenarios()
{
parent::runScenarios('User/remove.feature');
View
3  src/Ctors/ReadingCornerBundle/Tests/Feature/User/SearchScenariosTest.php
@@ -6,6 +6,9 @@
class SearchScenariosTest extends BehatFeature
{
+ /**
+ * @group behat
+ */
public function testScenarios()
{
parent::runScenarios('User/search.feature');
Please sign in to comment.
Something went wrong with that request. Please try again.