Compare commits

...

22 Commits

Author SHA1 Message Date
a7aa923241 release: v2.14.1 2023-08-16 09:47:05 +01:00
e012517b16 chore: bumps phpunit 2023-08-16 09:46:51 +01:00
b1dd18af8a chore: style changes 2023-08-16 09:46:31 +01:00
03648f580c docs: update changelog 2023-08-14 09:44:14 +01:00
df2212055b release: v2.14.0 2023-08-14 09:41:14 +01:00
b1a137c513 chore: updates snapshot tests 2023-08-14 09:41:05 +01:00
62267dfd3e Merge pull request #906 from JonPurvis/extra-expectations
add expectations for uppercase, lowercase, alpha and alphanumeric
2023-08-13 08:44:17 +00:00
f996a48dfa fix refacto check 2023-08-12 18:14:38 +01:00
54e00dd4dc add expectations for uppercase, lowercase, alpha and alphanumeric 2023-08-12 16:41:15 +01:00
f1414a0beb docs: changelog 2023-08-09 12:16:21 +01:00
47f2ae32c1 release: v2.13.0 2023-08-09 12:14:39 +01:00
306b7eb2a6 feat: adds ddWhen and ddUnless 2023-08-09 12:14:32 +01:00
02f72aabb2 Merge pull request #860 from devajmeireles/feature/add-dd-conditionally
Feature: Introducing The Ability to Dump Conditionally
2023-08-09 10:50:53 +00:00
e3a21384e6 release: v2.12.2 2023-08-07 10:29:25 +01:00
331381eed5 release: v2.12.1 2023-08-07 10:26:55 +01:00
75a7d77a80 Updates snapshots 2023-08-07 10:22:58 +01:00
cc242a50d1 chore: bump dependencies 2023-08-07 09:39:13 +01:00
704acbf6de Merge pull request #898 from dylanbr/allow_tests_to_be_extended
TestSuiteLoader will always consider classes from the current file
2023-08-06 22:59:52 +00:00
7baa48e068 TestSuiteLoader will always consider classes from the current file 2023-08-05 13:06:00 +02:00
b00bc4d5ea applying enhancement to use single dd function 2023-07-17 19:11:06 -03:00
8abc0d1920 applying enhancement to use ddWhen inside ddUnless 2023-07-17 14:12:54 -03:00
ea967b439f Feature: Introducing The Ability to Dump Conditionally 2023-07-17 11:08:00 -03:00
33 changed files with 338 additions and 51 deletions

View File

@ -2,6 +2,24 @@
## Unreleased ## Unreleased
## [v2.14.0 (2023-08-14)](https://github.com/pestphp/pest/compare/v2.13.0...v2.14.0)
### Added
- `toBeUppercase()`, `toBeLowercase()`, `toBeAlphaNumeric()`, `toBeAlpha()` ([#906](https://github.com/pestphp/pest/pull/906))
## [v2.13.0 (2023-08-09)](https://github.com/pestphp/pest/compare/v2.12.2...v2.13.0)
### Added
- `expect()->ddWhen` and `expect()->ddUnless` ([306b7eb](https://github.com/pestphp/pest/commit/306b7eb2a6a57e570d58228b46501ad9ba4062b4))
## [v2.12.2 (2023-08-07)](https://github.com/pestphp/pest/compare/v2.12.0...v2.12.2)
### Fixed
- Running tests from `uses` parent class ([#898](https://github.com/pestphp/pest/pull/898))
## [v2.12.0 (2023-08-02)](https://github.com/pestphp/pest/compare/v2.11.0...v2.12.0) ## [v2.12.0 (2023-08-02)](https://github.com/pestphp/pest/compare/v2.11.0...v2.12.0)
### Added ### Added

View File

@ -18,16 +18,16 @@
], ],
"require": { "require": {
"php": "^8.1.0", "php": "^8.1.0",
"brianium/paratest": "^7.2.4", "brianium/paratest": "^7.2.5",
"nunomaduro/collision": "^7.8.0", "nunomaduro/collision": "^7.8.1",
"nunomaduro/termwind": "^1.15.1", "nunomaduro/termwind": "^1.15.1",
"pestphp/pest-plugin": "^2.0.1", "pestphp/pest-plugin": "^2.0.1",
"pestphp/pest-plugin-arch": "^2.2.3", "pestphp/pest-plugin-arch": "^2.2.3",
"phpunit/phpunit": "^10.3.1" "phpunit/phpunit": "^10.3.2"
}, },
"conflict": { "conflict": {
"webmozart/assert": "<1.11.0", "webmozart/assert": "<1.11.0",
"phpunit/phpunit": ">10.3.1" "phpunit/phpunit": ">10.3.2"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View File

@ -34,17 +34,18 @@
namespace PHPUnit\Runner\Filter; namespace PHPUnit\Runner\Filter;
use function end;
use Exception; use Exception;
use function implode;
use Pest\Contracts\HasPrintableTestCaseName; use Pest\Contracts\HasPrintableTestCaseName;
use PHPUnit\Framework\SelfDescribing; use PHPUnit\Framework\SelfDescribing;
use PHPUnit\Framework\Test; use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestSuite; use PHPUnit\Framework\TestSuite;
use function preg_match;
use RecursiveFilterIterator; use RecursiveFilterIterator;
use RecursiveIterator; use RecursiveIterator;
use function end;
use function implode;
use function preg_match;
use function sprintf; use function sprintf;
use function str_replace; use function str_replace;

View File

@ -45,9 +45,15 @@ declare(strict_types=1);
namespace PHPUnit\Runner\ResultCache; namespace PHPUnit\Runner\ResultCache;
use const DIRECTORY_SEPARATOR;
use PHPUnit\Framework\TestStatus\TestStatus;
use PHPUnit\Runner\DirectoryCannotBeCreatedException;
use PHPUnit\Runner\Exception;
use PHPUnit\Util\Filesystem;
use function array_keys; use function array_keys;
use function assert; use function assert;
use const DIRECTORY_SEPARATOR;
use function dirname; use function dirname;
use function file_get_contents; use function file_get_contents;
use function file_put_contents; use function file_put_contents;
@ -57,10 +63,6 @@ use function is_file;
use function json_decode; use function json_decode;
use function json_encode; use function json_encode;
use function Pest\version; use function Pest\version;
use PHPUnit\Framework\TestStatus\TestStatus;
use PHPUnit\Runner\DirectoryCannotBeCreatedException;
use PHPUnit\Runner\Exception;
use PHPUnit\Util\Filesystem;
/** /**
* @internal This class is not covered by the backward compatibility promise for PHPUnit * @internal This class is not covered by the backward compatibility promise for PHPUnit

View File

@ -36,18 +36,19 @@ declare(strict_types=1);
namespace PHPUnit\Runner; namespace PHPUnit\Runner;
use function array_diff;
use function array_values;
use function basename;
use function class_exists;
use Exception; use Exception;
use function get_declared_classes;
use Pest\Contracts\HasPrintableTestCaseName; use Pest\Contracts\HasPrintableTestCaseName;
use Pest\TestCases\IgnorableTestCase; use Pest\TestCases\IgnorableTestCase;
use Pest\TestSuite; use Pest\TestSuite;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use ReflectionClass; use ReflectionClass;
use ReflectionException; use ReflectionException;
use function array_diff;
use function array_values;
use function basename;
use function class_exists;
use function get_declared_classes;
use function substr; use function substr;
/** /**
@ -60,6 +61,11 @@ final class TestSuiteLoader
*/ */
private static array $loadedClasses = []; private static array $loadedClasses = [];
/**
* @psalm-var array<string, array<class-string>>
*/
private static array $loadedClassesByFilename = [];
/** /**
* @psalm-var list<class-string> * @psalm-var list<class-string>
*/ */
@ -97,6 +103,17 @@ final class TestSuiteLoader
self::$loadedClasses = array_merge($loadedClasses, self::$loadedClasses); self::$loadedClasses = array_merge($loadedClasses, self::$loadedClasses);
foreach ($loadedClasses as $loadedClass) {
$reflection = new ReflectionClass($loadedClass);
$filename = $reflection->getFileName();
self::$loadedClassesByFilename[$filename] = [
$loadedClass,
...self::$loadedClassesByFilename[$filename] ?? [],
];
}
$loadedClasses = array_merge(self::$loadedClassesByFilename[$suiteClassFile] ?? [], $loadedClasses);
if (empty($loadedClasses)) { if (empty($loadedClasses)) {
return $this->exceptionFor($suiteClassName, $suiteClassFile); return $this->exceptionFor($suiteClassName, $suiteClassFile);
} }

View File

@ -45,7 +45,6 @@ declare(strict_types=1);
namespace PHPUnit\TextUI; namespace PHPUnit\TextUI;
use function array_map;
use Pest\Plugins\Only; use Pest\Plugins\Only;
use PHPUnit\Event; use PHPUnit\Event;
use PHPUnit\Framework\TestSuite; use PHPUnit\Framework\TestSuite;
@ -53,6 +52,8 @@ use PHPUnit\Runner\Filter\Factory;
use PHPUnit\TextUI\Configuration\Configuration; use PHPUnit\TextUI\Configuration\Configuration;
use PHPUnit\TextUI\Configuration\FilterNotConfiguredException; use PHPUnit\TextUI\Configuration\FilterNotConfiguredException;
use function array_map;
/** /**
* @internal This class is not covered by the backward compatibility promise for PHPUnit * @internal This class is not covered by the backward compatibility promise for PHPUnit
*/ */

View File

@ -7,12 +7,13 @@ namespace Pest\Bootstrappers;
use Pest\Contracts\Bootstrapper; use Pest\Contracts\Bootstrapper;
use Pest\Support\DatasetInfo; use Pest\Support\DatasetInfo;
use Pest\Support\Str; use Pest\Support\Str;
use function Pest\testDirectory;
use Pest\TestSuite; use Pest\TestSuite;
use RecursiveDirectoryIterator; use RecursiveDirectoryIterator;
use RecursiveIteratorIterator; use RecursiveIteratorIterator;
use SebastianBergmann\FileIterator\Facade as PhpUnitFileIterator; use SebastianBergmann\FileIterator\Facade as PhpUnitFileIterator;
use function Pest\testDirectory;
/** /**
* @internal * @internal
*/ */

View File

@ -127,6 +127,40 @@ final class Expectation
exit(1); exit(1);
} }
/**
* Dump the expectation value when the result of the condition is truthy.
*
* @param (\Closure(TValue): bool)|bool $condition
* @return self<TValue>
*/
public function ddWhen(Closure|bool $condition, mixed ...$arguments): Expectation
{
$condition = $condition instanceof Closure ? $condition($this->value) : $condition;
if (! $condition) {
return $this;
}
$this->dd(...$arguments);
}
/**
* Dump the expectation value when the result of the condition is falsy.
*
* @param (\Closure(TValue): bool)|bool $condition
* @return self<TValue>
*/
public function ddUnless(Closure|bool $condition, mixed ...$arguments): Expectation
{
$condition = $condition instanceof Closure ? $condition($this->value) : $condition;
if ($condition) {
return $this;
}
$this->dd(...$arguments);
}
/** /**
* Send the expectation value to Ray along with all given arguments. * Send the expectation value to Ray along with all given arguments.
* *

View File

@ -4,9 +4,10 @@ declare(strict_types=1);
namespace Pest\Expectations; namespace Pest\Expectations;
use function expect;
use Pest\Expectation; use Pest\Expectation;
use function expect;
/** /**
* @internal * @internal
* *

View File

@ -961,4 +961,52 @@ final class Expectation
return $this->exporter->shortenedExport($value); return $this->exporter->shortenedExport($value);
} }
/**
* Asserts that the value is uppercase.
*
* @return self<TValue>
*/
public function toBeUppercase(string $message = ''): self
{
Assert::assertTrue(ctype_upper((string) $this->value), $message);
return $this;
}
/**
* Asserts that the value is lowercase.
*
* @return self<TValue>
*/
public function toBeLowercase(string $message = ''): self
{
Assert::assertTrue(ctype_lower((string) $this->value), $message);
return $this;
}
/**
* Asserts that the value is alphanumeric.
*
* @return self<TValue>
*/
public function toBeAlphaNumeric(string $message = ''): self
{
Assert::assertTrue(ctype_alnum((string) $this->value), $message);
return $this;
}
/**
* Asserts that the value is alpha.
*
* @return self<TValue>
*/
public function toBeAlpha(string $message = ''): self
{
Assert::assertTrue(ctype_alpha((string) $this->value), $message);
return $this;
}
} }

View File

@ -6,7 +6,7 @@ namespace Pest;
function version(): string function version(): string
{ {
return '2.12.0'; return '2.14.1';
} }
function testDirectory(string $file = ''): string function testDirectory(string $file = ''): string

View File

@ -6,10 +6,11 @@ namespace Pest\Plugins;
use Pest\Contracts\Plugins\HandlesArguments; use Pest\Contracts\Plugins\HandlesArguments;
use Pest\Support\View; use Pest\Support\View;
use function Pest\version;
use PHPUnit\TextUI\Help as PHPUnitHelp; use PHPUnit\TextUI\Help as PHPUnitHelp;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use function Pest\version;
/** /**
* @internal * @internal
*/ */

View File

@ -13,11 +13,12 @@ use Pest\Plugins\Parallel\Paratest\CleanConsoleOutput;
use Pest\Support\Arr; use Pest\Support\Arr;
use Pest\Support\Container; use Pest\Support\Container;
use Pest\TestSuite; use Pest\TestSuite;
use function Pest\version;
use Stringable; use Stringable;
use Symfony\Component\Console\Application; use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\ArgvInput;
use function Pest\version;
final class Parallel implements HandlesArguments final class Parallel implements HandlesArguments
{ {
use HandleArguments; use HandleArguments;

View File

@ -4,6 +4,16 @@ declare(strict_types=1);
namespace Pest\Plugins\Parallel\Paratest; namespace Pest\Plugins\Parallel\Paratest;
use ParaTest\Options;
use Pest\Plugins\Parallel\Support\CompactPrinter;
use Pest\Support\StateGenerator;
use PHPUnit\TestRunner\TestResult\TestResult;
use PHPUnit\TextUI\Output\Printer;
use SebastianBergmann\Timer\Duration;
use SplFileInfo;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Output\OutputInterface;
use function assert; use function assert;
use function fclose; use function fclose;
use function feof; use function feof;
@ -12,16 +22,7 @@ use function fread;
use function fseek; use function fseek;
use function ftell; use function ftell;
use function fwrite; use function fwrite;
use ParaTest\Options;
use Pest\Plugins\Parallel\Support\CompactPrinter;
use Pest\Support\StateGenerator;
use PHPUnit\TestRunner\TestResult\TestResult;
use PHPUnit\TextUI\Output\Printer;
use SebastianBergmann\Timer\Duration;
use SplFileInfo;
use function strlen; use function strlen;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Output\OutputInterface;
/** /**
* @internal * @internal

View File

@ -4,15 +4,8 @@ declare(strict_types=1);
namespace Pest\Plugins\Parallel\Paratest; namespace Pest\Plugins\Parallel\Paratest;
use function array_merge;
use function array_merge_recursive;
use function array_shift;
use function assert;
use function count;
use const DIRECTORY_SEPARATOR; use const DIRECTORY_SEPARATOR;
use function dirname;
use function file_get_contents;
use function max;
use NunoMaduro\Collision\Adapters\Phpunit\Support\ResultReflection; use NunoMaduro\Collision\Adapters\Phpunit\Support\ResultReflection;
use ParaTest\Coverage\CoverageMerger; use ParaTest\Coverage\CoverageMerger;
use ParaTest\JUnit\LogMerger; use ParaTest\JUnit\LogMerger;
@ -30,11 +23,20 @@ use PHPUnit\TestRunner\TestResult\Facade as TestResultFacade;
use PHPUnit\TestRunner\TestResult\TestResult; use PHPUnit\TestRunner\TestResult\TestResult;
use PHPUnit\TextUI\Configuration\CodeCoverageFilterRegistry; use PHPUnit\TextUI\Configuration\CodeCoverageFilterRegistry;
use PHPUnit\Util\ExcludeList; use PHPUnit\Util\ExcludeList;
use function realpath;
use SebastianBergmann\Timer\Timer; use SebastianBergmann\Timer\Timer;
use SplFileInfo; use SplFileInfo;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\PhpExecutableFinder;
use function array_merge;
use function array_merge_recursive;
use function array_shift;
use function assert;
use function count;
use function dirname;
use function file_get_contents;
use function max;
use function realpath;
use function unlink; use function unlink;
use function unserialize; use function unserialize;
use function usleep; use function usleep;

View File

@ -16,8 +16,9 @@ use PHPUnit\TestRunner\TestResult\TestResult as PHPUnitTestResult;
use SebastianBergmann\Timer\Duration; use SebastianBergmann\Timer\Duration;
use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use function Termwind\render;
use Termwind\Terminal; use Termwind\Terminal;
use function Termwind\render;
use function Termwind\terminal; use function Termwind\terminal;
/** /**

View File

@ -6,6 +6,7 @@ namespace Pest\Plugins;
use Pest\Contracts\Plugins\HandlesArguments; use Pest\Contracts\Plugins\HandlesArguments;
use Pest\Support\View; use Pest\Support\View;
use function Pest\version; use function Pest\version;
/** /**

View File

@ -10,9 +10,10 @@ use Pest\Exceptions\DatasetAlreadyExists;
use Pest\Exceptions\DatasetDoesNotExist; use Pest\Exceptions\DatasetDoesNotExist;
use Pest\Exceptions\ShouldNotHappen; use Pest\Exceptions\ShouldNotHappen;
use Pest\Support\Exporter; use Pest\Support\Exporter;
use function sprintf;
use Traversable; use Traversable;
use function sprintf;
/** /**
* @internal * @internal
*/ */

View File

@ -10,6 +10,7 @@ use SebastianBergmann\CodeCoverage\Node\Directory;
use SebastianBergmann\CodeCoverage\Node\File; use SebastianBergmann\CodeCoverage\Node\File;
use SebastianBergmann\Environment\Runtime; use SebastianBergmann\Environment\Runtime;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use function Termwind\render; use function Termwind\render;
use function Termwind\renderUsing; use function Termwind\renderUsing;
use function Termwind\terminal; use function Termwind\terminal;

View File

@ -5,9 +5,10 @@ declare(strict_types=1);
namespace Pest\Support; namespace Pest\Support;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Termwind\Termwind;
use function Termwind\render; use function Termwind\render;
use function Termwind\renderUsing; use function Termwind\renderUsing;
use Termwind\Termwind;
/** /**
* @internal * @internal

View File

@ -1,5 +1,5 @@
Pest Testing Framework 2.12.0. Pest Testing Framework 2.14.1.
USAGE: pest <file> [options] USAGE: pest <file> [options]

View File

@ -1,3 +1,3 @@
Pest Testing Framework 2.12.0. Pest Testing Framework 2.14.1.

View File

@ -308,6 +308,18 @@
✓ strict comparisons ✓ strict comparisons
✓ failures ✓ failures
✓ failures with custom message ✓ failures with custom message
✓ not failures
PASS Tests\Features\Expect\toBeAlpha
✓ pass
✓ failures
✓ failures with custom message
✓ not failures
PASS Tests\Features\Expect\toBeAlphaNumeric
✓ pass
✓ failures
✓ failures with custom message
✓ not failures ✓ not failures
PASS Tests\Features\Expect\toBeArray PASS Tests\Features\Expect\toBeArray
@ -443,6 +455,12 @@
✓ passes with DateTime and DateTimeImmutable ✓ passes with DateTime and DateTimeImmutable
✓ failures ✓ failures
✓ failures with custom message ✓ failures with custom message
✓ not failures
PASS Tests\Features\Expect\toBeLowercase
✓ pass
✓ failures
✓ failures with custom message
✓ not failures ✓ not failures
PASS Tests\Features\Expect\toBeNAN PASS Tests\Features\Expect\toBeNAN
@ -518,6 +536,12 @@
✓ passes as not truthy with ('0') ✓ passes as not truthy with ('0')
✓ failures ✓ failures
✓ failures with custom message ✓ failures with custom message
✓ not failures
PASS Tests\Features\Expect\toBeUppercase
✓ pass
✓ failures
✓ failures with custom message
✓ not failures ✓ not failures
PASS Tests\Features\Expect\toBeWritableDirectory PASS Tests\Features\Expect\toBeWritableDirectory
@ -1015,9 +1039,15 @@
PASS Tests\PHPUnit\CustomAffixes\snakecasespec PASS Tests\PHPUnit\CustomAffixes\snakecasespec
✓ it runs file names like snake_case_spec.php ✓ it runs file names like snake_case_spec.php
PASS Tests\CustomTestCase\ChildTest
✓ override method
PASS Tests\CustomTestCase\ExecutedTest PASS Tests\CustomTestCase\ExecutedTest
✓ that gets executed ✓ that gets executed
PASS Tests\CustomTestCase\ParentTest
✓ override method
PASS Tests\PHPUnit\CustomTestCase\UsesPerDirectory PASS Tests\PHPUnit\CustomTestCase\UsesPerDirectory
✓ closure was bound to CustomTestCase ✓ closure was bound to CustomTestCase
@ -1210,4 +1240,4 @@
WARN Tests\Visual\Version WARN Tests\Visual\Version
- visual snapshot of help command output - visual snapshot of help command output
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 860 passed (1975 assertions) Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 878 passed (2013 assertions)

View File

@ -19,7 +19,13 @@
↓ something todo later chained ↓ something todo later chained
↓ something todo later chained and with function body ↓ something todo later chained and with function body
PASS Tests\CustomTestCase\ChildTest
✓ override method
PASS Tests\CustomTestCase\ExecutedTest PASS Tests\CustomTestCase\ExecutedTest
✓ that gets executed ✓ that gets executed
Tests: 13 todos, 1 passed (1 assertions) PASS Tests\CustomTestCase\ParentTest
✓ override method
Tests: 13 todos, 3 passed (3 assertions)

View File

@ -0,0 +1,20 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect('abc')->toBeAlpha();
expect('123')->not->toBeAlpha();
});
test('failures', function () {
expect('123')->toBeAlpha();
})->throws(ExpectationFailedException::class);
test('failures with custom message', function () {
expect('123')->toBeAlpha('oh no!');
})->throws(ExpectationFailedException::class, 'oh no!');
test('not failures', function () {
expect('abc')->not->toBeAlpha();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,20 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect('abc123')->toBeAlphaNumeric();
expect('-')->not->toBeAlphaNumeric();
});
test('failures', function () {
expect('-')->toBeAlphaNumeric();
})->throws(ExpectationFailedException::class);
test('failures with custom message', function () {
expect('-')->toBeAlphaNumeric('oh no!');
})->throws(ExpectationFailedException::class, 'oh no!');
test('not failures', function () {
expect('abc123')->not->toBeAlphaNumeric();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,20 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect('lowercase')->toBeLowercase();
expect('UPPERCASE')->not->toBeLowercase();
});
test('failures', function () {
expect('UPPERCASE')->toBeLowercase();
})->throws(ExpectationFailedException::class);
test('failures with custom message', function () {
expect('UPPERCASE')->toBeLowercase('oh no!');
})->throws(ExpectationFailedException::class, 'oh no!');
test('not failures', function () {
expect('lowercase')->not->toBeLowercase();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,20 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect('UPPERCASE')->toBeUppercase();
expect('lowercase')->not->toBeUppercase();
});
test('failures', function () {
expect('lowercase')->toBeUppercase();
})->throws(ExpectationFailedException::class);
test('failures with custom message', function () {
expect('lowercase')->toBeUppercase('oh no!');
})->throws(ExpectationFailedException::class, 'oh no!');
test('not failures', function () {
expect('UPPERCASE')->not->toBeUppercase();
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace Tests\CustomTestCase;
class ChildTest extends ParentTest
{
private function getEntity(): bool
{
return true;
}
}

View File

@ -4,9 +4,10 @@ declare(strict_types=1);
namespace Tests\CustomTestCase; namespace Tests\CustomTestCase;
use function PHPUnit\Framework\assertTrue;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use function PHPUnit\Framework\assertTrue;
abstract class CustomTestCase extends TestCase abstract class CustomTestCase extends TestCase
{ {
public function assertCustomTrue() public function assertCustomTrue()

View File

@ -4,9 +4,10 @@ declare(strict_types=1);
namespace Tests\CustomTestCase; namespace Tests\CustomTestCase;
use function PHPUnit\Framework\assertTrue;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use function PHPUnit\Framework\assertTrue;
class ExecutedTest extends TestCase class ExecutedTest extends TestCase
{ {
public static $executed = false; public static $executed = false;

View File

@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace Tests\CustomTestCase;
use PHPUnit\Framework\TestCase;
use function PHPUnit\Framework\assertTrue;
class ParentTest extends TestCase
{
private function getEntity(): bool
{
return false;
}
/** @test */
public function testOverrideMethod(): void
{
assertTrue($this->getEntity() || true);
}
}

View File

@ -16,7 +16,7 @@ $run = function () {
test('parallel', function () use ($run) { test('parallel', function () use ($run) {
expect($run('--exclude-group=integration')) expect($run('--exclude-group=integration'))
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 849 passed (1960 assertions)') ->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 867 passed (1998 assertions)')
->toContain('Parallel: 3 processes'); ->toContain('Parallel: 3 processes');
})->skipOnWindows(); })->skipOnWindows();