Giter VIP home page Giter VIP logo

commoncontexts's Introduction

Behat

Behat is a BDD framework for PHP to help you test business expectations.

Gitter chat License Build Status

Installing Behat

The easiest way to install Behat is by using Composer:

$> composer require --dev behat/behat

After that you'll be able to run Behat via:

$> vendor/bin/behat

Installing Development Version

Clone the repository and install dependencies via Composer:

$> composer install

After that you will be able to run development version of Behat via:

$> bin/behat

Contributing

Before contributing to Behat, please take a look at the CONTRIBUTING.md document.

Versioning

Starting from v3.0.0, Behat is following Semantic Versioning v2.0.0. This basically means that if all you do is implement interfaces (like this one) and use service constants (like this one), you would not have any backwards compatibility issues with Behat up until v4.0.0 (or later major) is released. Exception could be an extremely rare case where BC break is introduced as a measure to fix a serious issue.

You can read detailed guidance on what BC means in Symfony BC guide.

Useful Links

Contributors

commoncontexts's People

Contributors

aderuwe avatar bartoszrychlicki avatar docteurklein avatar everzet avatar fightmaster avatar fre5h avatar herzult avatar jakzal avatar jamescauwelier avatar kbond avatar localheinz avatar marijn avatar nenadalm avatar patromo avatar schmittjoh avatar sizuhiko avatar stfalcon avatar stof avatar ubermuda avatar umpirsky avatar veloce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

commoncontexts's Issues

It seems there is problem with token

should't be in SymfonyMailerContext something like:
$token = end($token) ?
(that's happen if $token is null in parameter)

substr() expects parameter 1 to be string, array given in /srv/www/nextlove/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php on line 185

[SymfonyDoctrineContext] Improve performance for sqlite

Anyone who used behat and sqlite can notice that

   $tool->dropSchema($metadata);
   $tool->createSchema($metadata);

are very slow when it's run on sqlite
guys from Liip fixed this by copying filled db file ond restoring from backup
inspired by https://github.com/liip/LiipFunctionalTestBundle/blob/master/Test/WebTestCase.php

this is a rough (although working) example how it could be done



use Behat\CommonContexts;
/**
 * Created by JetBrains PhpStorm.
 * User: wodor
 * Date: 12.03.12
 * Time: 15:30
 */
class FastSqliteDoctrineContext extends  \Behat\CommonContexts\SymfonyDoctrineContext
{

    /**
     * @param \Behat\Behat\Event\ScenarioEvent|\Behat\Behat\Event\OutlineExampleEvent $event
     *
     * @BeforeScenario
     *
     * @return null
     */
    public function buildSchema($event)
    {
        $metadata = $this->getMetadata();
        $container = $this->getContainer();

        $connection = current($this->getConnections());
        if ($connection->getDriver() instanceOf \Doctrine\DBAL\Driver\PDOSqlite\Driver) {
            $params = $connection->getParams();
            $name = isset($params['path']) ? $params['path'] : $params['dbname'];
            $metadatas = $this->getEntityManager()->getMetadataFactory()->getAllMetadata();

            $backup = $container->getParameter('kernel.cache_dir') . '/test_' . md5(serialize($metadatas)) . '.db';
            if (file_exists($backup)) {
                copy($backup, $name);
                return;
            }

            if (!empty($metadata)) {
                $tool = new \Doctrine\ORM\Tools\SchemaTool($this->getEntityManager());
                $tool->dropSchema($metadata);
                $tool->createSchema($metadata);
            }

            if (isset($backup)) {
                copy($name, $backup);
            }
        }
    }
}

This , could be blended into SymfonyDoctrineContext and, of course, requires polishing and introducing an option enabling it.

I could transform this into a PR
@jakzal , are you interested in this improvement ?

Why not truncate tables instead of dropping and recreating schema?

Disabling foreign key checks, truncating all tables and re-enabling foreign key checks is lightning-fast vs. the crawl of dropping and recreating all tables each time. What would be the downsides implementing this way?

# SymfonyDoctrineContext::buildSchema method

$connection = $entityManager->getConnection();
$connection->exec('SET FOREIGN_KEY_CHECKS = 0;');

$schemaManager = $connection->getSchemaManager();
$tables = $schemaManager->listTables();
foreach ($tables as $table) {
    $connection->exec(sprintf('TRUNCATE TABLE %s', $table->getName()));
}

$connection->exec('SET FOREIGN_KEY_CHECKS = 1;');

Add nex tag for composer.

I it's seem that there is no new tags since 11 months.

image

The version 1.1.1 is not compatible with the last behat version.

Can you please add a new tag ?

Best regard.

Inconsistent naming

The repository name is Behat/CommonContexts while the namespace is Behat/CommonContext.

RedirectContext resets session

My controller requires to have an active user session to work. I'm using RedirectContext to test emails. this is the feature:

Background:
Given I am logged in as "user" with password "pass

Scenario: Update a regular Users
...
When I do not follow redirects
And I press "Update"
Then email with subject "Subject" should have been sent to "[email protected]"
And I should be redirected to "/users/"

In /users/ the first line gets the logged user:

public function indexAction(){
$this->get('security.context')->getToken()->getUser()->getId()
...
}

This is the output of the test:

...
Then email with subject "Subject" should have been sent to "[email protected]"
PHP Fatal error: Call to a member function getId() on a non-object in UsersController.php on line 28

Problem with work api and mailer together

I created regstration feature with api and mailer context. Api to send request to my json-rpc application and mailer to check what mail was send.

Scenario: Register new user
    When I send a POST request to "/" with body:
    """
    {
        "jsonrpc": "2.0",
        "method": "registration",
        "params": {
            "name":"user1",
            "email":"[email protected]",
            "password": "12345"
        },
        "id":1
    }
    """
    Then response should contain json:
    """
    {
        "jsonrpc":"2.0",
        "result":null,
        "id":1
    }
    """
    And email with subject "Registration confirmation" should have been sent to "[email protected]"

But I got following error:

..F

(::) проваленные шаги (::)

01. The BrowserKit client returned an unsupported response implementation: Behat\Mink\Driver\BrowserKitDriver
    In step `And email with subject "Registration confirmation" should have been sent to "[email protected]"'. # Behat\CommonContexts\SymfonyMailerContext::emailWithSubjectShouldHaveBeenSent()
    From scenario `Register new user'.                                                                         # features/registration.feature:3
    Of feature `Registration'.                                                                                 # features/registration.feature

1 сценарий (1 провален)
3 шага (2 пройдено, 1 провален)
0m2.396s

What is wrong here? How I can fix this error?

composer.json should require phpunit/phpunit ~3.7

In WebApiContext.php, you're requiring PHPUnit/Autoload.php. However, since version 4.0 of phpunit, it is no longer bringing its own Autoloader but using composer as well.

Please add a require dependency on ~3.7 or alternatively please release a new tag of behat/common-contexts that can deal with phpunit 4.0

Cookies not getting sent

Cookies are not getting sent from request to request.

I realize this might be the desired behavior but if you are using a session cookie to authenticate it's very difficult to use this context.

release

Can you guys release a 1.2.1 or so?

Or what's the plan? :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.