2017 © Pedro Peláez
 

library comparehelper

small php helper for comparing api responses in your tests.

image

vielhuber/comparehelper

small php helper for comparing api responses in your tests.

  • Wednesday, August 1, 2018
  • by vielhuber
  • Repository
  • 1 Watchers
  • 0 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

📑 comparehelper 📑

comparehelper is a small php helper for comparing api responses in your tests., (*1)

installation

install once with composer:, (*2)

composer require vielhuber/comparehelper

then add this to your files:, (*3)

require __DIR__.'/vendor/autoload.php';
use vielhuber\comparehelper\comparehelper;

usage

CompareHelper::compare($var1, $var2); // true|false

you can use the following placeholders:, (*4)

  • *: any datatype
  • #STR#: any string
  • #INT#: any numeric value

examples

CompareHelper::compare('foo','foo'); // true

CompareHelper::compare(42,42); // true

CompareHelper::compare(
    [
        'foo' => 'bar'
    ],
    [
        'foo' => 'bar',
        'foo2' => 'bar'
    ]
); // false

CompareHelper::compare(
    [
        'foo' => 'bar',
        'bar' => [
            'baz',
            42
        ]
    ],
    [
        '#STR' => '*',
        'bar' => [
            '#STR#',
            '#INT#'
        ]
    ]
); // true

// ordering is lazy
CompareHelper::compare(['foo','bar'],['bar','foo']); // true
CompareHelper::compare(['#INT#','#STR#'],[42,'foo']); // true
CompareHelper::compare(['#INT#','#STR#'],['foo',42]); // false
CompareHelper::compare(['foo' => 7,'bar' => 42],['bar' => 42,'foo' => 7,]); // true
CompareHelper::compare(['#INT#' => 7,'#STR#' => 42],[7 => 7,'foo' => 42]); // true
CompareHelper::compare(['#INT#' => 7,'#STR#' => 42],['foo' => 42,7 => 7]); // false

// datatypes are strict
CompareHelper::compare(42,'42'); // false

The Versions

01/08 2018

dev-master

9999999-dev

small php helper for comparing api responses in your tests.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

01/08 2018

1.0.2

1.0.2.0

small php helper for comparing api responses in your tests.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

25/07 2018

1.0.1

1.0.1.0

small php helper for comparing api responses in your tests.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

25/07 2018

1.0.0

1.0.0.0

small php helper for comparing api responses in your tests.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires