Skip to content

Commit

Permalink
Abstract HTTP requests in testing to standalone class (#505)
Browse files Browse the repository at this point in the history
* Abstract the logic that makes HTTP requests during testing to an isolated class to prevent confusion when chaining headers/cookies

* Reduce the number of imports

* Include conditional trait to allow fluent chaining

* Change to property read

* Docblocks

* One more return type

* CHANGELOG

* CHANGELOG
  • Loading branch information
srtfisher committed Mar 6, 2024
1 parent 2ddbc81 commit c34fc22
Show file tree
Hide file tree
Showing 7 changed files with 893 additions and 520 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added support for PHP 8.3.
- PHPUnit 10 support added and `nunomaduro/collision` depend on to v6-7.

**Upgrade Note:** When upgrading to Mantle v1 projects will receive PHPUnit 10
Expand All @@ -31,6 +32,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Overhauled queue performance and added admin interface.
- Tests that make requests using `$this->get()` and other HTTP methods will now
use a fluent pending request class `Mantle\Testing\Pending_Testable_Request`
to allow for more complex request building.

### Removed

Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
backupGlobals="false"
colors="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
displayDetailsOnTestsThatTriggerDeprecations="true"
>
<testsuites>
<testsuite name="mantle-framework">
Expand Down
13 changes: 10 additions & 3 deletions src/mantle/support/traits/trait-enumerates-values.php
Original file line number Diff line number Diff line change
Expand Up @@ -743,12 +743,19 @@ public function collect() {
*/
public function to_array() {
return $this->map(
function ( $value ) {
return $value instanceof Arrayable ? $value->to_array() : $value;
}
fn ( $value ) => $value instanceof Arrayable ? $value->to_array() : $value,
)->all();
}

/**
* Alias for the "to_array" method.
*
* @return array<TKey, TValue>
*/
public function toArray() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
return $this->to_array();
}

/**
* Convert the object into something JSON serializable.
*
Expand Down
Loading

0 comments on commit c34fc22

Please sign in to comment.