mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d1a9e0bbe3 | |||
| 17eacfdf95 | |||
| 9ec0762d41 | |||
| 30f39f1850 | |||
| 8ee07330b3 | |||
| cffde4564d | |||
| ce7a7649a2 | |||
| eeed7e6a0a | |||
| d6844f5239 | |||
| 06c4019e81 | |||
| 7785a8cc58 | |||
| 663516c1e3 | |||
| a5af4bc5ed |
15
.github/workflows/tests.yml
vendored
15
.github/workflows/tests.yml
vendored
@ -5,26 +5,11 @@ on: ['push', 'pull_request']
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: ${{ matrix.os }}
|
||||
continue-on-error: ${{ matrix.experimental }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
php: ['7.3', '7.4', '8.0']
|
||||
dependency-version: [prefer-lowest, prefer-stable]
|
||||
experimental: [false]
|
||||
include:
|
||||
- php: '8.1'
|
||||
os: ubuntu-latest
|
||||
experimental: true
|
||||
dependency-version: prefer-stable
|
||||
- php: '8.1'
|
||||
os: macos-latest
|
||||
experimental: true
|
||||
dependency-version: prefer-stable
|
||||
- php: '8.1'
|
||||
os: windows-latest
|
||||
experimental: true
|
||||
dependency-version: prefer-stable
|
||||
|
||||
name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->in(__DIR__ . DIRECTORY_SEPARATOR . 'tests')
|
||||
->in(__DIR__ . DIRECTORY_SEPARATOR . 'bin')
|
||||
->in(__DIR__ . DIRECTORY_SEPARATOR . 'scripts')
|
||||
->in(__DIR__ . DIRECTORY_SEPARATOR . 'stubs')
|
||||
->in(__DIR__ . DIRECTORY_SEPARATOR . 'src')
|
||||
->append(['.php-cs-fixer.dist.php']);
|
||||
|
||||
@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [v1.15.0 (2021-08-04)](https://github.com/pestphp/pest/compare/v1.14.0...v1.15.0)
|
||||
### Added
|
||||
- `toBeTruthy` and `toBeFalsy` ([#367](https://github.com/pestphp/pest/pull/367))
|
||||
|
||||
## [v1.14.0 (2021-08-03)](https://github.com/pestphp/pest/compare/v1.13.0...v1.14.0)
|
||||
### Added
|
||||
- A new bound closure that allows you to access the test case in Datasets ([#364](https://github.com/pestphp/pest/pull/364))
|
||||
|
||||
@ -6,7 +6,7 @@ When releasing a new version of Pest there are some checks and updates that need
|
||||
- On the GitHub repository, check the contents of [github.com/pestphp/pest/compare/{latest_version}...master](https://github.com/pestphp/pest/compare/{latest_version}...master) and update the [changelog](CHANGELOG.md) file with the main changes for this release
|
||||
- Update the version number in [src/Pest.php](src/Pest.php)
|
||||
- Run the tests locally using: `composer test`
|
||||
- Commit the CHANGELOG and Pest file with the message: `git commit -m "docs: update changelog"`
|
||||
- Commit the CHANGELOG and Pest file with the message: `git commit -m "release: vX.X.X"`
|
||||
- Push the changes to GitHub
|
||||
- Check that the CI is passing as expected: [github.com/pestphp/pest/actions](https://github.com/pestphp/pest/actions)
|
||||
- Tag and push the tag with `git tag vX.X.X && git push --tags`
|
||||
|
||||
4
bin/pest
4
bin/pest
@ -27,7 +27,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
(new Provider())->register();
|
||||
|
||||
// get $rootPath based on $autoloadPath
|
||||
// Get $rootPath based on $autoloadPath
|
||||
$rootPath = dirname($autoloadPath, 2);
|
||||
$argv = new ArgvInput();
|
||||
|
||||
@ -42,7 +42,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
ValidatesEnvironment::in($testSuite);
|
||||
|
||||
// lets remove any arguments that PHPUnit does not understand
|
||||
// Let's remove any arguments that PHPUnit does not understand
|
||||
if ($argv->hasParameterOption('--test-directory')) {
|
||||
foreach ($_SERVER['argv'] as $key => $value) {
|
||||
if (strpos($value, '--test-directory') !== false) {
|
||||
|
||||
@ -7,7 +7,6 @@ parameters:
|
||||
level: max
|
||||
paths:
|
||||
- src
|
||||
- scripts
|
||||
|
||||
checkMissingIterableValueType: true
|
||||
checkGenericClassInNonGenericObjectType: false
|
||||
|
||||
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$globalsFilePath = implode(DIRECTORY_SEPARATOR, [
|
||||
dirname(__DIR__),
|
||||
'vendor',
|
||||
'phpunit',
|
||||
'phpunit',
|
||||
'src',
|
||||
'Framework',
|
||||
'Assert',
|
||||
'Functions.php',
|
||||
]);
|
||||
|
||||
$compiledFilePath = implode(DIRECTORY_SEPARATOR, [dirname(__DIR__), 'compiled', 'globals.php']);
|
||||
|
||||
/* @phpstan-ignore-next-line */
|
||||
@unlink($compiledFilePath);
|
||||
|
||||
$replace = function ($contents, $string, $by) {
|
||||
return str_replace($string, $by, $contents);
|
||||
};
|
||||
|
||||
$remove = function ($contents, $string) {
|
||||
return str_replace($string, '', $contents);
|
||||
};
|
||||
|
||||
$contents = file_get_contents($globalsFilePath);
|
||||
$contents = $replace($contents, 'namespace PHPUnit\Framework;', 'use PHPUnit\Framework\Assert;');
|
||||
$contents = $remove($contents, 'use ArrayAccess;');
|
||||
$contents = $remove($contents, 'use Countable;');
|
||||
$contents = $remove($contents, 'use DOMDocument;');
|
||||
$contents = $remove($contents, 'use DOMElement;');
|
||||
$contents = $remove($contents, 'use Throwable;');
|
||||
|
||||
file_put_contents(implode(DIRECTORY_SEPARATOR, [dirname(__DIR__), 'compiled', 'globals.php']), $contents);
|
||||
@ -22,8 +22,6 @@ final class AddsTests
|
||||
{
|
||||
self::removeTestClosureWarnings($testSuite);
|
||||
|
||||
// @todo refactor this...
|
||||
|
||||
$testSuites = [];
|
||||
$pestTestSuite->tests->build($pestTestSuite, function (TestCase $testCase) use (&$testSuites): void {
|
||||
$testCaseClass = get_class($testCase);
|
||||
|
||||
@ -205,6 +205,16 @@ final class Expectation
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the value is truthy.
|
||||
*/
|
||||
public function toBeTruthy(): Expectation
|
||||
{
|
||||
Assert::assertTrue((bool) $this->value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the value is false.
|
||||
*/
|
||||
@ -215,6 +225,16 @@ final class Expectation
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the value is falsy.
|
||||
*/
|
||||
public function toBeFalsy(): Expectation
|
||||
{
|
||||
Assert::assertFalse((bool) $this->value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the value is greater than $expected.
|
||||
*
|
||||
|
||||
@ -6,7 +6,7 @@ namespace Pest;
|
||||
|
||||
function version(): string
|
||||
{
|
||||
return '1.14.0';
|
||||
return '1.15.0';
|
||||
}
|
||||
|
||||
function testDirectory(string $file = ''): string
|
||||
|
||||
@ -206,6 +206,20 @@
|
||||
PASS Tests\Features\Expect\toBeFalse
|
||||
✓ strict comparisons
|
||||
✓ failures
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeFalsy
|
||||
✓ passes as falsy with (false)
|
||||
✓ passes as falsy with ('')
|
||||
✓ passes as falsy with (null)
|
||||
✓ passes as falsy with (0)
|
||||
✓ passes as falsy with ('0')
|
||||
✓ passes as not falsy with (true)
|
||||
✓ passes as not falsy with (1) #1
|
||||
✓ passes as not falsy with ('false')
|
||||
✓ passes as not falsy with (1) #2
|
||||
✓ passes as not falsy with (-1)
|
||||
✓ failures
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeFile
|
||||
@ -316,6 +330,20 @@
|
||||
PASS Tests\Features\Expect\toBeTrue
|
||||
✓ strict comparisons
|
||||
✓ failures
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeTruthy
|
||||
✓ passes as truthy with (true)
|
||||
✓ passes as truthy with (1) #1
|
||||
✓ passes as truthy with ('false')
|
||||
✓ passes as truthy with (1) #2
|
||||
✓ passes as truthy with (-1)
|
||||
✓ passes as not truthy with (false)
|
||||
✓ passes as not truthy with ('')
|
||||
✓ passes as not truthy with (null)
|
||||
✓ passes as not truthy with (0)
|
||||
✓ passes as not truthy with ('0')
|
||||
✓ failures
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeWritableDirectory
|
||||
@ -619,5 +647,5 @@
|
||||
✓ it is a test
|
||||
✓ it uses correct parent class
|
||||
|
||||
Tests: 4 incompleted, 9 skipped, 395 passed
|
||||
Tests: 4 incompleted, 9 skipped, 419 passed
|
||||
|
||||
19
tests/Features/Expect/toBeFalsy.php
Normal file
19
tests/Features/Expect/toBeFalsy.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('passes as falsy', function ($value) {
|
||||
expect($value)->toBeFalsy();
|
||||
})->with([false, '', null, 0, '0']);
|
||||
|
||||
test('passes as not falsy', function ($value) {
|
||||
expect($value)->not->toBeFalsy();
|
||||
})->with([true, [1], 'false', 1, -1]);
|
||||
|
||||
test('failures', function () {
|
||||
expect(1)->toBeFalsy();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect(null)->not->toBeFalsy();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
19
tests/Features/Expect/toBeTruthy.php
Normal file
19
tests/Features/Expect/toBeTruthy.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('passes as truthy', function ($value) {
|
||||
expect($value)->toBeTruthy();
|
||||
})->with([true, [1], 'false', 1, -1]);
|
||||
|
||||
test('passes as not truthy', function ($value) {
|
||||
expect($value)->not->toBeTruthy();
|
||||
})->with([false, '', null, 0, '0']);
|
||||
|
||||
test('failures', function () {
|
||||
expect(null)->toBeTruthy();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect(1)->not->toBeTruthy();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
Reference in New Issue
Block a user