mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Merge branch 'master' into nested-higher-order-expectations
# Conflicts: # tests/.snapshots/success.txt
This commit is contained in:
1
.github/FUNDING.yml
vendored
1
.github/FUNDING.yml
vendored
@ -2,4 +2,3 @@
|
|||||||
|
|
||||||
github: [nunomaduro,owenvoke,olivernybroe,octoper]
|
github: [nunomaduro,owenvoke,olivernybroe,octoper]
|
||||||
patreon: nunomaduro
|
patreon: nunomaduro
|
||||||
custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L
|
|
||||||
|
|||||||
@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
## [v1.6.0 (2021-06-18)](https://github.com/pestphp/pest/compare/v1.5.0...v1.6.0)
|
||||||
|
### Added
|
||||||
|
- Adds a new `json` expectation method to improve testing with JSON strings ([#325](https://github.com/pestphp/pest/pull/325))
|
||||||
|
- Adds dot notation support to the `toHaveKey` and `toHaveKeys` expectations ([#322](https://github.com/pestphp/pest/pull/322))
|
||||||
|
|
||||||
## [v1.5.0 (2021-06-15)](https://github.com/pestphp/pest/compare/v1.4.0...v1.5.0)
|
## [v1.5.0 (2021-06-15)](https://github.com/pestphp/pest/compare/v1.4.0...v1.5.0)
|
||||||
### Changed
|
### Changed
|
||||||
- Moves plugins from the `require` section to the core itself ([#317](https://github.com/pestphp/pest/pull/317)), ([#318](https://github.com/pestphp/pest/pull/318)), ([#320](https://github.com/pestphp/pest/pull/320))
|
- Moves plugins from the `require` section to the core itself ([#317](https://github.com/pestphp/pest/pull/317)), ([#318](https://github.com/pestphp/pest/pull/318)), ([#320](https://github.com/pestphp/pest/pull/320))
|
||||||
|
|||||||
@ -64,6 +64,14 @@ final class Expectation
|
|||||||
return new self($value);
|
return new self($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new expectation with the decoded JSON value.
|
||||||
|
*/
|
||||||
|
public function json(): Expectation
|
||||||
|
{
|
||||||
|
return $this->toBeJson()->and(json_decode($this->value, true));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump the expectation value and end the script.
|
* Dump the expectation value and end the script.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '1.5.0';
|
return '1.6.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
@ -111,11 +111,9 @@
|
|||||||
✓ it works inside of each
|
✓ it works inside of each
|
||||||
✓ it works with sequence
|
✓ it works with sequence
|
||||||
✓ it can compose complex expectations
|
✓ it can compose complex expectations
|
||||||
✓ it can handle nested method calls
|
|
||||||
|
|
||||||
PASS Tests\Features\Expect\HigherOrder\methodsAndProperties
|
PASS Tests\Features\Expect\HigherOrder\methodsAndProperties
|
||||||
✓ it can access methods and properties
|
✓ it can access methods and properties
|
||||||
✓ it can handle nested methods and properties
|
|
||||||
|
|
||||||
PASS Tests\Features\Expect\HigherOrder\properties
|
PASS Tests\Features\Expect\HigherOrder\properties
|
||||||
✓ it allows properties to be accessed from the value
|
✓ it allows properties to be accessed from the value
|
||||||
@ -126,7 +124,6 @@
|
|||||||
✓ it works with sequence
|
✓ it works with sequence
|
||||||
✓ it can compose complex expectations
|
✓ it can compose complex expectations
|
||||||
✓ it works with objects
|
✓ it works with objects
|
||||||
✓ it works with nested properties
|
|
||||||
|
|
||||||
PASS Tests\Features\Expect\each
|
PASS Tests\Features\Expect\each
|
||||||
✓ an exception is thrown if the the type is not iterable
|
✓ an exception is thrown if the the type is not iterable
|
||||||
@ -143,6 +140,10 @@
|
|||||||
✓ it macros true is true with argument
|
✓ it macros true is true with argument
|
||||||
✓ it macros false is not true with argument
|
✓ it macros false is not true with argument
|
||||||
|
|
||||||
|
PASS Tests\Features\Expect\json
|
||||||
|
✓ it properly parses json string
|
||||||
|
✓ fails with broken json string
|
||||||
|
|
||||||
PASS Tests\Features\Expect\not
|
PASS Tests\Features\Expect\not
|
||||||
✓ not property calls
|
✓ not property calls
|
||||||
|
|
||||||
@ -572,5 +573,5 @@
|
|||||||
✓ it is a test
|
✓ it is a test
|
||||||
✓ it uses correct parent class
|
✓ it uses correct parent class
|
||||||
|
|
||||||
Tests: 4 incompleted, 7 skipped, 358 passed
|
Tests: 4 incompleted, 7 skipped, 357 passed
|
||||||
|
|
||||||
14
tests/Features/Expect/json.php
Normal file
14
tests/Features/Expect/json.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
|
test('it properly parses json string', function () {
|
||||||
|
expect('{"name":"Nuno"}')
|
||||||
|
->json()
|
||||||
|
->name
|
||||||
|
->toBe('Nuno');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('fails with broken json string', function () {
|
||||||
|
expect('{":"Nuno"}')->json();
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
Reference in New Issue
Block a user