crowdin / crowdin-api-client-php

PHP client library for Crowdin API
https://packagist.org/packages/crowdin/crowdin-api-client
MIT License
58 stars 31 forks source link

AbstractTestApi::mockRequest fails to assert body & header #149

Closed pdelre closed 1 year ago

pdelre commented 1 year ago

The two AbstractTestApi::mockRequest implementations have a bug (likely typo) where it will never assert the called body & header as the assertion is testing the same values ($params['body'] vs $params['body']).

https://github.com/crowdin/crowdin-api-client-php/blob/811b26ffa5335671c4b27eb38f8f18891ade8c14/tests/CrowdinApiClient/Api/AbstractTestApi.php#L46-L51 https://github.com/crowdin/crowdin-api-client-php/blob/811b26ffa5335671c4b27eb38f8f18891ade8c14/tests/CrowdinApiClient/Api/Enterprise/AbstractTestApi.php#L47-L52

This is masking 41 failures:

$ docker run -v $(pwd):/app --rm php:8.1-cli bash -c "cd app && vendor/bin/phpunit"
PHPUnit 9.6.13 by Sebastian Bergmann and contributors.

Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

..F....F...F....F..F....F....F..F.....F...F..........F.F...F...  63 / 396 ( 15%)
F...F..F....F.........F..F................F......F..F.F...F.... 126 / 396 ( 31%)
..F.......FE.F......F.F.F....F..F......F......FF..F.....F...... 189 / 396 ( 47%)
....F...F.F............F....................................... 252 / 396 ( 63%)
............................................................... 315 / 396 ( 79%)
............................................................... 378 / 396 ( 95%)
..................                                              396 / 396 (100%)

Time: 00:00.798, Memory: 18.00 MB
#...
ERRORS!
Tests: 396, Assertions: 1819, Errors: 1, Failures: 41.
pdelre commented 1 year ago

FYI, most of these failed tests quite minor issues with the test themselves (comparing an array to a string containing json). A small number are issues with the Api implementations themselves.

I'll have a PR next week to resolve.

andrii-bodnar commented 1 year ago

@pdelre nice catch, thanks for pointing that out! We'd be happy to accept a PR :)