mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
if: github.repository == 'pestphp/pest'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Checkout website repository
|
- name: Checkout website repository
|
||||||
|
|||||||
@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [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)
|
## [v0.3.4 (2020-09-15)](https://github.com/pestphp/pest/compare/v0.3.3...v0.3.4)
|
||||||
### Added
|
### Added
|
||||||
- `toMatchObject` expectation ([4e184b2](https://github.com/pestphp/pest/commit/4e184b2f906c318a5e9cd38fe693cdab5c48d8a2))
|
- `toMatchObject` expectation ([4e184b2](https://github.com/pestphp/pest/commit/4e184b2f906c318a5e9cd38fe693cdab5c48d8a2))
|
||||||
|
|||||||
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace Pest;
|
namespace Pest;
|
||||||
|
|
||||||
use PHPUnit\Framework\Assert;
|
use PHPUnit\Framework\Assert;
|
||||||
|
use PHPUnit\Framework\Constraint\Constraint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -158,6 +159,26 @@ final class Expectation
|
|||||||
return $this;
|
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.
|
* Asserts that $count matches the number of elements of the value.
|
||||||
*/
|
*/
|
||||||
@ -484,6 +505,26 @@ final class Expectation
|
|||||||
return $this;
|
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.
|
* Dynamically calls methods on the class without any arguments.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -6,5 +6,5 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '0.3.1';
|
return '0.3.6';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -155,6 +155,11 @@
|
|||||||
✓ passes strings
|
✓ passes strings
|
||||||
✓ passes arrays
|
✓ passes arrays
|
||||||
✓ failures
|
✓ failures
|
||||||
|
✓ not failures
|
||||||
|
|
||||||
|
PASS Tests\Expect\toEndWith
|
||||||
|
✓ pass
|
||||||
|
✓ failures
|
||||||
✓ not failures
|
✓ not failures
|
||||||
|
|
||||||
PASS Tests\Expect\toEqual
|
PASS Tests\Expect\toEqual
|
||||||
@ -190,11 +195,26 @@
|
|||||||
PASS Tests\Expect\toHaveProperty
|
PASS Tests\Expect\toHaveProperty
|
||||||
✓ pass
|
✓ pass
|
||||||
✓ failures
|
✓ failures
|
||||||
|
✓ not failures
|
||||||
|
|
||||||
|
PASS Tests\Expect\toMatch
|
||||||
|
✓ pass
|
||||||
|
✓ failures
|
||||||
|
✓ not failures
|
||||||
|
|
||||||
|
PASS Tests\Expect\toMatchConstraint
|
||||||
|
✓ pass
|
||||||
|
✓ failures
|
||||||
✓ not failures
|
✓ not failures
|
||||||
|
|
||||||
PASS Tests\Expect\toMatchObject
|
PASS Tests\Expect\toMatchObject
|
||||||
✓ pass
|
✓ pass
|
||||||
✓ failures
|
✓ failures
|
||||||
|
✓ not failures
|
||||||
|
|
||||||
|
PASS Tests\Expect\toStartWith
|
||||||
|
✓ pass
|
||||||
|
✓ failures
|
||||||
✓ not failures
|
✓ not failures
|
||||||
|
|
||||||
PASS Tests\Features\AfterAll
|
PASS Tests\Features\AfterAll
|
||||||
@ -363,5 +383,5 @@
|
|||||||
✓ depends with defined arguments
|
✓ depends with defined arguments
|
||||||
✓ depends run test only once
|
✓ depends run test only once
|
||||||
|
|
||||||
Tests: 6 skipped, 214 passed
|
Tests: 6 skipped, 226 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);
|
||||||
Reference in New Issue
Block a user