secret
Created

  • Download Gist
Featurecontext.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
<?php
 
use \Behat\MinkExtension\Context\MinkContext,
\Behat\Behat\Exception\PendingException,
\Behat\Behat\Event\SuiteEvent;
 
use \Symfony\Component\Process\Process;
 
 
/**
* Features context.
*/
class FeatureContext extends MinkContext
{
/**
* Connects the user
*
* @Given /^I am connected with "(?P<user>(?:[^"]|\\")*)" and "(?P<pass>(?:[^"]|\\")*)"$/
*
* @param string $user username to log in
* @param string $pass username's password
*/
public function iAmConnectedWithAnd($user, $pass)
{
$this->fillField('username', $user);
$this->fillField('password', $pass);
$this->pressButton('Login');
}
 
/**
* Connects the user on an url
*
* @Given /^I am connected with "(?P<user>(?:[^"]|\\")*)" and "(?P<pass>(?:[^"]|\\")*)" on "(?P<url>.+)"/
*
* @param string $user username to log in
* @param string $pass username's password
* @param string $url url to visit
*/
public function iAmConnectedWithAndOn($user, $pass, $url)
{
$this->visit($url);
$this->iAmConnectedWithAnd($user, $pass);
$this->visit($url);
}
 
/**
* Connects the user on the homepage
*
* @Given /^I am connected with "(?P<user>(?:[^"]|\\")*)" and "(?P<pass>(?:[^"]|\\")*)" on homepage$/
*
* @param string $user username to log in
* @param string $pass username's password
*/
public function iAmConnectedWithAndOnHomepage($user, $pass)
{
$this->iAmConnectedWithAndOn($user, $pass, '/');
}
}
access.features
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Feature: Handles the logging in and logging out of the user.
 
Scenario: Log an user in
Given I am on homepage
When I fill in "username" with "user@wisembly.com"
And I fill in "password" with "pass"
And I press "Login"
And I reload the page
Then I should see "Root"
 
Scenario: Log an user out
Given I am connected with "user@wisembly.com" and "pass" on homepage
When I follow "user_logout"
And I reload the page
Then I follow "user_signup"
app_dev.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
<?php
 
use Symfony\Component\HttpFoundation\Request;
 
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);
 
// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !in_array(@$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'::1',
))
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
 
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
 
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
app_test.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
<?php
 
use Symfony\Component\HttpFoundation\Request;
 
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);
 
// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !in_array(@$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'::1',
))
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
 
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
 
$kernel = new AppKernel('test', false);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
behat.yml
YAML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
default:
context:
class : 'features\bootstrap\Context\FeatureContext'
parameters:
reset_database : false
environment : prod
extensions:
Behat\MinkExtension\Extension:
base_url : 'http://localhost/'
goutte : ~
zombie : ~
 
test:
context:
parameters:
reset_database : true
environment : test
extensions:
Behat\MinkExtension\Extension:
base_url : 'http://localhost/app_test.php'
 
dev:
context:
parameters:
reset_database : true
environment : dev
extensions:
Behat\MinkExtension\Extension:
base_url : 'http://localhost/app_dev.php'
config_test.yml
YAML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
imports:
- { resource: config_dev.yml }
 
security:
acl:
connection: test
 
framework:
test: ~
session:
storage_id: session.storage.filesystem
 
doctrine:
dbal:
default_connection: test
connections:
default:
dbname: %database_test%
orm:
default_entity_manager: default
 
web_profiler:
toolbar: false
intercept_redirects: false
 
swiftmailer:
disable_delivery: true

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.