CalderaWP/caldera-interop-fixture

Name: caldera-interop-fixture

Owner: Caldera Labs

Description: Auto-magic(ish) testing for caldera-interop

Created: 2018-05-08 21:50:51.0

Updated: 2018-05-08 22:31:09.0

Pushed: 2018-05-08 21:54:32.0

Homepage: null

Size: 50

Language: PHP

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status

Auto-magic tests for caldera-interop Interoperable Servies

Why?
Install

composer require calderawp/caldera-interop-fixture --dev

Requires
Status

BETA

Usage

This testing component is designed to be used with interoperable sets that are provided to the container using a InteropProvider. This component is comprised of two parts.

Fixture and Prop Description

The InteropFixture class takes an array-like set of data PropData that describes the properties and possible values of an entity. The PropData is the least auto-magic part of this process.

PropData

For each property, we provide that property's name and an array of values. For example, to add a xpLevel prop:

pData = new PropData();
pData->testProps = [
'xpLevel' => [
    'values' => []
]

The values index collects arrays that provides an input value and an expected output value. For example, to test that the absolute value of our property is always returned:


'value' => -10,
'expect' => 10

Completer example:

pData = new PropData();
pData->testProps = [
'xpLevel' => [
    'values' => [
        [
            'value' => -10,
            'expect' => 10
        ],
        [
            'value' => 10,
            'expect' => 10
        ],
    ]
],
'otherLevel' => [
        'values' => [
            [
                'value' => 10,
                'expect' => 10
            ],
            [
                'value' => 10,
                'expect' => 10
            ],
        ]
    ]

InteropFixture
calderawp\InteropFixture\Entities\PropData;
calderawp\InteropFixture\InteropFixture;
ture = new InteropFixture($propData);
Using In Tests
calderawp\HelloExtension\HelloInteropService;
calderawp\interop\CalderaForms;
calderawp\interop\Interfaces\CalderaFormsApp;
calderawp\InteropFixture\Entities\PropData;

lass HelloInteropTest

est the example Hello interop binding

s MyInteropTest extends UnitTestCase

//Make fixture tests available
use TestsInterops;


public function testInterop()
{
    //This provides 64 assertions for a set with two properties :)
    $this->checkFixture(
        new InteropFixture(PropData::fromArray([
            //array like examples above
        ])),
        //The interoperable service provider for this set
        new SomeService(),
        //main app
        CalderaForms::factory()
    );
}



Complete Example

See Tests/example for an example interoperable set that is tested in by the test in tests/Unit/HelloInteropTest. This example has two properites. Both with custom validation logic. 64 assertions are generated for this set.

Development
Install

Requires git and Composer

Coding Standard: Caldera (psr2 with tabs). Enforces using phpcs.

Testing

Tests are divided between unit tests and currently no other types of tests.

Install

All testing dependencies are installed with composer.

Use

Run these commands from the plugin's root directory.

Stuff.

Copyright 2018 CalderaWP LLC. License: GPL v2 or later.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.