mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Compare commits
51 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3fbec70ed3 | |||
| d177ab5ec2 | |||
| e4f5a284a6 | |||
| 6671b266da | |||
| 3728bd8e0f | |||
| c3616edbc8 | |||
| 21143b2693 | |||
| 006f9232cc | |||
| d1b61a34de | |||
| 896317ac97 | |||
| 4fd5c0edd4 | |||
| e2c5d6d857 | |||
| 8057fe4bc2 | |||
| ebc9690301 | |||
| 049ce1845e | |||
| faa6cd7deb | |||
| 1f9362c4e7 | |||
| 36fd18bcc8 | |||
| aa352317cb | |||
| edcd2cb50e | |||
| be8a64e4b8 | |||
| 2336bc0f65 | |||
| da82eecbae | |||
| 4855987ba8 | |||
| a493db1873 | |||
| 4f677a6cc2 | |||
| 228f2deb64 | |||
| 0fadf9a02c | |||
| 2b138ad76b | |||
| e3e4815b55 | |||
| f76f353c32 | |||
| 16b9f54dc3 | |||
| 281166475e | |||
| 23805cb5d6 | |||
| 76d0f9cfc1 | |||
| 5b083e4eb1 | |||
| f48694b18a | |||
| 8fa59ddbf0 | |||
| 2619db4026 | |||
| f3a71fb100 | |||
| 04fafe742c | |||
| cad8a41e6d | |||
| 1567923cda | |||
| c7116afcae | |||
| 4e184b2f90 | |||
| 9b5f664f00 | |||
| 0e89525ea8 | |||
| 0b6cdf8f02 | |||
| 5f63d959e1 | |||
| be7fe41179 | |||
| 204f343831 |
21
.github/workflows/changelog.yml
vendored
21
.github/workflows/changelog.yml
vendored
@ -5,6 +5,7 @@ on:
|
|||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
paths:
|
paths:
|
||||||
- CHANGELOG.md
|
- CHANGELOG.md
|
||||||
|
- .github/workflows/changelog.yml
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
paths:
|
paths:
|
||||||
@ -13,19 +14,25 @@ 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
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CHANGELOG_KEY }}
|
token: ${{ secrets.CHANGELOG_KEY }}
|
||||||
repository: pestphp/website
|
repository: pestphp/docs
|
||||||
path: pestphp-website
|
path: pestphp-docs
|
||||||
|
ref: master
|
||||||
|
|
||||||
- name: Read CHANGELOG.md
|
- name: Read CHANGELOG.md
|
||||||
id: package
|
id: package
|
||||||
uses: juliangruber/read-file-action@v1
|
uses: juliangruber/read-file-action@v1
|
||||||
with:
|
with:
|
||||||
path: ./CHANGELOG.md
|
path: ./CHANGELOG.md
|
||||||
|
|
||||||
- name: Add file headers
|
- name: Add file headers
|
||||||
uses: DamianReeves/write-file-action@v1.0
|
uses: DamianReeves/write-file-action@v1.0
|
||||||
with:
|
with:
|
||||||
@ -34,8 +41,6 @@ jobs:
|
|||||||
---
|
---
|
||||||
title: Changelog
|
title: Changelog
|
||||||
description: Changelog
|
description: Changelog
|
||||||
extends: _layouts.documentation
|
|
||||||
section: content
|
|
||||||
---
|
---
|
||||||
${{ steps.package.outputs.content }}
|
${{ steps.package.outputs.content }}
|
||||||
|
|
||||||
@ -43,14 +48,16 @@ jobs:
|
|||||||
|
|
||||||
Next section: [Upgrade Guide →](/docs/upgrade-guide)
|
Next section: [Upgrade Guide →](/docs/upgrade-guide)
|
||||||
write-mode: overwrite
|
write-mode: overwrite
|
||||||
|
|
||||||
- name: Copy CHANGELOG to website repository
|
- name: Copy CHANGELOG to website repository
|
||||||
run: cp CHANGELOG.md pestphp-website/source/docs/changelog.md
|
run: cp CHANGELOG.md pestphp-docs/changelog.md
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v2
|
uses: peter-evans/create-pull-request@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CHANGELOG_KEY }}
|
token: ${{ secrets.CHANGELOG_KEY }}
|
||||||
commit-message: Update changelog.md
|
commit-message: Update changelog.md
|
||||||
committer: GitHub Action <noreply@github.com>
|
committer: GitHub Action <noreply@github.com>
|
||||||
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
|
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
|
||||||
title: 'Update changelog.md'
|
title: 'Update changelog.md'
|
||||||
path: ./pestphp-website
|
path: ./pestphp-docs
|
||||||
|
|||||||
38
CHANGELOG.md
38
CHANGELOG.md
@ -6,6 +6,44 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [v0.3.10 (2020-11-01)](https://github.com/pestphp/pest/compare/v0.3.9...v0.3.10)
|
||||||
|
### Added
|
||||||
|
- Add support for PHPUnit 9.4.2 ([d177ab5](https://github.com/pestphp/pest/commit/d177ab5ec2030c5bb8e418d10834c370c94c433d))
|
||||||
|
|
||||||
|
## [v0.3.9 (2020-10-13)](https://github.com/pestphp/pest/compare/v0.3.8...v0.3.9)
|
||||||
|
### Added
|
||||||
|
- Add support for named datasets in description output ([#134](https://github.com/pestphp/pest/pull/134))
|
||||||
|
- Add Pest version to `--help` output ([#203](https://github.com/pestphp/pest/pull/203))
|
||||||
|
- Add support for PHPUnit 9.4.1 ([#207](https://github.com/pestphp/pest/pull/207))
|
||||||
|
|
||||||
|
## [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))
|
||||||
|
|
||||||
|
## [v0.3.3 (2020-09-13)](https://github.com/pestphp/pest/compare/v0.3.2...v0.3.3)
|
||||||
|
### Added
|
||||||
|
- `toHaveKeys` expectation ([204f343](https://github.com/pestphp/pest/commit/204f343831adc17bb3734553c24fac92d02f27c7))
|
||||||
|
|
||||||
## [v0.3.2 (2020-09-12)](https://github.com/pestphp/pest/compare/v0.3.1...v0.3.2)
|
## [v0.3.2 (2020-09-12)](https://github.com/pestphp/pest/compare/v0.3.1...v0.3.2)
|
||||||
### Added
|
### Added
|
||||||
- Support to PHPUnit 9.3.9, and 9.3.10 ([1318bf9](https://github.com/pestphp/pest/commit/97f98569bc86e8b87f8cde963fe7b4bf5399623b))
|
- Support to PHPUnit 9.3.9, and 9.3.10 ([1318bf9](https://github.com/pestphp/pest/commit/97f98569bc86e8b87f8cde963fe7b4bf5399623b))
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
"pestphp/pest-plugin": "^0.3",
|
"pestphp/pest-plugin": "^0.3",
|
||||||
"pestphp/pest-plugin-coverage": "^0.3",
|
"pestphp/pest-plugin-coverage": "^0.3",
|
||||||
"pestphp/pest-plugin-init": "^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.2"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|||||||
@ -8,8 +8,8 @@
|
|||||||
<directory suffix=".php">./tests</directory>
|
<directory suffix=".php">./tests</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<coverage>
|
<coverage processUncoveredFiles="true">
|
||||||
<include processUncoveredFiles="true">
|
<include>
|
||||||
<directory suffix=".php">./src</directory>
|
<directory suffix=".php">./src</directory>
|
||||||
</include>
|
</include>
|
||||||
</coverage>
|
</coverage>
|
||||||
|
|||||||
@ -11,6 +11,8 @@ use Pest\Actions\ValidatesConfiguration;
|
|||||||
use Pest\Contracts\Plugins\AddsOutput;
|
use Pest\Contracts\Plugins\AddsOutput;
|
||||||
use Pest\Contracts\Plugins\HandlesArguments;
|
use Pest\Contracts\Plugins\HandlesArguments;
|
||||||
use Pest\Plugin\Loader;
|
use Pest\Plugin\Loader;
|
||||||
|
use Pest\Plugins\Version;
|
||||||
|
use Pest\Support\Container;
|
||||||
use Pest\TestSuite;
|
use Pest\TestSuite;
|
||||||
use PHPUnit\Framework\TestSuite as BaseTestSuite;
|
use PHPUnit\Framework\TestSuite as BaseTestSuite;
|
||||||
use PHPUnit\TextUI\Command as BaseCommand;
|
use PHPUnit\TextUI\Command as BaseCommand;
|
||||||
@ -139,4 +141,12 @@ final class Command extends BaseCommand
|
|||||||
|
|
||||||
exit($result);
|
exit($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function showHelp(): void
|
||||||
|
{
|
||||||
|
/** @var Version $version */
|
||||||
|
$version = Container::getInstance()->get(Version::class);
|
||||||
|
$version->handleArguments(['--version']);
|
||||||
|
parent::showHelp();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,10 +77,10 @@ final class Datasets
|
|||||||
$dataSetDescriptions = [];
|
$dataSetDescriptions = [];
|
||||||
$dataSetValues = [];
|
$dataSetValues = [];
|
||||||
|
|
||||||
foreach ($data as $values) {
|
foreach ($data as $key => $values) {
|
||||||
$values = is_array($values) ? $values : [$values];
|
$values = is_array($values) ? $values : [$values];
|
||||||
|
|
||||||
$dataSetDescriptions[] = $description . self::getDataSetDescription($values);
|
$dataSetDescriptions[] = $description . self::getDataSetDescription($key, $values);
|
||||||
$dataSetValues[] = $values;
|
$dataSetValues[] = $values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,12 +104,15 @@ final class Datasets
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param int|string $key
|
||||||
* @param array<int, mixed> $data
|
* @param array<int, mixed> $data
|
||||||
*/
|
*/
|
||||||
private static function getDataSetDescription(array $data): string
|
private static function getDataSetDescription($key, array $data): string
|
||||||
{
|
{
|
||||||
$exporter = new Exporter();
|
$exporter = new Exporter();
|
||||||
|
|
||||||
return \sprintf(' with (%s)', $exporter->shortenedRecursiveExport($data));
|
$nameInsert = is_string($key) ? \sprintf('data set "%s" ', $key) : '';
|
||||||
|
|
||||||
|
return \sprintf(' with %s(%s)', $nameInsert, $exporter->shortenedRecursiveExport($data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.
|
||||||
*/
|
*/
|
||||||
@ -170,11 +191,20 @@ final class Expectation
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that the value contains the property $name.
|
* Asserts that the value contains the property $name.
|
||||||
|
*
|
||||||
|
* @param mixed $value
|
||||||
*/
|
*/
|
||||||
public function toHaveProperty(string $name): Expectation
|
public function toHaveProperty(string $name, $value = null): Expectation
|
||||||
{
|
{
|
||||||
|
$this->toBeObject();
|
||||||
|
|
||||||
Assert::assertTrue(property_exists($this->value, $name));
|
Assert::assertTrue(property_exists($this->value, $name));
|
||||||
|
|
||||||
|
if (func_num_args() > 1) {
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
|
Assert::assertEquals($value, $this->value->{$name});
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,14 +406,30 @@ final class Expectation
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that the value array has the provided $key.
|
* Asserts that the value array has the provided $key.
|
||||||
|
*
|
||||||
|
* @param string|int $key
|
||||||
*/
|
*/
|
||||||
public function toHaveKey(string $key): Expectation
|
public function toHaveKey($key): Expectation
|
||||||
{
|
{
|
||||||
Assert::assertArrayHasKey($key, $this->value);
|
Assert::assertArrayHasKey($key, $this->value);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the value array has the provided $keys.
|
||||||
|
*
|
||||||
|
* @param array<int, int|string> $keys
|
||||||
|
*/
|
||||||
|
public function toHaveKeys(array $keys): Expectation
|
||||||
|
{
|
||||||
|
foreach ($keys as $key) {
|
||||||
|
$this->toHaveKey($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that the value is a directory.
|
* Asserts that the value is a directory.
|
||||||
*/
|
*/
|
||||||
@ -444,6 +490,41 @@ final class Expectation
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the value object matches a subset
|
||||||
|
* of the properties of an given object.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed>|object $object
|
||||||
|
*/
|
||||||
|
public function toMatchObject($object): Expectation
|
||||||
|
{
|
||||||
|
foreach ((array) $object as $property => $value) {
|
||||||
|
$this->toHaveProperty($property, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
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.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -27,6 +27,26 @@ final class OppositeExpectation
|
|||||||
$this->original = $original;
|
$this->original = $original;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the value array not has the provided $keys.
|
||||||
|
*
|
||||||
|
* @param array<int, int|string> $keys
|
||||||
|
*/
|
||||||
|
public function toHaveKeys(array $keys): Expectation
|
||||||
|
{
|
||||||
|
foreach ($keys as $key) {
|
||||||
|
try {
|
||||||
|
$this->original->toHaveKey($key);
|
||||||
|
} catch (ExpectationFailedException $e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->throwExpectationFailedExpection('toHaveKey', [$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->original;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle dynamic method calls into the original expectation.
|
* Handle dynamic method calls into the original expectation.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -6,5 +6,5 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '0.3.1';
|
return '0.3.9';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,7 @@ final class HigherOrderMessageCollection
|
|||||||
public function chain(object $target): void
|
public function chain(object $target): void
|
||||||
{
|
{
|
||||||
foreach ($this->messages as $message) {
|
foreach ($this->messages as $message) {
|
||||||
$target = $message->call($target);
|
$target = $message->call($target) ?? $target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,10 +12,10 @@
|
|||||||
<directory suffix="Test.php">./tests/Feature</directory>
|
<directory suffix="Test.php">./tests/Feature</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<filter>
|
<coverage processUncoveredFiles="true">
|
||||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
<include>
|
||||||
<directory suffix=".php">./app</directory>
|
<directory suffix=".php">./app</directory>
|
||||||
<directory suffix=".php">./src</directory>
|
<directory suffix=".php">./src</directory>
|
||||||
</whitelist>
|
</include>
|
||||||
</filter>
|
</coverage>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
<directory suffix="Test.php">./tests</directory>
|
<directory suffix="Test.php">./tests</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<filter>
|
<coverage processUncoveredFiles="true">
|
||||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
<include>
|
||||||
<directory suffix=".php">./app</directory>
|
<directory suffix=".php">./app</directory>
|
||||||
</whitelist>
|
</include>
|
||||||
</filter>
|
</coverage>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|||||||
@ -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
|
||||||
@ -180,11 +185,36 @@
|
|||||||
PASS Tests\Expect\toHaveKey
|
PASS Tests\Expect\toHaveKey
|
||||||
✓ pass
|
✓ pass
|
||||||
✓ failures
|
✓ failures
|
||||||
|
✓ not failures
|
||||||
|
|
||||||
|
PASS Tests\Expect\toHaveKeys
|
||||||
|
✓ pass
|
||||||
|
✓ failures
|
||||||
✓ not failures
|
✓ not failures
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
PASS Tests\Expect\toMatchObject
|
||||||
|
✓ pass
|
||||||
|
✓ failures
|
||||||
|
✓ not failures
|
||||||
|
|
||||||
|
PASS Tests\Expect\toStartWith
|
||||||
|
✓ pass
|
||||||
|
✓ failures
|
||||||
✓ not failures
|
✓ not failures
|
||||||
|
|
||||||
PASS Tests\Features\AfterAll
|
PASS Tests\Features\AfterAll
|
||||||
@ -225,6 +255,9 @@
|
|||||||
✓ eager wrapped registered datasets with (1)
|
✓ eager wrapped registered datasets with (1)
|
||||||
✓ eager wrapped registered datasets with (2)
|
✓ eager wrapped registered datasets with (2)
|
||||||
✓ eager registered wrapped datasets did the job right
|
✓ eager registered wrapped datasets did the job right
|
||||||
|
✓ named datasets with data set "one" (1)
|
||||||
|
✓ named datasets with data set "two" (2)
|
||||||
|
✓ named datasets did the job right
|
||||||
✓ lazy named datasets with (Bar Object (...))
|
✓ lazy named datasets with (Bar Object (...))
|
||||||
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), true) #1
|
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), true) #1
|
||||||
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), true) #2
|
✓ it creates unique test case names with ('Name 1', Pest\Plugin Object (), true) #2
|
||||||
@ -248,6 +281,7 @@
|
|||||||
|
|
||||||
PASS Tests\Features\HigherOrderTests
|
PASS Tests\Features\HigherOrderTests
|
||||||
✓ it proxies calls to object
|
✓ it proxies calls to object
|
||||||
|
✓ it is capable doing multiple assertions
|
||||||
|
|
||||||
PASS Tests\Features\It
|
PASS Tests\Features\It
|
||||||
✓ it is a test
|
✓ it is a test
|
||||||
@ -272,6 +306,7 @@
|
|||||||
- it skips with truthy closure condition
|
- it skips with truthy closure condition
|
||||||
✓ it do not skips with falsy closure condition
|
✓ it do not skips with falsy closure condition
|
||||||
- it skips with condition and message → skipped because foo
|
- it skips with condition and message → skipped because foo
|
||||||
|
- it skips when skip after assertion
|
||||||
|
|
||||||
PASS Tests\Features\Test
|
PASS Tests\Features\Test
|
||||||
✓ a test
|
✓ a test
|
||||||
@ -313,6 +348,9 @@
|
|||||||
✓ it throws exception when `process isolation` is true
|
✓ it throws exception when `process isolation` is true
|
||||||
✓ it do not throws exception when `process isolation` is false
|
✓ it do not throws exception when `process isolation` is false
|
||||||
|
|
||||||
|
PASS Tests\Unit\Datasets
|
||||||
|
✓ it show the names of named datasets in their description
|
||||||
|
|
||||||
PASS Tests\Unit\Plugins\Version
|
PASS Tests\Unit\Plugins\Version
|
||||||
✓ it outputs the version when --version is used
|
✓ it outputs the version when --version is used
|
||||||
✓ it do not outputs version when --version is not used
|
✓ it do not outputs version when --version is not used
|
||||||
@ -353,5 +391,5 @@
|
|||||||
✓ depends with defined arguments
|
✓ depends with defined arguments
|
||||||
✓ depends run test only once
|
✓ depends run test only once
|
||||||
|
|
||||||
Tests: 6 skipped, 208 passed
|
Tests: 7 skipped, 231 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/toHaveKeys.php
Normal file
15
tests/Expect/toHaveKeys.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
|
test('pass', function () {
|
||||||
|
expect(['a' => 1, 'b', 'c' => 'world'])->toHaveKeys(['a', 'c']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('failures', function () {
|
||||||
|
expect(['a' => 1, 'b', 'c' => 'world'])->toHaveKeys(['a', 'd']);
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
|
test('not failures', function () {
|
||||||
|
expect(['a' => 1, 'hello' => 'world', 'c'])->not->toHaveKeys(['hello', 'c']);
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
@ -2,11 +2,15 @@
|
|||||||
|
|
||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
$obj->foo = 'bar';
|
$obj->foo = 'bar';
|
||||||
|
$obj->fooNull = null;
|
||||||
|
|
||||||
test('pass', function () use ($obj) {
|
test('pass', function () use ($obj) {
|
||||||
expect($obj)->toHaveProperty('foo');
|
expect($obj)->toHaveProperty('foo');
|
||||||
|
expect($obj)->toHaveProperty('foo', 'bar');
|
||||||
|
expect($obj)->toHaveProperty('fooNull');
|
||||||
|
expect($obj)->toHaveProperty('fooNull', null);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('failures', function () use ($obj) {
|
test('failures', function () use ($obj) {
|
||||||
|
|||||||
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);
|
||||||
31
tests/Expect/toMatchObject.php
Normal file
31
tests/Expect/toMatchObject.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
$this->user = (object) [
|
||||||
|
'id' => 1,
|
||||||
|
'name' => 'Nuno',
|
||||||
|
'email' => 'enunomaduro@gmail.com',
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
test('pass', function () {
|
||||||
|
expect($this->user)->toMatchObject([
|
||||||
|
'name' => 'Nuno',
|
||||||
|
'email' => 'enunomaduro@gmail.com',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('failures', function () {
|
||||||
|
expect($this->user)->toMatchObject([
|
||||||
|
'name' => 'Not the same name',
|
||||||
|
'email' => 'enunomaduro@gmail.com',
|
||||||
|
]);
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
|
test('not failures', function () {
|
||||||
|
expect($this->user)->not->toMatchObject([
|
||||||
|
'id' => 1,
|
||||||
|
]);
|
||||||
|
})->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);
|
||||||
@ -95,6 +95,18 @@ test('eager registered wrapped datasets did the job right', function () use ($st
|
|||||||
expect($state->text)->toBe('1212121212');
|
expect($state->text)->toBe('1212121212');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('named datasets', function ($text) use ($state, $datasets) {
|
||||||
|
$state->text .= $text;
|
||||||
|
expect($datasets)->toContain([$text]);
|
||||||
|
})->with([
|
||||||
|
'one' => [1],
|
||||||
|
'two' => [2],
|
||||||
|
]);
|
||||||
|
|
||||||
|
test('named datasets did the job right', function () use ($state) {
|
||||||
|
expect($state->text)->toBe('121212121212');
|
||||||
|
});
|
||||||
|
|
||||||
class Bar
|
class Bar
|
||||||
{
|
{
|
||||||
public $name = 1;
|
public $name = 1;
|
||||||
|
|||||||
@ -4,4 +4,8 @@ beforeEach()->assertTrue(true);
|
|||||||
|
|
||||||
it('proxies calls to object')->assertTrue(true);
|
it('proxies calls to object')->assertTrue(true);
|
||||||
|
|
||||||
|
it('is capable doing multiple assertions')
|
||||||
|
->assertTrue(true)
|
||||||
|
->assertFalse(false);
|
||||||
|
|
||||||
afterEach()->assertTrue(true);
|
afterEach()->assertTrue(true);
|
||||||
|
|||||||
@ -27,3 +27,7 @@ it('do not skips with falsy closure condition')
|
|||||||
it('skips with condition and message')
|
it('skips with condition and message')
|
||||||
->skip(true, 'skipped because foo')
|
->skip(true, 'skipped because foo')
|
||||||
->assertTrue(false);
|
->assertTrue(false);
|
||||||
|
|
||||||
|
it('skips when skip after assertion')
|
||||||
|
->assertTrue(true)
|
||||||
|
->skip();
|
||||||
|
|||||||
13
tests/Unit/Datasets.php
Normal file
13
tests/Unit/Datasets.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Pest\Datasets;
|
||||||
|
|
||||||
|
it('show the names of named datasets in their description', function () {
|
||||||
|
$descriptions = array_keys(Datasets::resolve('test description', [
|
||||||
|
'one' => [1],
|
||||||
|
'two' => [[2]],
|
||||||
|
]));
|
||||||
|
|
||||||
|
expect($descriptions[0])->toBe('test description with data set "one" (1)');
|
||||||
|
expect($descriptions[1])->toBe('test description with data set "two" (array(2))');
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user