From 233fdeccd7316d4dc26299a986a853c1879089eb Mon Sep 17 00:00:00 2001 From: Vitor iqueira Date: Mon, 31 May 2021 21:14:40 -0300 Subject: [PATCH 1/2] refatora testes para usar Data Providers e dados de phpunit.xml --- .phpunit.result.cache | 1 + composer.json | 2 +- composer.lock | 477 +++++++++++++++++------------ tests/AccountInformationTest.php | 33 +- tests/AreaTypeTest.php | 40 ++- tests/BimerTest.php | 50 +-- tests/CustomerTest.php | 5 +- tests/GeneratorHelper.php | 28 +- tests/IncomeTest.php | 91 +++--- tests/PersonCharacteristicTest.php | 7 +- tests/PersonTest.php | 138 +++++---- tests/PostalCodeTest.php | 12 +- tests/ResourceTest.php | 4 +- 13 files changed, 502 insertions(+), 386 deletions(-) create mode 100644 .phpunit.result.cache diff --git a/.phpunit.result.cache b/.phpunit.result.cache new file mode 100644 index 0000000..4e4e516 --- /dev/null +++ b/.phpunit.result.cache @@ -0,0 +1 @@ +C:37:"PHPUnit\Runner\DefaultTestResultCache":5167:{a:2:{s:7:"defects";a:22:{s:40:"Bimer\Test\IncomeTest::testGetIncomeById";i:4;s:70:"Bimer\Test\IncomeTest::testMakeIncomeBatch with data set "income_data"";i:4;s:69:"Bimer\Test\IncomeTest::testMakeIncomeBatch with data set "batch_data"";i:4;s:59:"Bimer\Test\IncomeTest::testMakeIncomeBatch with data set #0";i:4;s:56:"Bimer\Test\IncomeTest::testCreateIncome with data set #0";i:4;s:57:"Bimer\Test\IncomeTest::testGetIncomeById with data set #0";i:4;s:69:"Bimer\Test\PersonCharacteristicTest::it_should_retrieve_all_resources";i:4;s:49:"Bimer\Test\PersonTest::it_should_retrieve_by_name";i:4;s:50:"Bimer\Test\PersonTest::it_should_create_a_resource";i:4;s:58:"Bimer\Test\PersonTest::it_should_retrieve_none_by_cpf_cnpj";i:4;s:58:"Bimer\Test\PersonTest::it_should_retrieve_some_by_cpf_cnpj";i:4;s:50:"Bimer\Test\PersonTest::it_should_find_one_resource";i:1;s:47:"Bimer\Test\PersonTest::it_should_update_address";i:1;s:48:"Bimer\Test\PostalCodeTest::it_should_get_by_code";i:4;s:55:"Bimer\Test\AccountInformationTest::testGetByDescription";i:4;s:46:"Bimer\Test\AccountInformationTest::testGetById";i:4;s:72:"Bimer\Test\AccountInformationTest::testGetByDescription with data set #0";i:4;s:63:"Bimer\Test\AccountInformationTest::testGetById with data set #0";i:4;s:62:"Bimer\Test\AreaTypeTest::testGetByDescription with data set #0";i:4;s:49:"Bimer\Test\PersonCharacteristicTest::testGetArray";i:4;s:34:"Bimer\Test\PersonTest::testGetById";i:4;s:60:"Bimer\Test\PersonTest::testChangePersonData with data set #0";i:4;}s:5:"times";a:56:{s:67:"Bimer\Test\IncomeTest::testCreateIncome with data set "income_data"";d:1.695;s:40:"Bimer\Test\IncomeTest::testGetIncomeById";d:0;s:68:"Bimer\Test\IncomeTest::testGetIncomeById with data set "income_data"";d:0.816;s:70:"Bimer\Test\IncomeTest::testMakeIncomeBatch with data set "income_data"";d:0;s:69:"Bimer\Test\IncomeTest::testMakeIncomeBatch with data set "batch_data"";d:1.472;s:56:"Bimer\Test\IncomeTest::testCreateIncome with data set #0";d:1.661;s:57:"Bimer\Test\IncomeTest::testGetIncomeById with data set #0";d:2.567;s:59:"Bimer\Test\IncomeTest::testMakeIncomeBatch with data set #0";d:35.599;s:63:"Bimer\Test\AccountInformationTest::it_should_get_by_description";d:4.883;s:54:"Bimer\Test\AccountInformationTest::it_should_get_by_id";d:0.297;s:53:"Bimer\Test\AreaTypeTest::it_should_get_by_description";d:0.291;s:44:"Bimer\Test\AreaTypeTest::it_should_get_by_id";d:0.521;s:57:"Bimer\Test\BimerTest::it_should_get_vars_from_environment";d:0.001;s:41:"Bimer\Test\BimerTest::it_should_set_token";d:0;s:56:"Bimer\Test\CustomerTest::it_should_not_create_a_resource";d:0.007;s:69:"Bimer\Test\PersonCharacteristicTest::it_should_retrieve_all_resources";d:15.02;s:46:"Bimer\Test\PersonTest::it_should_validate_name";d:0.006;s:49:"Bimer\Test\PersonTest::it_should_retrieve_by_name";d:15.014;s:50:"Bimer\Test\PersonTest::it_should_validate_cpf_cnpj";d:0.007;s:50:"Bimer\Test\PersonTest::it_should_create_a_resource";d:10.006;s:58:"Bimer\Test\PersonTest::it_should_retrieve_none_by_cpf_cnpj";d:10.012;s:58:"Bimer\Test\PersonTest::it_should_retrieve_some_by_cpf_cnpj";d:10.01;s:50:"Bimer\Test\PersonTest::it_should_find_one_resource";d:0;s:47:"Bimer\Test\PersonTest::it_should_update_address";d:0;s:50:"Bimer\Test\PostalCodeTest::it_should_validate_code";d:0.006;s:48:"Bimer\Test\PostalCodeTest::it_should_get_by_code";d:0.033;s:55:"Bimer\Test\AccountInformationTest::testGetByDescription";d:0.001;s:46:"Bimer\Test\AccountInformationTest::testGetById";d:0;s:72:"Bimer\Test\AccountInformationTest::testGetByDescription with data set #0";d:5.484;s:63:"Bimer\Test\AccountInformationTest::testGetById with data set #0";d:0.486;s:62:"Bimer\Test\AreaTypeTest::testGetByDescription with data set #0";d:0.277;s:35:"Bimer\Test\IncomeTest::testEndpoint";d:0;s:47:"Bimer\Test\AccountInformationTest::testEndpoint";d:0.001;s:53:"Bimer\Test\AreaTypeTest::testGetById with data set #0";d:0.264;s:37:"Bimer\Test\AreaTypeTest::testEndpoint";d:0;s:44:"Bimer\Test\BimerTest::testSetBimerParameters";d:0.001;s:35:"Bimer\Test\BimerTest::setBimerToken";d:0;s:43:"Bimer\Test\CustomerTest::testCreateCustomer";d:0.002;s:37:"Bimer\Test\CustomerTest::testEndpoint";d:0;s:49:"Bimer\Test\PersonCharacteristicTest::testGetArray";d:6.446;s:49:"Bimer\Test\PersonCharacteristicTest::testEndpoint";d:0;s:39:"Bimer\Test\PersonTest::testValidateName";d:0.002;s:36:"Bimer\Test\PersonTest::testGetByName";d:5.438;s:42:"Bimer\Test\PersonTest::testValidateCpfCnpj";d:0.001;s:39:"Bimer\Test\PersonTest::testCreatePerson";d:1.182;s:42:"Bimer\Test\PersonTest::testGetEmptyCpfCnpj";d:0.271;s:41:"Bimer\Test\PersonTest::testGetSomeCpfCnpj";d:0.498;s:34:"Bimer\Test\PersonTest::testGetById";d:0.001;s:40:"Bimer\Test\PersonTest::testUpdateAddress";d:0.61;s:35:"Bimer\Test\PersonTest::testEndpoint";d:0;s:43:"Bimer\Test\PostalCodeTest::testValidateCode";d:0;s:40:"Bimer\Test\PostalCodeTest::testGetByCode";d:0.294;s:39:"Bimer\Test\PostalCodeTest::testEndpoint";d:0;s:56:"Bimer\Test\PersonTest::testCreatePerson with data set #0";d:0.646;s:60:"Bimer\Test\PersonTest::testChangePersonData with data set #0";d:1.438;s:51:"Bimer\Test\PersonTest::testGetById with data set #0";d:1.071;}}} \ No newline at end of file diff --git a/composer.json b/composer.json index 4cc2221..fc919d8 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ }, "require-dev": { "php": ">=7.3", - "phpunit/phpunit": "^6" + "phpunit/phpunit": "^8.5" }, "authors": [ { diff --git a/composer.lock b/composer.lock index 61abcdb..5a0c167 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "35d669049a04f89de6123464d2e8c777", + "content-hash": "67082925aa6bcb9a0a125a76d3ba4bfc", "packages": [ { "name": "guzzlehttp/guzzle", @@ -489,28 +489,29 @@ }, { "name": "phar-io/manifest", - "version": "1.0.1", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0" + "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0", - "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/85265efd3af7ba3ca4b2a2c34dbfc5788dd29133", + "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133", "shasum": "" }, "require": { "ext-dom": "*", "ext-phar": "*", - "phar-io/version": "^1.0.1", - "php": "^5.6 || ^7.0" + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -540,24 +541,24 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "time": "2017-03-05T18:14:27+00:00" + "time": "2020-06-27T14:33:11+00:00" }, { "name": "phar-io/version", - "version": "1.0.1", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df" + "reference": "bae7c545bef187884426f042434e561ab1ddb182" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df", - "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df", + "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182", + "reference": "bae7c545bef187884426f042434e561ab1ddb182", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.2 || ^8.0" }, "type": "library", "autoload": { @@ -587,7 +588,7 @@ } ], "description": "Library for handling version information and constraints", - "time": "2017-03-05T17:38:23+00:00" + "time": "2021-02-23T14:00:09+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -737,33 +738,33 @@ }, { "name": "phpspec/prophecy", - "version": "v1.10.3", + "version": "1.13.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "451c3cd1418cf640de218914901e51b064abb093" + "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", - "reference": "451c3cd1418cf640de218914901e51b064abb093", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea", + "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" + "doctrine/instantiator": "^1.2", + "php": "^7.2 || ~8.0, <8.1", + "phpdocumentor/reflection-docblock": "^5.2", + "sebastian/comparator": "^3.0 || ^4.0", + "sebastian/recursion-context": "^3.0 || ^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5 || ^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" + "phpspec/phpspec": "^6.0", + "phpunit/phpunit": "^8.0 || ^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.10.x-dev" + "dev-master": "1.11.x-dev" } }, "autoload": { @@ -796,44 +797,44 @@ "spy", "stub" ], - "time": "2020-03-05T15:02:03+00:00" + "time": "2021-03-17T13:42:18+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "5.3.2", + "version": "7.0.14", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "c89677919c5dd6d3b3852f230a663118762218ac" + "reference": "bb7c9a210c72e4709cdde67f8b7362f672f2225c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c89677919c5dd6d3b3852f230a663118762218ac", - "reference": "c89677919c5dd6d3b3852f230a663118762218ac", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/bb7c9a210c72e4709cdde67f8b7362f672f2225c", + "reference": "bb7c9a210c72e4709cdde67f8b7362f672f2225c", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", - "php": "^7.0", - "phpunit/php-file-iterator": "^1.4.2", + "php": ">=7.2", + "phpunit/php-file-iterator": "^2.0.2", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^2.0.1", + "phpunit/php-token-stream": "^3.1.1 || ^4.0", "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.0", + "sebastian/environment": "^4.2.2", "sebastian/version": "^2.0.1", - "theseer/tokenizer": "^1.1" + "theseer/tokenizer": "^1.1.3" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^8.2.2" }, "suggest": { - "ext-xdebug": "^2.5.5" + "ext-xdebug": "^2.7.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.3.x-dev" + "dev-master": "7.0-dev" } }, "autoload": { @@ -859,29 +860,38 @@ "testing", "xunit" ], - "time": "2018-04-06T15:36:58+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-12-02T13:39:03+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.5", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" + "reference": "4b49fb70f067272b659ef0174ff9ca40fdaa6357" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/4b49fb70f067272b659ef0174ff9ca40fdaa6357", + "reference": "4b49fb70f067272b659ef0174ff9ca40fdaa6357", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -896,7 +906,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -906,7 +916,13 @@ "filesystem", "iterator" ], - "time": "2017-11-27T13:52:08+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T08:25:21+00:00" }, { "name": "phpunit/php-text-template", @@ -951,28 +967,28 @@ }, { "name": "phpunit/php-timer", - "version": "1.0.9", + "version": "2.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + "reference": "2454ae1765516d20c4ffe103d85a58a9a3bd5662" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/2454ae1765516d20c4ffe103d85a58a9a3bd5662", + "reference": "2454ae1765516d20c4ffe103d85a58a9a3bd5662", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -987,7 +1003,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -996,33 +1012,39 @@ "keywords": [ "timer" ], - "time": "2017-02-26T11:10:40+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T08:20:02+00:00" }, { "name": "phpunit/php-token-stream", - "version": "2.0.2", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "791198a2c6254db10131eecfe8c06670700904db" + "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", - "reference": "791198a2c6254db10131eecfe8c06670700904db", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/a853a0e183b9db7eed023d7933a858fa1c8d25a3", + "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": "^7.0" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^6.2.4" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1045,58 +1067,63 @@ "keywords": [ "tokenizer" ], + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], "abandoned": true, - "time": "2017-11-27T05:48:46+00:00" + "time": "2020-08-04T08:28:15+00:00" }, { "name": "phpunit/phpunit", - "version": "6.5.14", + "version": "8.5.15", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7" + "reference": "038d4196d8e8cb405cd5e82cedfe413ad6eef9ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/bac23fe7ff13dbdb461481f706f0e9fe746334b7", - "reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/038d4196d8e8cb405cd5e82cedfe413ad6eef9ef", + "reference": "038d4196d8e8cb405cd5e82cedfe413ad6eef9ef", "shasum": "" }, "require": { + "doctrine/instantiator": "^1.3.1", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", - "myclabs/deep-copy": "^1.6.1", - "phar-io/manifest": "^1.0.1", - "phar-io/version": "^1.0", - "php": "^7.0", - "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^5.3", - "phpunit/php-file-iterator": "^1.4.3", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.10.0", + "phar-io/manifest": "^2.0.1", + "phar-io/version": "^3.0.2", + "php": ">=7.2", + "phpspec/prophecy": "^1.10.3", + "phpunit/php-code-coverage": "^7.0.12", + "phpunit/php-file-iterator": "^2.0.2", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^1.0.9", - "phpunit/phpunit-mock-objects": "^5.0.9", - "sebastian/comparator": "^2.1", - "sebastian/diff": "^2.0", - "sebastian/environment": "^3.1", - "sebastian/exporter": "^3.1", - "sebastian/global-state": "^2.0", + "phpunit/php-timer": "^2.1.2", + "sebastian/comparator": "^3.0.2", + "sebastian/diff": "^3.0.2", + "sebastian/environment": "^4.2.3", + "sebastian/exporter": "^3.1.2", + "sebastian/global-state": "^3.0.0", "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^1.0", + "sebastian/resource-operations": "^2.0.1", + "sebastian/type": "^1.1.3", "sebastian/version": "^2.0.1" }, - "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2", - "phpunit/dbunit": "<3.0" - }, "require-dev": { "ext-pdo": "*" }, "suggest": { + "ext-soap": "*", "ext-xdebug": "*", - "phpunit/php-invoker": "^1.1" + "phpunit/php-invoker": "^2.0.0" }, "bin": [ "phpunit" @@ -1104,7 +1131,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.5.x-dev" + "dev-master": "8.5-dev" } }, "autoload": { @@ -1130,67 +1157,17 @@ "testing", "xunit" ], - "time": "2019-02-01T05:22:47+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "5.0.10", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "cd1cf05c553ecfec36b170070573e540b67d3f1f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/cd1cf05c553ecfec36b170070573e540b67d3f1f", - "reference": "cd1cf05c553ecfec36b170070573e540b67d3f1f", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.5", - "php": "^7.0", - "phpunit/php-text-template": "^1.2.1", - "sebastian/exporter": "^3.1" - }, - "conflict": { - "phpunit/phpunit": "<6.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.5.11" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ + "funding": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "url": "https://phpunit.de/donate.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" } ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "abandoned": true, - "time": "2018-08-09T05:50:03+00:00" + "time": "2021-03-17T07:27:54+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -1245,30 +1222,30 @@ }, { "name": "sebastian/comparator", - "version": "2.1.3", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9" + "reference": "1071dfcef776a57013124ff35e1fc41ccd294758" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9", - "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1071dfcef776a57013124ff35e1fc41ccd294758", + "reference": "1071dfcef776a57013124ff35e1fc41ccd294758", "shasum": "" }, "require": { - "php": "^7.0", - "sebastian/diff": "^2.0 || ^3.0", + "php": ">=7.1", + "sebastian/diff": "^3.0", "sebastian/exporter": "^3.1" }, "require-dev": { - "phpunit/phpunit": "^6.4" + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1281,6 +1258,10 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -1292,10 +1273,6 @@ { "name": "Bernhard Schussek", "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" } ], "description": "Provides the functionality to compare PHP values for equality", @@ -1305,32 +1282,39 @@ "compare", "equality" ], - "time": "2018-02-01T13:46:46+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T08:04:30+00:00" }, { "name": "sebastian/diff", - "version": "2.0.1", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd" + "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", - "reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/14f72dd46eaf2f2293cbe79c93cc0bc43161a211", + "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^6.2" + "phpunit/phpunit": "^7.5 || ^8.0", + "symfony/process": "^2 || ^3.3 || ^4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1343,46 +1327,58 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" } ], "description": "Diff implementation", "homepage": "https://github.com/sebastianbergmann/diff", "keywords": [ - "diff" + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2017-08-03T08:09:46+00:00" + "time": "2020-11-30T07:59:04+00:00" }, { "name": "sebastian/environment", - "version": "3.1.0", + "version": "4.2.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" + "reference": "d47bbbad83711771f167c72d4e3f25f7fcc1f8b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/d47bbbad83711771f167c72d4e3f25f7fcc1f8b0", + "reference": "d47bbbad83711771f167c72d4e3f25f7fcc1f8b0", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^6.1" + "phpunit/phpunit": "^7.5" + }, + "suggest": { + "ext-posix": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1.x-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -1407,7 +1403,13 @@ "environment", "hhvm" ], - "time": "2017-07-01T08:51:00+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:53:42+00:00" }, { "name": "sebastian/exporter", @@ -1484,23 +1486,26 @@ }, { "name": "sebastian/global-state", - "version": "2.0.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" + "reference": "474fb9edb7ab891665d3bfc6317f42a0a150454b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/474fb9edb7ab891665d3bfc6317f42a0a150454b", + "reference": "474fb9edb7ab891665d3bfc6317f42a0a150454b", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=7.2", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "ext-dom": "*", + "phpunit/phpunit": "^8.0" }, "suggest": { "ext-uopz": "*" @@ -1508,7 +1513,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1531,7 +1536,13 @@ "keywords": [ "global state" ], - "time": "2017-04-27T15:39:26+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:43:24+00:00" }, { "name": "sebastian/object-enumerator", @@ -1698,25 +1709,25 @@ }, { "name": "sebastian/resource-operations", - "version": "1.0.0", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + "reference": "31d35ca87926450c44eae7e2611d45a7a65ea8b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/31d35ca87926450c44eae7e2611d45a7a65ea8b3", + "reference": "31d35ca87926450c44eae7e2611d45a7a65ea8b3", "shasum": "" }, "require": { - "php": ">=5.6.0" + "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1736,7 +1747,65 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2015-07-28T20:34:47+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:30:19+00:00" + }, + { + "name": "sebastian/type", + "version": "1.1.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "0150cfbc4495ed2df3872fb31b26781e4e077eb4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/0150cfbc4495ed2df3872fb31b26781e4e077eb4", + "reference": "0150cfbc4495ed2df3872fb31b26781e4e077eb4", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:25:11+00:00" }, { "name": "sebastian/version", @@ -1783,16 +1852,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.22.1", + "version": "v1.23.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "c6c942b1ac76c82448322025e084cadc56048b4e" + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e", - "reference": "c6c942b1ac76c82448322025e084cadc56048b4e", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", "shasum": "" }, "require": { @@ -1804,7 +1873,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.22-dev" + "dev-main": "1.23-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1855,7 +1924,7 @@ "type": "tidelift" } ], - "time": "2021-01-07T16:49:33+00:00" + "time": "2021-02-19T12:13:01+00:00" }, { "name": "theseer/tokenizer", diff --git a/tests/AccountInformationTest.php b/tests/AccountInformationTest.php index 2caab02..cfd0f6a 100644 --- a/tests/AccountInformationTest.php +++ b/tests/AccountInformationTest.php @@ -7,32 +7,41 @@ class AccountInformationTest extends ResourceTest { - public function setUp() + public function setUp(): void { $this->resource = AccountInformation::class; - - $this->data = [ - 'description' => 'aa', - 'id' => '00A00000AA', - ]; } /** - * @test + * @dataProvider accountData */ - public function it_should_get_by_description() + public function testGetByDescription(array $accountData) { - $response = $this->resource::getByDescription($this->data['description']); + $response = $this->resource::getByDescription($accountData['description']); $this->assertGreaterThan(0, count($response)); } /** - * @test + * @dataProvider accountData */ - public function it_should_get_by_id() + public function testGetById(array $accountData) { - $accountInformation = $this->resource::find($this->data['id']); + $accountInformation = $this->resource::find($accountData['id']); $this->assertObjectHasAttribute('Identificador', $accountInformation); } + + /** + * Data provider for Account Data + */ + public function accountData(): array + { + $accountData = (array)json_decode(getenv('DATA_ACCOUNT')); + + return [ + [ + $accountData + ] + ]; + } } diff --git a/tests/AreaTypeTest.php b/tests/AreaTypeTest.php index f45ee11..18b4274 100644 --- a/tests/AreaTypeTest.php +++ b/tests/AreaTypeTest.php @@ -7,30 +7,42 @@ class AreaTypeTest extends ResourceTest { - public function setUp() + public function setUp(): void { $this->resource = AreaType::class; - - $this->data = [ - 'description' => 'RUA', - 'id' => '00A0000006' - ]; } - /** @test */ - public function it_should_get_by_description() + /** + * @dataProvider areaTypeData + */ + public function testGetByDescription(array $areaType) { - $response = $this->resource::getByDescription($this->data['description']); + $response = $this->resource::getByDescription($areaType['description']); $this->assertGreaterThan(0, count($response)); - - $this->firstRecord = reset($response); } - /** @test */ - public function it_should_get_by_id() + /** + * @dataProvider areaTypeData + */ + public function testGetById(array $areaType) { - $accountInformation = $this->resource::find($this->data['id']); + $accountInformation = $this->resource::find($areaType['id']); + $this->assertObjectHasAttribute('Identificador', $accountInformation); } + + /** + * Data provider for Area Type Data + */ + public function areaTypeData(): array + { + $areaType = (array)json_decode(getenv('DATA_AREA_TYPE')); + + return [ + [ + $areaType + ] + ]; + } } diff --git a/tests/BimerTest.php b/tests/BimerTest.php index f849107..cba98c8 100644 --- a/tests/BimerTest.php +++ b/tests/BimerTest.php @@ -8,42 +8,44 @@ final class BimerTest extends TestCase { - /** @test */ - public function it_should_get_vars_from_environment() + public function testSetBimerParameters() { - $envValue = getenv(Bimer::BIMER_API_URL); - $bimmerValue = Bimer::getApiUrl(); - $this->assertEquals($bimmerValue, $envValue); + $envValue = getenv(Bimer::BIMER_API_URL); + $bimerValue = Bimer::getApiUrl(); + $this->assertEquals($bimerValue, $envValue); - $envValue = getenv(Bimer::BIMER_API_USER); - $bimmerValue = Bimer::getUsername(); - $this->assertEquals($bimmerValue, $envValue); + $envValue = getenv(Bimer::BIMER_API_USER); + $bimerValue = Bimer::getUsername(); + $this->assertEquals($bimerValue, $envValue); - $envValue = getenv(Bimer::BIMER_API_PWD); - $bimmerValue = Bimer::getPassword(); - $this->assertEquals($bimmerValue, $envValue); + $envValue = getenv(Bimer::BIMER_API_PWD); + $bimerValue = Bimer::getPassword(); + $this->assertEquals($bimerValue, $envValue); - $envValue = getenv(Bimer::BIMER_API_ID); - $bimmerValue = Bimer::getClientId(); - $this->assertEquals($bimmerValue, $envValue); + $envValue = getenv(Bimer::BIMER_API_ID); + $bimerValue = Bimer::getClientId(); + $this->assertEquals($bimerValue, $envValue); - $envValue = getenv(Bimer::BIMER_API_SECRET); - $bimmerValue = Bimer::getClientSecret(); - $this->assertEquals($bimmerValue, $envValue); + $envValue = getenv(Bimer::BIMER_API_SECRET); + $bimerValue = Bimer::getClientSecret(); + $this->assertEquals($bimerValue, $envValue); - $envValue = getenv(Bimer::BIMER_API_TIMEOUT); - $bimmerValue = Bimer::getTimeout(); - $this->assertEquals($bimmerValue, $envValue); + $envValue = getenv(Bimer::BIMER_API_TIMEOUT); + $bimerValue = Bimer::getTimeout(); + $this->assertEquals($bimerValue, $envValue); } /** @test */ - public function it_should_set_token() + public function setBimerToken() { $random = (string)rand(); Bimer::setToken($random); - $value = Bimer::getToken(); - $this->assertEquals($value, $random); - Bimer::setToken(null); + $this->assertEquals(Bimer::getToken(), $random); + } + + protected function tearDown(): void + { + Bimer::setToken(); } } diff --git a/tests/CustomerTest.php b/tests/CustomerTest.php index 99e3bbb..48aaa35 100644 --- a/tests/CustomerTest.php +++ b/tests/CustomerTest.php @@ -8,13 +8,12 @@ class CustomerTest extends ResourceTest { - public function setUp() + public function setUp(): void { $this->resource = Customer::class; } - /** @test */ - public function it_should_not_create_a_resource() + public function testCreateCustomer() { $invalidParameters = []; $this->expectException(BimerApiException::class); diff --git a/tests/GeneratorHelper.php b/tests/GeneratorHelper.php index fa25898..ae0dc3b 100644 --- a/tests/GeneratorHelper.php +++ b/tests/GeneratorHelper.php @@ -13,13 +13,10 @@ class GeneratorHelper { /** - * Método para gerar CNPJ válido, com máscara ou não - * @param int $mascara + * @param bool $mascara * @return string - * @example cnpjRandom(0) - * para retornar CNPJ sem máscar */ - public static function cnpjRandom($mascara = "1") + public static function cnpjRandom(bool $mascara = true): string { $n1 = rand(0, 9); $n2 = rand(0, 9); @@ -43,8 +40,7 @@ public static function cnpjRandom($mascara = "1") if ($d2 >= 10) { $d2 = 0; } - $retorno = ''; - if ($mascara == 1) { + if ($mascara) { $retorno = '' . $n1 . $n2 . "." . $n3 . $n4 . $n5 . "." . $n6 . $n7 . $n8 . "/" . $n9 . $n10 . $n11 . $n12 . "-" . $d1 . $d2; } else { $retorno = '' . $n1 . $n2 . $n3 . $n4 . $n5 . $n6 . $n7 . $n8 . $n9 . $n10 . $n11 . $n12 . $d1 . $d2; @@ -53,13 +49,10 @@ public static function cnpjRandom($mascara = "1") } /** - * Método para gerar CPF válido, com máscara ou não - * @param int $mascara + * @param bool $mascara * @return string - * @example cpfRandom(0) - * para retornar CPF sem máscar */ - public static function cpfRandom($mascara = "1") + public static function cpfRandom(bool $mascara = true): string { $n1 = rand(0, 9); $n2 = rand(0, 9); @@ -80,8 +73,7 @@ public static function cpfRandom($mascara = "1") if ($d2 >= 10) { $d2 = 0; } - $retorno = ''; - if ($mascara == 1) { + if ($mascara) { $retorno = '' . $n1 . $n2 . $n3 . "." . $n4 . $n5 . $n6 . "." . $n7 . $n8 . $n9 . "-" . $d1 . $d2; } else { $retorno = '' . $n1 . $n2 . $n3 . $n4 . $n5 . $n6 . $n7 . $n8 . $n9 . $d1 . $d2; @@ -90,11 +82,11 @@ public static function cpfRandom($mascara = "1") } /** - * @param type $dividendo - * @param type $divisor - * @return type + * @param int $dividendo + * @param int $divisor + * @return float */ - private static function mod($dividendo, $divisor) + private static function mod(int $dividendo, int $divisor) { return round($dividendo - (floor($dividendo / $divisor) * $divisor)); } diff --git a/tests/IncomeTest.php b/tests/IncomeTest.php index 5a45edb..484c383 100644 --- a/tests/IncomeTest.php +++ b/tests/IncomeTest.php @@ -1,4 +1,5 @@ resource = Income::class; - - $this->data = [ - 'CodigoEmpresa' => '1', - 'IdentificadorPessoa' => '00A000000A', - 'IdentificadorFormaPagamento' => '00A0000001', - 'CodigoEnderecoCobranca' => '01', - 'ValorTitulo' => 100 - ]; - - $this->batchData = [ - "CodigoEmpresa" => 1, - "LoteAReceberItemBaixa" => [ - [ - "IdentificadorTituloAReceber" => "", - "IdentificadorFormaPagamento" => "00A0000001", - "IdentificadorTipoBaixa" => "00A0000002", - "IdentificadorContaBancaria" => "00A0000005" - ] - ] - ]; } - /** @test */ - public function it_should_create_a_resource() + /** + * @dataProvider incomeData + */ + public function testCreateIncome(array $incomeData) { - $incomeId = Income::create($this->data); + $incomeId = Income::create($incomeData); - $this->assertTrue(strlen($incomeId) > 1); - - return $incomeId; + $this->assertNotEmpty($incomeId); } /** - * @depends it_should_create_a_resource - * @test + * @dataProvider incomeData */ - public function it_should_retrieve_resource($incomeId) + public function testGetIncomeById(array $incomeData) { + $incomeId = Income::create($incomeData); $income = $this->resource::find($incomeId); + $this->assertObjectHasAttribute('Identificador', $income); } /** - * @depends it_should_create_a_resource - * @test + * @dataProvider batchData */ - public function it_should_make_a_batch($incomeId) + public function testMakeIncomeBatch(array $incomeData, array $batchData) { - $this->batchData["LoteAReceberItemBaixa"][0]["IdentificadorTituloAReceber"] = $incomeId; + $incomeId = Income::create($incomeData); - $batch = Income::makeBatch($this->batchData); + $batchData["LoteAReceberItemBaixa"][0]->IdentificadorTituloAReceber = $incomeId; + $batch = Income::makeBatch($batchData); $this->assertObjectHasAttribute('IdentificadorLoteAReceber', $batch); } + + /** + * Data provider for Income Data + */ + public function incomeData(): array + { + $incomeData = array_merge((array)json_decode(getenv('DATA_INCOME')), [ + "NumeroTitulo" => random_int(10000, 999999), + "ValorTitulo" => 100 + ]); + + return [ + [ + $incomeData + ] + ]; + } + + /** + * Data provider for Batch Data + */ + public function batchData(): array + { + $incomeData = array_merge((array)json_decode(getenv('DATA_INCOME')), [ + "NumeroTitulo" => random_int(10000, 999999), + "ValorTitulo" => 100 + ]); + + $batchData = (array)json_decode(getenv('DATA_INCOME_BATCH')); + + return [ + [ + $incomeData, + $batchData + ] + ]; + } } diff --git a/tests/PersonCharacteristicTest.php b/tests/PersonCharacteristicTest.php index f29dd31..09b5d87 100644 --- a/tests/PersonCharacteristicTest.php +++ b/tests/PersonCharacteristicTest.php @@ -7,15 +7,16 @@ class PersonCharacteristicTest extends ResourceTest { - public function setUp() + public function setUp(): void { $this->resource = PersonCharacteristic::class; } - /** @test */ - public function it_should_retrieve_all_resources() + public function testGetArray() { $response = $this->resource::all(); + + $this->assertIsArray($response); $this->assertGreaterThan(0, count($response)); } } diff --git a/tests/PersonTest.php b/tests/PersonTest.php index 48c71fd..40f9984 100644 --- a/tests/PersonTest.php +++ b/tests/PersonTest.php @@ -4,121 +4,141 @@ namespace Bimer\Test; use Bimer\Exceptions\BimerApiException; +use Bimer\Exceptions\BimerParameterException; +use Bimer\Exceptions\BimerRequestException; use Bimer\Person; class PersonTest extends ResourceTest { - public function setUp() + public function setUp(): void { $this->resource = Person::class; - $this->data = (array)json_decode(getenv('DATA')); + $this->incomeData = (array)json_decode(getenv('DATA_PERSON')); } - /** @test */ - public function it_should_validate_name() + public function testValidateName() { $this->expectException(BimerApiException::class); - $response = $this->resource::getByName('a'); + $this->resource::getByName('a'); } - /** @test */ - public function it_should_retrieve_by_name() + public function testGetByName() { $response = $this->resource::getByName('NOME'); + $this->assertIsArray($response); $this->assertGreaterThanOrEqual(0, count($response)); } - /** @test */ - public function it_should_validate_cpf_cnpj() + public function testValidateCpfCnpj() { $this->expectException(BimerApiException::class); - $response = $this->resource::getByCpfCnpj('123.456.789-01'); - $this->assertGreaterThanOrEqual(0, count($response)); + $this->resource::getByCpfCnpj('123.456.789-01'); } - /** @test */ - public function it_should_create_a_resource() + /** + * @dataProvider addressData + */ + public function testCreatePerson(array $addressData) { - $customer = \Bimer\Customer::create([ - 'Nome' => 'Customer #' . rand(), - 'CpfCnpj' => GeneratorHelper::cpfRandom(0), - 'Enderecos' => [ - [ - 'TipoCadastro' => 'I', - 'CEP' => '22060020', - 'IdentificadorBairro' => '00A00001R7', - 'IdentificadorCidade' => '00A000059E', - 'NomeLogradouro' => 'RUA LEOPOLDO MIGUEZ 99/202', - 'IdentificadorTipoLogradouro' => '00A0000006', - 'SiglaUnidadeFederativa' => 'SP', - 'Tipos' => [ - 'Principal' => true - ] - ] - ] - ]); + $customer = $this->createCustomer($addressData); $this->assertObjectHasAttribute('Identificador', $customer); - - return $customer; } - /** @test */ - public function it_should_retrieve_none_by_cpf_cnpj() + public function testGetEmptyCpfCnpj() { - $randomCpf = GeneratorHelper::cpfRandom(0); + $randomCpf = GeneratorHelper::cpfRandom(false); $response = $this->resource::getByCpfCnpj($randomCpf); - $empty = is_array($response) && count($response) == 0; - $this->assertTrue($empty); + + $this->assertIsArray($response); + $this->assertEmpty($response); } - /** @test */ - public function it_should_retrieve_some_by_cpf_cnpj() + public function testGetSomeCpfCnpj() { - $response = $this->resource::getByCpfCnpj($this->data['cpfCnpj']); - $some = is_array($response) && count($response) > 0; - $this->assertTrue($some); + $response = $this->resource::getByCpfCnpj($this->incomeData['cpfCnpj']); + + $this->assertIsArray($response); + $this->assertNotEmpty($response); } /** - * @depends it_should_create_a_resource - * @test + * @dataProvider addressData */ - public function it_should_find_one_resource($customer) + public function testGetById(array $addressData) { + $customer = $this->createCustomer($addressData); $person = $this->resource::find($customer->Identificador); $this->assertObjectHasAttribute('Identificador', $person); } /** - * @depends it_should_create_a_resource - * @test + * @dataProvider addressData */ - public function it_should_update_address($customer) + public function testChangePersonData(array $addressData) { + $customer = $this->createCustomer($addressData); + + $placeholder = 'CHANGE TEST'; $data = [ - 'Nome' => 'Changed2', + 'Nome' => $placeholder, 'Enderecos' => [ - [ + array_merge($addressData, [ 'Codigo' => '01', 'TipoCadastro' => 'A', - 'CEP' => '22060020', - 'IdentificadorBairro' => '00A00001R7', - 'IdentificadorCidade' => '00A000059E', - 'NomeLogradouro' => 'Changed2', + 'NomeLogradouro' => $placeholder, 'Tipos' => [ 'Principal' => true ] - ] + ]) ] ]; - $person = $this->resource::update($customer->Identificador, $data); - $this->assertSame($person->Nome, strtoupper('Changed2')); - $this->assertSame($person->Enderecos[0]->NomeLogradouro, 'Changed2'); + + $this->assertSame($person->Nome, $placeholder); + $this->assertSame($person->Enderecos[0]->NomeLogradouro, $placeholder); + } + + /** + * Data provider for Address Data + */ + public function addressData(): array + { + $areaType = (array)json_decode(getenv('DATA_ADDRESS')); + + return [ + [ + $areaType + ] + ]; + } + + /** + * @param array $addressData + * @return \stdClass + * @throws BimerApiException + * @throws BimerParameterException + * @throws BimerRequestException + */ + private function createCustomer(array $addressData): \stdClass + { + return \Bimer\Customer::create([ + 'Nome' => 'Customer #' . rand(), + 'CpfCnpj' => GeneratorHelper::cpfRandom(false), + 'Enderecos' => [ + array_merge($addressData, [ + 'Codigo' => '01', + 'TipoCadastro' => 'I', + 'NomeLogradouro' => 'CREATE TEST', + 'Tipos' => [ + 'Principal' => true + ] + ]) + ] + ]); } } diff --git a/tests/PostalCodeTest.php b/tests/PostalCodeTest.php index 99a9ed8..0fbec0d 100644 --- a/tests/PostalCodeTest.php +++ b/tests/PostalCodeTest.php @@ -8,25 +8,19 @@ class PostalCodeTest extends ResourceTest { - public function setUp() + public function setUp(): void { $this->resource = PostalCode::class; } - /** - * @test - */ - public function it_should_validate_code() + public function testValidateCode() { $this->expectException(BimerApiException::class); $this->resource::getByCode('0'); } - /** - * @test - */ - public function it_should_get_by_code() + public function testGetByCode() { $response = (array)$this->resource::getByCode('01310200'); $this->assertGreaterThan(0, count($response)); diff --git a/tests/ResourceTest.php b/tests/ResourceTest.php index 5bbdac4..01b5663 100644 --- a/tests/ResourceTest.php +++ b/tests/ResourceTest.php @@ -7,11 +7,11 @@ class ResourceTest extends TestCase { - protected $data; + protected $incomeData; protected $resource; - public function it_should_have_an_endpoint() + public function testEndpoint() { $this->assertNotEmpty($this->resource::endpoint()); } From 1d0f18e1584d3a09e7afbd57d3eb2f24b105ca00 Mon Sep 17 00:00:00 2001 From: Vitor Siqueira Date: Mon, 31 May 2021 22:46:28 -0300 Subject: [PATCH 2/2] atualiza phpunit.xml.dist e readme --- .gitignore | 1 + .phpunit.result.cache | 1 - README.md | 2 +- composer.json | 2 +- phpunit.xml.dist | 7 ++++++- 5 files changed, 9 insertions(+), 4 deletions(-) delete mode 100644 .phpunit.result.cache diff --git a/.gitignore b/.gitignore index d81715d..73eeacf 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ composer.phar vendor phpunit.xml index.php +.phpunit.result.cache # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file diff --git a/.phpunit.result.cache b/.phpunit.result.cache deleted file mode 100644 index 4e4e516..0000000 --- a/.phpunit.result.cache +++ /dev/null @@ -1 +0,0 @@ -C:37:"PHPUnit\Runner\DefaultTestResultCache":5167:{a:2:{s:7:"defects";a:22:{s:40:"Bimer\Test\IncomeTest::testGetIncomeById";i:4;s:70:"Bimer\Test\IncomeTest::testMakeIncomeBatch with data set "income_data"";i:4;s:69:"Bimer\Test\IncomeTest::testMakeIncomeBatch with data set "batch_data"";i:4;s:59:"Bimer\Test\IncomeTest::testMakeIncomeBatch with data set #0";i:4;s:56:"Bimer\Test\IncomeTest::testCreateIncome with data set #0";i:4;s:57:"Bimer\Test\IncomeTest::testGetIncomeById with data set #0";i:4;s:69:"Bimer\Test\PersonCharacteristicTest::it_should_retrieve_all_resources";i:4;s:49:"Bimer\Test\PersonTest::it_should_retrieve_by_name";i:4;s:50:"Bimer\Test\PersonTest::it_should_create_a_resource";i:4;s:58:"Bimer\Test\PersonTest::it_should_retrieve_none_by_cpf_cnpj";i:4;s:58:"Bimer\Test\PersonTest::it_should_retrieve_some_by_cpf_cnpj";i:4;s:50:"Bimer\Test\PersonTest::it_should_find_one_resource";i:1;s:47:"Bimer\Test\PersonTest::it_should_update_address";i:1;s:48:"Bimer\Test\PostalCodeTest::it_should_get_by_code";i:4;s:55:"Bimer\Test\AccountInformationTest::testGetByDescription";i:4;s:46:"Bimer\Test\AccountInformationTest::testGetById";i:4;s:72:"Bimer\Test\AccountInformationTest::testGetByDescription with data set #0";i:4;s:63:"Bimer\Test\AccountInformationTest::testGetById with data set #0";i:4;s:62:"Bimer\Test\AreaTypeTest::testGetByDescription with data set #0";i:4;s:49:"Bimer\Test\PersonCharacteristicTest::testGetArray";i:4;s:34:"Bimer\Test\PersonTest::testGetById";i:4;s:60:"Bimer\Test\PersonTest::testChangePersonData with data set #0";i:4;}s:5:"times";a:56:{s:67:"Bimer\Test\IncomeTest::testCreateIncome with data set "income_data"";d:1.695;s:40:"Bimer\Test\IncomeTest::testGetIncomeById";d:0;s:68:"Bimer\Test\IncomeTest::testGetIncomeById with data set "income_data"";d:0.816;s:70:"Bimer\Test\IncomeTest::testMakeIncomeBatch with data set "income_data"";d:0;s:69:"Bimer\Test\IncomeTest::testMakeIncomeBatch with data set "batch_data"";d:1.472;s:56:"Bimer\Test\IncomeTest::testCreateIncome with data set #0";d:1.661;s:57:"Bimer\Test\IncomeTest::testGetIncomeById with data set #0";d:2.567;s:59:"Bimer\Test\IncomeTest::testMakeIncomeBatch with data set #0";d:35.599;s:63:"Bimer\Test\AccountInformationTest::it_should_get_by_description";d:4.883;s:54:"Bimer\Test\AccountInformationTest::it_should_get_by_id";d:0.297;s:53:"Bimer\Test\AreaTypeTest::it_should_get_by_description";d:0.291;s:44:"Bimer\Test\AreaTypeTest::it_should_get_by_id";d:0.521;s:57:"Bimer\Test\BimerTest::it_should_get_vars_from_environment";d:0.001;s:41:"Bimer\Test\BimerTest::it_should_set_token";d:0;s:56:"Bimer\Test\CustomerTest::it_should_not_create_a_resource";d:0.007;s:69:"Bimer\Test\PersonCharacteristicTest::it_should_retrieve_all_resources";d:15.02;s:46:"Bimer\Test\PersonTest::it_should_validate_name";d:0.006;s:49:"Bimer\Test\PersonTest::it_should_retrieve_by_name";d:15.014;s:50:"Bimer\Test\PersonTest::it_should_validate_cpf_cnpj";d:0.007;s:50:"Bimer\Test\PersonTest::it_should_create_a_resource";d:10.006;s:58:"Bimer\Test\PersonTest::it_should_retrieve_none_by_cpf_cnpj";d:10.012;s:58:"Bimer\Test\PersonTest::it_should_retrieve_some_by_cpf_cnpj";d:10.01;s:50:"Bimer\Test\PersonTest::it_should_find_one_resource";d:0;s:47:"Bimer\Test\PersonTest::it_should_update_address";d:0;s:50:"Bimer\Test\PostalCodeTest::it_should_validate_code";d:0.006;s:48:"Bimer\Test\PostalCodeTest::it_should_get_by_code";d:0.033;s:55:"Bimer\Test\AccountInformationTest::testGetByDescription";d:0.001;s:46:"Bimer\Test\AccountInformationTest::testGetById";d:0;s:72:"Bimer\Test\AccountInformationTest::testGetByDescription with data set #0";d:5.484;s:63:"Bimer\Test\AccountInformationTest::testGetById with data set #0";d:0.486;s:62:"Bimer\Test\AreaTypeTest::testGetByDescription with data set #0";d:0.277;s:35:"Bimer\Test\IncomeTest::testEndpoint";d:0;s:47:"Bimer\Test\AccountInformationTest::testEndpoint";d:0.001;s:53:"Bimer\Test\AreaTypeTest::testGetById with data set #0";d:0.264;s:37:"Bimer\Test\AreaTypeTest::testEndpoint";d:0;s:44:"Bimer\Test\BimerTest::testSetBimerParameters";d:0.001;s:35:"Bimer\Test\BimerTest::setBimerToken";d:0;s:43:"Bimer\Test\CustomerTest::testCreateCustomer";d:0.002;s:37:"Bimer\Test\CustomerTest::testEndpoint";d:0;s:49:"Bimer\Test\PersonCharacteristicTest::testGetArray";d:6.446;s:49:"Bimer\Test\PersonCharacteristicTest::testEndpoint";d:0;s:39:"Bimer\Test\PersonTest::testValidateName";d:0.002;s:36:"Bimer\Test\PersonTest::testGetByName";d:5.438;s:42:"Bimer\Test\PersonTest::testValidateCpfCnpj";d:0.001;s:39:"Bimer\Test\PersonTest::testCreatePerson";d:1.182;s:42:"Bimer\Test\PersonTest::testGetEmptyCpfCnpj";d:0.271;s:41:"Bimer\Test\PersonTest::testGetSomeCpfCnpj";d:0.498;s:34:"Bimer\Test\PersonTest::testGetById";d:0.001;s:40:"Bimer\Test\PersonTest::testUpdateAddress";d:0.61;s:35:"Bimer\Test\PersonTest::testEndpoint";d:0;s:43:"Bimer\Test\PostalCodeTest::testValidateCode";d:0;s:40:"Bimer\Test\PostalCodeTest::testGetByCode";d:0.294;s:39:"Bimer\Test\PostalCodeTest::testEndpoint";d:0;s:56:"Bimer\Test\PersonTest::testCreatePerson with data set #0";d:0.646;s:60:"Bimer\Test\PersonTest::testChangePersonData with data set #0";d:1.438;s:51:"Bimer\Test\PersonTest::testGetById with data set #0";d:1.071;}}} \ No newline at end of file diff --git a/README.md b/README.md index d75b661..b86399e 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ try { ## Testes -Caso queira contribuir, por favor, implementar testes de unidade em PHPUnit. +Caso queira contribuir, por favor, implementar testes em PHPUnit. Para executar: 1) Faça uma cópia de phpunit.xml.dist em phpunit.xml na raíz do projeto diff --git a/composer.json b/composer.json index fc919d8..078baa6 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,6 @@ } }, "scripts": { - "test": "phpunit" + "test": "phpunit --testdox" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 213c8cd..68c232d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -27,6 +27,11 @@ - + + + + + +