Skip to content

Commit

Permalink
Stubbing Behat tests #266
Browse files Browse the repository at this point in the history
  • Loading branch information
dbellettini committed Mar 5, 2013
1 parent 46c6004 commit 0eb056c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace Universibo\Bundle\WebsiteBundle\Features\Context;

use Behat\Behat\Exception\PendingException;
use Behat\MinkExtension\Context\MinkContext;
use Behat\Symfony2Extension\Context\KernelAwareInterface;
use Symfony\Component\HttpKernel\KernelInterface;
use Universibo\Bundle\LegacyBundle\Entity\Canale;

/**
* Feature context.
Expand All @@ -14,6 +16,7 @@ class FeatureContext extends MinkContext
{
private $kernel;
private $parameters;
private $channelId;

/**
* Initializes context with parameters from behat.yml.
Expand Down Expand Up @@ -121,10 +124,62 @@ public function iClickOnButton($button)
}

/**
* @Then /^Text "([^"]*)" should be present$/
* @Then /^text "([^"]*)" should be present$/
*/
public function textShouldBePresent($text)
{
$this->assertPageContainsText($text);
}

/**
* @Given /^there is a channel with file service$/
*/
public function thereIsAChannelWithFileService()
{
$container = $this->kernel->getContainer();

$db = $container->get('doctrine.dbal.default_connection');

$query = $db
->createQueryBuilder()
->select('c.id_canale')
->from('canale', 'c')
->where('c.files_attivo = ?')
->setMaxResults(1)
->setParameter(1, 'S')
->execute()
;

$id = $query->fetchColumn();

if (false === $id) {
$channel = new Canale();
$channelRepo = $container->get('universibo_legacy.repository.canale');

$id = $channel->getIdCanale();
$channel->setServizioFiles(true);

$channelRepo->save($channel);
}

$this->channelId = $id;

throw new PendingException();
}

/**
* @When /^I visit that channel$/
*/
public function iVisitThatChannel()
{
throw new PendingException();
}

/**
* @Given /^I select a PHP file for upload$/
*/
public function iSelectAPhpFileForUpload()
{
throw new PendingException();
}
}
13 changes: 13 additions & 0 deletions src/Universibo/Bundle/WebsiteBundle/Features/file_add.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Feature: Publish a file
In order to make a file available to users
As user with rights on a channel
I want to add a file to it

Scenario: PHP file upload (forbidden action)
Given I'm logged in as "admin"
And there is a channel with file service
When I visit that channel
And I click on "Invia un nuovo file" link
And I select a PHP file for upload
And I click on "xxx" button
Then text "vietato" should be present
12 changes: 6 additions & 6 deletions src/Universibo/Bundle/WebsiteBundle/Features/login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Login
And I type "admin" on "username" field
And I type "padrino" on "password" field
And I click on "Login" button
Then Text "Benvenuto admin" should be present
Then text "Benvenuto admin" should be present
And Text "Il tuo livello di utenza è Admin" should be present

Scenario: Logging in as a Moderator
Expand All @@ -18,7 +18,7 @@ Feature: Login
And I type "moderator" on "username" field
And I type "padrino" on "password" field
And I click on "Login" button
Then Text "Benvenuto moderator" should be present
Then text "Benvenuto moderator" should be present
And Text "Il tuo livello di utenza è Collaboratore" should be present

Scenario: Logging in as a Student
Expand All @@ -27,7 +27,7 @@ Feature: Login
And I type "student" on "username" field
And I type "padrino" on "password" field
And I click on "Login" button
Then Text "Benvenuto student" should be present
Then text "Benvenuto student" should be present
And Text "Il tuo livello di utenza è Studente" should be present

Scenario: Logging in as a Professor
Expand All @@ -36,7 +36,7 @@ Feature: Login
And I type "professor" on "username" field
And I type "padrino" on "password" field
And I click on "Login" button
Then Text "Benvenuto professor" should be present
Then text "Benvenuto professor" should be present
And Text "Il tuo livello di utenza è Docente" should be present

Scenario: Logging in as a Tutor
Expand All @@ -45,7 +45,7 @@ Feature: Login
And I type "tutor" on "username" field
And I type "padrino" on "password" field
And I click on "Login" button
Then Text "Benvenuto tutor" should be present
Then text "Benvenuto tutor" should be present
And Text "Il tuo livello di utenza è Tutor" should be present

Scenario: Logging in as a non-teaching staff member
Expand All @@ -54,5 +54,5 @@ Feature: Login
And I type "staff" on "username" field
And I type "padrino" on "password" field
And I click on "Login" button
Then Text "Benvenuto staff" should be present
Then text "Benvenuto staff" should be present
And Text "Il tuo livello di utenza è Personale non docente" should be present
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Feature: ShowMyUniversiBO
Scenario: Plain test
Given I'm logged in as "student"
When I visit "/my/universibo"
Then Text "My News" should be present
And Text "My Files" should be present
Then text "My News" should be present
And text "My Files" should be present

0 comments on commit 0eb056c

Please sign in to comment.