Skip to content

Requests: set default transports as a constant#541

Merged
schlessera merged 1 commit intodevelopfrom
feature/513-6-unify-dataprovider-for-tests
Sep 17, 2021
Merged

Requests: set default transports as a constant#541
schlessera merged 1 commit intodevelopfrom
feature/513-6-unify-dataprovider-for-tests

Conversation

@jrfnl
Copy link
Copy Markdown
Member

@jrfnl jrfnl commented Sep 17, 2021

The default supported transports do not change during the request, so should be a constant and as the minimum PHP version is now PHP 5.6, we can use constant arrays.

I've elected to set this array with the same value for key and value to allow using isset() against the array.
I've also adjusted the Requests::add_transport() method to set the key as well, which automatically allows us to get rid of the expensive and unnecessary array_merge().

The list of supported constants was also used in multiple (duplicate) data providers in the tests.
This duplication has been removed by adding this data provider to the base TestCase, making it available to all tests.

The data provider in the base TestCase:

  • Makes use of the new constant to always provide the list of all supported transport classes.
  • Has been set up to provide named data sets to allow for more descriptive tests when running the tests using --testdox and for easier debugging.

Part of a PR series to address #513

The default supported transports do not change during the request, so should be a constant and as the minimum PHP version is now PHP 5.6, we can use constant arrays.

I've elected to set this array with the same value for key and value to allow using `isset()` against the array.
I've also adjusted the `Requests::add_transport()` method to set the key as well, which automatically allows us to get rid of the expensive and unnecessary `array_merge()`.

The list of supported constants was also used in multiple (duplicate) data providers in the tests.
This duplication has been removed by adding this data provider to the base `TestCase`, making it available to all tests.

The data provider in the base `TestCase`:
* Makes use of the new constant to always provide the list of all supported transport classes.
* Has been set up to provide named data sets to allow for more descriptive tests when running the tests using `--testdox` and for easier debugging.
@jrfnl jrfnl force-pushed the feature/513-6-unify-dataprovider-for-tests branch from abe982d to e21107c Compare September 17, 2021 10:04
@schlessera schlessera merged commit 01a6174 into develop Sep 17, 2021
@schlessera schlessera deleted the feature/513-6-unify-dataprovider-for-tests branch September 17, 2021 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants