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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Auto-magic tests for caldera-interop Interoperable Servies
composer require calderawp/caldera-interop-fixture --dev
BETA
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.
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.
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);
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()
);
}
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.
Requires git and Composer
git clone git@github.com:calderawp/caldera-interop-fixture.git
cd caldera-interop-fixture
composer install
Coding Standard: Caldera (psr2 with tabs). Enforces using phpcs.
Tests are divided between unit tests and currently no other types of tests.
All testing dependencies are installed with composer.
Run these commands from the plugin's root directory.
composer tests
composer unit-tests
/Tests/Unit
composer formatting
Copyright 2018 CalderaWP LLC. License: GPL v2 or later.