2017 © Pedro Peláez
 

behat-extension slim-behat-extension

Slim 3 extension for Behat

image

pavlakis/slim-behat-extension

Slim 3 extension for Behat

  • Sunday, October 8, 2017
  • by pavlakis
  • Repository
  • 1 Watchers
  • 4 Stars
  • 5,317 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 4 % Grown

The README.md

A Behat 3 extension for Slim 3

This extension was written based on the Behat Laravel Extension

Can install it with composer through packagist

 composer require --dev pavlakis/slim-behat-extension

On your behat.yml file add the extension within the extensions section

    Pavlakis\Slim\Behat: ~

The above is the minimum setup as long as you are using Akrabat's Slim 3 Skeleton with the default location for settings.php at app/settings.php and behat.yml inside tests/behat., (*1)

This is the expected directory structure for the default configuration:, (*2)

- my_app_dir
|___ app
    |_______ settings.php
    |_______ dependencies.php
|___ tests
    |_________ behat
               |_____ behat.yml


If behat.yml is in the root folder, use the following:, (*3)


default: suites: default: contexts: - FeatureContext extensions: Pavlakis\Slim\Behat: config_file: app/settings.php dependencies_file: app/dependencies.php

Apart from the config (settings.php) all other parameters are optional, however you can also pass:, (*4)

      config_file: ../../app/configs/settings_test.php
      dependencies_file: ../../app/dependencies.php
      middleware_file: ../../middleware.php
      routes_file: ../../routes.php

In your FeatureContext file

  • Include the KernelAwareContext interface
  • Include the Pavlakis\Slim\Behat\Context\App trait
  • Access the Slim 3 app using $this->app

Feature Context example

Use the logger to log some text to ensure the extension works., (*5)

FeatureContext.php, (*6)


<?php use Behat\Behat\Tester\Exception\PendingException; use Behat\Behat\Context\Context; use Behat\Gherkin\Node\PyStringNode; use Behat\Gherkin\Node\TableNode; use Pavlakis\Slim\Behat\Context\App; use Pavlakis\Slim\Behat\Context\KernelAwareContext; class FeatureContext implements Context, KernelAwareContext { use App; /** * @Then it works */ public function itWorks() { /** @var \Psr\Log\LoggerInterface $logger */ $logger = $this->app->getContainer()->get('logger'); $logger->info("Slim-behat integration works!"); } /** * @Given I load the slim-behat extension */ public function iLoadTheSlimBehatExtension() { } }

test.feature, (*7)


Feature: The extension works In order to see this extension works As a developer I need to be see something happening Scenario: The extension works Given I load the slim-behat extension Then it works

Feature Context example using Mink

use Behat\Behat\Context\Context;

use Behat\MinkExtension\Context\MinkContext;
use Pavlakis\Slim\Behat\Context\App;
use Pavlakis\Slim\Behat\Context\KernelAwareContext;

/**
 * Defines application features from the specific context.
 */
class FeatureContext extends MinkContext implements Context, KernelAwareContext
{
    use App;
}

Accessing your dependencies


$this->app->getContainer()

The Versions

08/10 2017

dev-master

9999999-dev

Slim 3 extension for Behat

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension behat slim

08/10 2017
08/10 2017

dev-feature/remove-composer-lock

dev-feature/remove-composer-lock

Slim 3 extension for Behat

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension behat slim

03/10 2017

dev-feature/add-return-types

dev-feature/add-return-types

Slim 3 extension for Behat

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension behat slim

02/10 2017

dev-develop

dev-develop

Slim 3 extension for Behat

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd extension behat slim

12/01 2016
12/01 2016