mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 049ce1845e | |||
| faa6cd7deb | |||
| 1f9362c4e7 | |||
| be8a64e4b8 | |||
| 2336bc0f65 | |||
| da82eecbae | |||
| 4855987ba8 | |||
| a493db1873 | |||
| 4f677a6cc2 | |||
| 228f2deb64 | |||
| 0fadf9a02c | |||
| 2b138ad76b | |||
| e3e4815b55 | |||
| f76f353c32 | |||
| 16b9f54dc3 | |||
| 281166475e | |||
| 23805cb5d6 | |||
| 76d0f9cfc1 | |||
| 5b083e4eb1 | |||
| f48694b18a | |||
| 8fa59ddbf0 | |||
| 2619db4026 | |||
| f3a71fb100 | |||
| 04fafe742c | |||
| cad8a41e6d |
2
.github/workflows/changelog.yml
vendored
2
.github/workflows/changelog.yml
vendored
@ -13,6 +13,8 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: github.repository == 'pestphp/pest'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Checkout website repository
|
||||
|
||||
20
CHANGELOG.md
20
CHANGELOG.md
@ -6,6 +6,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [v0.3.8 (2020-10-03)](https://github.com/pestphp/pest/compare/v0.3.7...v0.3.8)
|
||||
### Added
|
||||
- Add support for PHPUnit 9.4.0 ([#199](https://github.com/pestphp/pest/pull/199))
|
||||
|
||||
### Fixed
|
||||
- Fix chained higher order assertions returning void ([#196](https://github.com/pestphp/pest/pull/196))
|
||||
|
||||
## [v0.3.7 (2020-09-30)](https://github.com/pestphp/pest/compare/v0.3.6...v0.3.7)
|
||||
### Added
|
||||
- Add support for PHPUnit 9.3.11 ([#193](https://github.com/pestphp/pest/pull/193))
|
||||
|
||||
## [v0.3.6 (2020-09-21)](https://github.com/pestphp/pest/compare/v0.3.5...v0.3.6)
|
||||
### Added
|
||||
- `toMatch` expectation ([#191](https://github.com/pestphp/pest/pull/191))
|
||||
- `toMatchConstraint` expectation ([#190](https://github.com/pestphp/pest/pull/190))
|
||||
|
||||
## [v0.3.5 (2020-09-16)](https://github.com/pestphp/pest/compare/v0.3.4...v0.3.5)
|
||||
### Added
|
||||
- `toStartWith` and `toEndWith` expectations ([#187](https://github.com/pestphp/pest/pull/187))
|
||||
|
||||
## [v0.3.4 (2020-09-15)](https://github.com/pestphp/pest/compare/v0.3.3...v0.3.4)
|
||||
### Added
|
||||
- `toMatchObject` expectation ([4e184b2](https://github.com/pestphp/pest/commit/4e184b2f906c318a5e9cd38fe693cdab5c48d8a2))
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
"pestphp/pest-plugin": "^0.3",
|
||||
"pestphp/pest-plugin-coverage": "^0.3",
|
||||
"pestphp/pest-plugin-init": "^0.3",
|
||||
"phpunit/phpunit": "9.3.7 || 9.3.8 || 9.3.9 || 9.3.10"
|
||||
"phpunit/phpunit": ">= 9.3.7 <= 9.4.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Pest;
|
||||
|
||||
use PHPUnit\Framework\Assert;
|
||||
use PHPUnit\Framework\Constraint\Constraint;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -158,6 +159,26 @@ final class Expectation
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the value starts with $expected.
|
||||
*/
|
||||
public function toStartWith(string $expected): Expectation
|
||||
{
|
||||
Assert::assertStringStartsWith($expected, $this->value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the value ends with $expected.
|
||||
*/
|
||||
public function toEndWith(string $expected): Expectation
|
||||
{
|
||||
Assert::assertStringEndsWith($expected, $this->value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that $count matches the number of elements of the value.
|
||||
*/
|
||||
@ -484,6 +505,26 @@ final class Expectation
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the value matches a regular expression.
|
||||
*/
|
||||
public function toMatch(string $expression): Expectation
|
||||
{
|
||||
Assert::assertMatchesRegularExpression($expression, $this->value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the value matches a constraint.
|
||||
*/
|
||||
public function toMatchConstraint(Constraint $constraint): Expectation
|
||||
{
|
||||
Assert::assertThat($this->value, $constraint);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically calls methods on the class without any arguments.
|
||||
*
|
||||
|
||||
@ -6,5 +6,5 @@ namespace Pest;
|
||||
|
||||
function version(): string
|
||||
{
|
||||
return '0.3.1';
|
||||
return '0.3.6';
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ final class HigherOrderMessageCollection
|
||||
public function chain(object $target): void
|
||||
{
|
||||
foreach ($this->messages as $message) {
|
||||
$target = $message->call($target);
|
||||
$target = $message->call($target) ?? $target;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -155,6 +155,11 @@
|
||||
✓ passes strings
|
||||
✓ passes arrays
|
||||
✓ failures
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Expect\toEndWith
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Expect\toEqual
|
||||
@ -190,11 +195,26 @@
|
||||
PASS Tests\Expect\toHaveProperty
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Expect\toMatch
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Expect\toMatchConstraint
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Expect\toMatchObject
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Expect\toStartWith
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\AfterAll
|
||||
@ -258,6 +278,7 @@
|
||||
|
||||
PASS Tests\Features\HigherOrderTests
|
||||
✓ it proxies calls to object
|
||||
✓ it is capable doing multiple assertions
|
||||
|
||||
PASS Tests\Features\It
|
||||
✓ it is a test
|
||||
@ -282,6 +303,7 @@
|
||||
- it skips with truthy closure condition
|
||||
✓ it do not skips with falsy closure condition
|
||||
- it skips with condition and message → skipped because foo
|
||||
- it skips when skip after assertion
|
||||
|
||||
PASS Tests\Features\Test
|
||||
✓ a test
|
||||
@ -363,5 +385,5 @@
|
||||
✓ depends with defined arguments
|
||||
✓ depends run test only once
|
||||
|
||||
Tests: 6 skipped, 214 passed
|
||||
Tests: 7 skipped, 227 passed
|
||||
|
||||
15
tests/Expect/toEndWith.php
Normal file
15
tests/Expect/toEndWith.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('pass', function () {
|
||||
expect('username')->toEndWith('name');
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect('username')->toEndWith('password');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect('username')->not->toEndWith('name');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
15
tests/Expect/toMatch.php
Normal file
15
tests/Expect/toMatch.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('pass', function () {
|
||||
expect('Hello World')->toMatch('/^hello wo.*$/i');
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect('Hello World')->toMatch('/^hello$/i');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect('Hello World')->not->toMatch('/^hello wo.*$/i');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
16
tests/Expect/toMatchConstraint.php
Normal file
16
tests/Expect/toMatchConstraint.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\Constraint\IsTrue;
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('pass', function () {
|
||||
expect(true)->toMatchConstraint(new IsTrue());
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect(false)->toMatchConstraint(new IsTrue());
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect(true)->not->toMatchConstraint(new IsTrue());
|
||||
})->throws(ExpectationFailedException::class);
|
||||
15
tests/Expect/toStartWith.php
Normal file
15
tests/Expect/toStartWith.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('pass', function () {
|
||||
expect('username')->toStartWith('user');
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect('username')->toStartWith('password');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect('username')->not->toStartWith('user');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
@ -4,4 +4,8 @@ beforeEach()->assertTrue(true);
|
||||
|
||||
it('proxies calls to object')->assertTrue(true);
|
||||
|
||||
it('is capable doing multiple assertions')
|
||||
->assertTrue(true)
|
||||
->assertFalse(false);
|
||||
|
||||
afterEach()->assertTrue(true);
|
||||
|
||||
@ -27,3 +27,7 @@ it('do not skips with falsy closure condition')
|
||||
it('skips with condition and message')
|
||||
->skip(true, 'skipped because foo')
|
||||
->assertTrue(false);
|
||||
|
||||
it('skips when skip after assertion')
|
||||
->assertTrue(true)
|
||||
->skip();
|
||||
|
||||
Reference in New Issue
Block a user