2017 © Pedro Peláez
 

library oe-poetry-behat

Poetry Client Behat extension.

image

ec-europa/oe-poetry-behat

Poetry Client Behat extension.

  • Friday, July 20, 2018
  • by ademarco
  • Repository
  • 23 Watchers
  • 0 Stars
  • 11,310 Installations
  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 0 Forks
  • 3 Open issues
  • 19 Versions
  • 21 % Grown

The README.md

Poetry Client Behat Extension

Build Status Packagist, (*1)

Behat extension for the European Commission's Poetry Client., (*2)

Installation Using Docker Compose

Requirements:, (*3)

Copy docker-compose.yml.dist into docker-compose.yml., (*4)

You can make any alterations you need for your local Docker setup. However, the defaults should be enough to set the project up. Note that there are mac specific settings available in the docker-compose.yml.dist., (*5)

Run:, (*6)

$ docker-compose up -d
$ docker-compose exec web composer install

Setup

Load the Poetry context and configure the extension as shown below:, (*7)

default:
  suites:
    default:
      contexts:
        - 'EC\Behat\PoetryExtension\Context\PoetryContext'
  extensions:
    EC\Behat\PoetryExtension:
      application:
        base_url: 'http://local.dev'  # Required: application base URL running Poetry Client library.
        endpoint: '/my-endpoint'      # Required: notification endpoint on your application.

The following extensive configuration allows you to further tweak the extension's behaviour:, (*8)

default:
  suites:
    default:
      contexts:
        - 'EC\Behat\PoetryExtension\Context\PoetryContext'
  extensions:
    EC\Behat\PoetryExtension:
      application:
        base_url: 'http://local.dev'  # Required: application base URL running the Poetry Client library.
        endpoint: '/my-endpoint'      # Required: notification endpoint for your application.
      service:
        host: 'localhost'             # Optional: host where mock Poetry service will be running, defaults to `localhost`.
        port: '28080'                 # Optional: mock Poetry service port, defaults to `28080`.
        endpoint: '/service'          # Optional: mock Poetry service endpoint, defaults to `/service`.
        wsdl: '/wsdl'                 # Optional: mock Poetry service WSDL endpoint, defaults to `/wsdl`.
        username: 'username'          # Optional: username used by the mock service to authenticate on your application, defaults to `username`.
        password: 'password'          # Optional: password used by the mock service to authenticate on your application, defaults to `password`.

Service parameters can be also overridden in your Behat scenarios (see below)., (*9)

Usage

All scenarios and/or features that wish to use the extension's steps will need to be tagged with @poetry., (*10)

To instantiate test Poetry client with redefined settings use:, (*11)

Given the Poetry client uses the following settings:
"""
  identifier.code: STSI
  identifier.year: 2017
  identifier.number: 40017
  identifier.version: 0
  identifier.part: 11
  client.wsdl: http://my-client.eu/wsdl
  notification.username: foo
  notification.password: bar
"""

To send a raw XML notification message to the client endpoint use:, (*12)

When Poetry notifies the client with the following XML:
"""
<?xml version="1.0" encoding="UTF-8"?>
...
"""

Or, if you want to express the message in a withArray() format, use:, (*13)

When Poetry notifies the client with the following "notification.translation_received" message:
"""
identifier:
  code: "WEB"
  year: "2017"
  number: "40012"
  ...
"""

To setup test responses for the Poetry server use:, (*14)

Given Poetry will return the following XML response:
"""
<?xml version="1.0" encoding="utf-8"?><POETRY xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://intragate.ec.europa.eu/DGT/poetry_services/poetry.xsd">
    <request communication="synchrone" id="WEB/2017/40029/0/0/TRA" type="status">
        <demandeId>
            <codeDemandeur>WEB</codeDemandeur>
            <annee>2017</annee>
            ...
"""

Or, if you want to express the message in a withArray() format, use:, (*15)

Given Poetry will return the following "response.status" message response:
"""
identifier:
  code: WEB
  year: 2017
  number: 40029
  version: 0
  ...
"""

Client responses can be asserted by using the following step:, (*16)

Then client response contains the following text:
  | <codeDemandeur>WEB</codeDemandeur> |
  | <annee>2017</annee>                |
  | <statusMessage>OK</statusMessage>  |

Or, if you want to assert XML portions, use:, (*17)

And Poetry service received request should contain the following XML portion:
"""
<documentSource format="HTML" legiswrite="No">
    <documentSourceName>content.html</documentSourceName>
    <documentSourceFile>BASE64ENCODEDFILECONTENT</documentSourceFile>
    <documentSourceLang lgCode="EN">
        <documentSourceLangPages>1</documentSourceLangPages>
    </documentSourceLang>
</documentSource>
"""

Application parameters can be overridden by using the following step:, (*18)

When Poetry service uses the following settings:
"""
  username: foo
  password: bar
"""

For more detailed examples please refer to the Poetry Behat Extension's tests features baring in mind that steps beginning with Given the test application... are only used to test the extension itself and, thus, not available to the extension users., (*19)

Token replacement

Both Behat extension settings and current Poetry client settings can be used in Behat steps as replacement tokens. The following tokens will be automatically replaced:, (*20)

  • Behat extension settings in dot-notation prefixed by !, like !service.host or !service.port
  • Poetry client string settings in dot-notation prefixed by !poetry., like !poetry.client.wsdl.

Token replacements can be used as follow:, (*21)

And Poetry service received request should contain the following XML portion:
"""
<retour type="webService" action="UPDATE">
   <retourUser>foo</retourUser>
   <retourPassword>bar</retourPassword>
   <retourAddress>!poetry.client.wsdl</retourAddress>
   <retourPath>handle</retourPath>
</retour>
"""

The Versions

20/07 2018

dev-master

9999999-dev

Poetry Client Behat extension.

  Sources   Download

EUPL-1.1 EUPL-1.2

The Requires

 

The Development Requires

20/07 2018

dev-OPENEUROPA-721

dev-OPENEUROPA-721

Poetry Client Behat extension.

  Sources   Download

EUPL-1.2

The Requires

 

The Development Requires

12/07 2018

dev-OPENEUROPA-582

dev-OPENEUROPA-582

Poetry Client Behat extension.

  Sources   Download

EUPL-1.1

The Requires

 

The Development Requires

03/07 2018

dev-OPENEUROPA-582-review

dev-OPENEUROPA-582-review

Poetry Client Behat extension.

  Sources   Download

EUPL-1.1

The Requires

 

The Development Requires

29/06 2018

dev-OPENEUROPA-369

dev-OPENEUROPA-369

Poetry Client Behat extension.

  Sources   Download

EUPL-1.2

The Requires

 

The Development Requires

22/02 2018

dev-OPENEUROPA-325

dev-OPENEUROPA-325

Poetry Client Behat extension.

  Sources   Download

EUPL-1.1

The Requires

 

The Development Requires

31/01 2018

dev-18-test-encoded-xml

dev-18-test-encoded-xml

Poetry Client Behat extension.

  Sources   Download

EUPL-1.1

The Requires

 

The Development Requires

31/01 2018

dev-69-test-encoded-xml

dev-69-test-encoded-xml

Poetry Client Behat extension.

  Sources   Download

EUPL-1.1

The Requires

 

The Development Requires

02/01 2018

dev-17-http-mock-version

dev-17-http-mock-version

Poetry Client Behat extension.

  Sources   Download

EUPL-1.1

The Requires

 

The Development Requires

21/12 2017

dev-10-fix-versions

dev-10-fix-versions

Poetry Client Behat extension.

  Sources   Download

EUPL-1.1

The Requires

 

The Development Requires

01/12 2017

dev-12-tokens

dev-12-tokens

Poetry Client Behat extension.

  Sources   Download

EUPL-1.1

The Requires

 

The Development Requires

01/12 2017
20/10 2017