Skip to content

Docker Compose

Willington Vega edited this page Aug 7, 2020 · 13 revisions

This page is an early draft on how to add Lumiere to a plugin (particularly payment gateways) to run the shared tests using the docker compose environment.

  1. Add Lumiere repository to composer:

    {
      "type": "vcs",
      "url": "[email protected]:skyverge/lumiere.git"
    }
    
  2. Require skyverge/lumiere as a development dependency:

    composer require codeception/module-db codeception/module-webdriver lucatume/wp-browser:2.4.8 skyverge/lumiere --dev
    
  3. lumiere up

  4. codecept build

  5. docker-compose.yml

version: '2'

services:
  codeception:
    volumes:
      - $PWD:/project
      - $PWD:/wordpress/wp-content/plugins/$PLUGIN_DIR

  wordpress:
    volumes:
      - $PWD:/var/www/html/wp-content/plugins/$PLUGIN_DIR
  1. wp-bootstrap.sh
wp wc payment_gateway update {gateway_id} --enabled=true --user=admin

wp option patch insert woocommerce_{gateway_id}_settings debug_mode "log"
wp option patch insert woocommerce_{gateway_id}_settings transaction_type "authorization"
wp option patch insert woocommerce_{gateway_id}_settings charge_virtual_orders "yes"
wp option patch insert woocommerce_{gateway_id}_settings enable_paid_capture "yes"
wp option patch insert woocommerce_{gateway_id}_settings tokenization "yes"
wp option patch insert woocommerce_{gateway_id}_settings environment "test"

# set gateway specific configuration options
  1. _support/Traits/PaymentGatewayMethods.php example

  2. bootstrap.php and codeception.dist.yml

  3. The main extension points are the abstract methods (get_gateway , get_plugin ), place_order , get_credit_cards_data , get_payment_tokens_data.

  4. Extend shared Cests

Frontend

Credit Card Tokenization Tests

Lumiere includes tests for several tokenization scenarios:

To implement those tests in a payment gateway, you should add a tests/frontend/CreditCardTokenizationCest.php class that extends Lumiere's class with the same name:

<?php

use SkyVerge\Lumiere\Tests as Tests;

class CreditCardTokenizationCest extends Tests\Frontend\PaymentGateways\CreditCardTokenizationCest {


	// TODO: define abstract methods


}
  1. Remove existing services: docker-compose -f vendor/skyverge/lumiere/docker/docker-compose.yml -f docker-compose.yml --env-file=.env.lumiere.dist --project-name=lumiere down --volumes

  2. Build services in case there are changes in the Dockerfile or entry-point scripts docker-compose -f vendor/skyverge/lumiere/docker/docker-compose.yml -f docker-compose.yml --env-file=.env.lumiere.dist --project-name=lumiere build

  3. Bootstrap a new Codeception service: docker-compose -f vendor/skyverge/lumiere/docker/docker-compose.yml -f docker-compose.yml --env-file=.env.lumiere.dist --project-name=lumiere run --rm codeception bootstrap

  4. Run the frontend test suite docker-compose -f vendor/skyverge/lumiere/docker/docker-compose.yml -f docker-compose.yml --env-file=.env.lumiere.dist --project-name=lumiere run --workdir /wordpress/wp-content/plugins/woocommerce-gateway-beanstream --rm codeception vendor/bin/codecept run frontend

Clone this wiki locally