mirror of
https://github.com/pestphp/pest.git
synced 2026-03-10 01:37:21 +01:00
Compare commits
53 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b6c2812a91 | |||
| 4b65d2c426 | |||
| 3589f3d5e7 | |||
| 1f39b8d239 | |||
| 7c3c390cbf | |||
| 19a1569fa8 | |||
| 9a0240bc7b | |||
| dd94a843b5 | |||
| 9426d08aa2 | |||
| fe2fac37f8 | |||
| cabd64df00 | |||
| bb57a54089 | |||
| 5e0bfba7bf | |||
| f6c19e469f | |||
| 13f09cc662 | |||
| a7e2856887 | |||
| 721e047485 | |||
| 301ff155a4 | |||
| 40f2065575 | |||
| be906eb823 | |||
| 2cee825f61 | |||
| ea6308bfdf | |||
| c6a6f7e2ab | |||
| 20077c285a | |||
| fa13016785 | |||
| b81bb9d621 | |||
| 2deb53c14f | |||
| 6b8feed08a | |||
| 2fe8e07cf3 | |||
| d2c907868e | |||
| a2900a5e09 | |||
| df934bacd9 | |||
| b0f03c278d | |||
| b59b321249 | |||
| 82d6991cf8 | |||
| d693d99379 | |||
| 50c1136be8 | |||
| dd491e516c | |||
| 078aab0d3d | |||
| 89c9f4b428 | |||
| 2148e896e2 | |||
| 7ba49b2e3e | |||
| 54a285f7e3 | |||
| 3ed20d059c | |||
| 92b6800f28 | |||
| 29cfd1a2dc | |||
| 45c09ea0ed | |||
| 424e24d530 | |||
| 26b2e3561a | |||
| 60aea6798d | |||
| fac3fe3f55 | |||
| 17fac0a488 | |||
| 6abc2207b2 |
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@ -1,5 +1,5 @@
|
|||||||
# These are supported funding model platforms
|
# These are supported funding model platforms
|
||||||
|
|
||||||
github: nunomaduro
|
github: [nunomaduro,owenvoke,olivernybroe,octoper]
|
||||||
patreon: nunomaduro
|
patreon: nunomaduro
|
||||||
custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L
|
custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L
|
||||||
|
|||||||
4
.github/workflows/static.yml
vendored
4
.github/workflows/static.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
|||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: 7.4
|
php-version: 8.0
|
||||||
tools: composer:v2
|
tools: composer:v2
|
||||||
coverage: none
|
coverage: none
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ jobs:
|
|||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: 7.4
|
php-version: 8.0
|
||||||
tools: composer:v2
|
tools: composer:v2
|
||||||
coverage: none
|
coverage: none
|
||||||
|
|
||||||
|
|||||||
31
CHANGELOG.md
31
CHANGELOG.md
@ -4,6 +4,37 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
## [v1.0.3 (2021-03-13)](https://github.com/pestphp/pest/compare/v1.0.2...v1.0.3)
|
||||||
|
### Added
|
||||||
|
- Support for test extensions ([#269](https://github.com/pestphp/pest/pull/269))
|
||||||
|
|
||||||
|
## [v1.0.2 (2021-02-04)](https://github.com/pestphp/pest/compare/v1.0.1...v1.0.2)
|
||||||
|
### Added
|
||||||
|
- Support for PHPUnit 9.5.2 ([#267](https://github.com/pestphp/pest/pull/267))
|
||||||
|
|
||||||
|
## [v1.0.1 (2021-01-18)](https://github.com/pestphp/pest/compare/v1.0.0...v1.0.1)
|
||||||
|
### Added
|
||||||
|
- Support for PHPUnit 9.5.1 ([#261](https://github.com/pestphp/pest/pull/261))
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fix `TestCase@expect` PHPDoc tag ([#251](https://github.com/pestphp/pest/pull/251))
|
||||||
|
|
||||||
|
## [v1.0.0 (2021-01-03)](https://github.com/pestphp/pest/compare/v0.3.19...v1.0.0)
|
||||||
|
### Added
|
||||||
|
- `pest:test --dusk` option ([#245](https://github.com/pestphp/pest/pull/245))
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Stable version
|
||||||
|
- Updates init structure ([#240](https://github.com/pestphp/pest/pull/240))
|
||||||
|
|
||||||
|
## [v0.3.19 (2020-12-27)](https://github.com/pestphp/pest/compare/v0.3.18...v0.3.19)
|
||||||
|
### Fixed
|
||||||
|
- Fix binary path in `pest:dusk` command ([#239](https://github.com/pestphp/pest/pull/239))
|
||||||
|
|
||||||
|
## [v0.3.18 (2020-12-26)](https://github.com/pestphp/pest/compare/v0.3.17...v0.3.18)
|
||||||
|
### Added
|
||||||
|
- `toBeJson()` expectation ([plugin-expectations#2](https://github.com/pestphp/pest-plugin-expectations/pull/2))
|
||||||
|
|
||||||
## [v0.3.17 (2020-12-20)](https://github.com/pestphp/pest/compare/v0.3.16...v0.3.17)
|
## [v0.3.17 (2020-12-20)](https://github.com/pestphp/pest/compare/v0.3.16...v0.3.17)
|
||||||
### Fixed
|
### Fixed
|
||||||
- Class inheritance with `depends()` ([#236](https://github.com/pestphp/pest/pull/236))
|
- Class inheritance with `depends()` ([#236](https://github.com/pestphp/pest/pull/236))
|
||||||
|
|||||||
@ -21,6 +21,7 @@ We would like to extend our thanks to the following sponsors for funding Pest de
|
|||||||
|
|
||||||
### Premium Sponsors
|
### Premium Sponsors
|
||||||
|
|
||||||
- **[Scout APM](https://github.com/scoutapp)**
|
- **[Scout APM](https://scoutapm.com)**
|
||||||
|
- **[Akaunting](https://akaunting.com)**
|
||||||
|
|
||||||
Pest was created by **[Nuno Maduro](https://twitter.com/enunomaduro)** under the **[Sponsorware license](https://github.com/sponsorware/docs)**. It got open-sourced and is now licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.
|
Pest was created by **[Nuno Maduro](https://twitter.com/enunomaduro)** under the **[Sponsorware license](https://github.com/sponsorware/docs)**. It got open-sourced and is now licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.
|
||||||
|
|||||||
@ -19,11 +19,11 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^7.3 || ^8.0",
|
"php": "^7.3 || ^8.0",
|
||||||
"nunomaduro/collision": "^5.0",
|
"nunomaduro/collision": "^5.0",
|
||||||
"pestphp/pest-plugin": "^0.3",
|
"pestphp/pest-plugin": "^1.0",
|
||||||
"pestphp/pest-plugin-coverage": "^0.3",
|
"pestphp/pest-plugin-coverage": "^1.0",
|
||||||
"pestphp/pest-plugin-expectations": "^0.3.2",
|
"pestphp/pest-plugin-expectations": "^1.0",
|
||||||
"pestphp/pest-plugin-init": "^0.3",
|
"pestphp/pest-plugin-init": "^1.0",
|
||||||
"phpunit/phpunit": ">= 9.3.7 <= 9.5.0"
|
"phpunit/phpunit": ">= 9.3.7 <= 9.5.2"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
@ -43,10 +43,10 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"illuminate/console": "^7.16.1",
|
"illuminate/console": "^8.32.1",
|
||||||
"illuminate/support": "^7.16.1",
|
"illuminate/support": "^8.32.1",
|
||||||
"laravel/dusk": "^6.9.1",
|
"laravel/dusk": "^6.13.0",
|
||||||
"mockery/mockery": "^1.4.1",
|
"mockery/mockery": "^1.4.3",
|
||||||
"pestphp/pest-dev-tools": "dev-master"
|
"pestphp/pest-dev-tools": "dev-master"
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
@ -74,7 +74,7 @@
|
|||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "0.4.x-dev"
|
"dev-master": "1.x-dev"
|
||||||
},
|
},
|
||||||
"pest": {
|
"pest": {
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
|||||||
@ -14,7 +14,6 @@ parameters:
|
|||||||
|
|
||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
- "#type mixed is not subtype of native#"
|
- "#type mixed is not subtype of native#"
|
||||||
- "#Undefined variable: \\$this#"
|
|
||||||
- "#is not allowed to extend#"
|
- "#is not allowed to extend#"
|
||||||
- "#Language construct eval#"
|
- "#Language construct eval#"
|
||||||
- "# with null as default value#"
|
- "# with null as default value#"
|
||||||
|
|||||||
@ -5,14 +5,17 @@ declare(strict_types=1);
|
|||||||
namespace Pest\Factories;
|
namespace Pest\Factories;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use ParseError;
|
||||||
use Pest\Concerns;
|
use Pest\Concerns;
|
||||||
use Pest\Contracts\HasPrintableTestCaseName;
|
use Pest\Contracts\HasPrintableTestCaseName;
|
||||||
use Pest\Datasets;
|
use Pest\Datasets;
|
||||||
use Pest\Exceptions\ShouldNotHappen;
|
use Pest\Exceptions\ShouldNotHappen;
|
||||||
use Pest\Support\HigherOrderMessageCollection;
|
use Pest\Support\HigherOrderMessageCollection;
|
||||||
use Pest\Support\NullClosure;
|
use Pest\Support\NullClosure;
|
||||||
|
use Pest\Support\Str;
|
||||||
use Pest\TestSuite;
|
use Pest\TestSuite;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -139,6 +142,7 @@ final class TestCaseFactory
|
|||||||
$proxies->proxy($this);
|
$proxies->proxy($this);
|
||||||
$chains->chain($this);
|
$chains->chain($this);
|
||||||
|
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
return call_user_func(Closure::bind($factoryTest, $this, get_class($this)), ...func_get_args());
|
return call_user_func(Closure::bind($factoryTest, $this, get_class($this)), ...func_get_args());
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -168,7 +172,7 @@ final class TestCaseFactory
|
|||||||
}, $filename);
|
}, $filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = (string) realpath($filename);
|
$filename = str_replace('\\\\', '\\', addslashes((string) realpath($filename)));
|
||||||
$rootPath = TestSuite::getInstance()->rootPath;
|
$rootPath = TestSuite::getInstance()->rootPath;
|
||||||
$relativePath = str_replace($rootPath . DIRECTORY_SEPARATOR, '', $filename);
|
$relativePath = str_replace($rootPath . DIRECTORY_SEPARATOR, '', $filename);
|
||||||
$relativePath = dirname(ucfirst($relativePath)) . DIRECTORY_SEPARATOR . basename($relativePath, '.php');
|
$relativePath = dirname(ucfirst($relativePath)) . DIRECTORY_SEPARATOR . basename($relativePath, '.php');
|
||||||
@ -176,8 +180,12 @@ final class TestCaseFactory
|
|||||||
|
|
||||||
// Strip out any %-encoded octets.
|
// Strip out any %-encoded octets.
|
||||||
$relativePath = (string) preg_replace('|%[a-fA-F0-9][a-fA-F0-9]|', '', $relativePath);
|
$relativePath = (string) preg_replace('|%[a-fA-F0-9][a-fA-F0-9]|', '', $relativePath);
|
||||||
|
// Remove escaped quote sequences (maintain namespace)
|
||||||
|
$relativePath = str_replace(array_map(function (string $quote): string {
|
||||||
|
return sprintf('\\%s', $quote);
|
||||||
|
}, ['\'', '"']), '', $relativePath);
|
||||||
// Limit to A-Z, a-z, 0-9, '_', '-'.
|
// Limit to A-Z, a-z, 0-9, '_', '-'.
|
||||||
$relativePath = (string) preg_replace('/[^A-Za-z0-9.\\\]/', '', $relativePath);
|
$relativePath = (string) preg_replace('/[^A-Za-z0-9\\\\]/', '', $relativePath);
|
||||||
|
|
||||||
$classFQN = 'P\\' . $relativePath;
|
$classFQN = 'P\\' . $relativePath;
|
||||||
if (class_exists($classFQN)) {
|
if (class_exists($classFQN)) {
|
||||||
@ -194,15 +202,24 @@ final class TestCaseFactory
|
|||||||
$namespace = implode('\\', $partsFQN);
|
$namespace = implode('\\', $partsFQN);
|
||||||
$baseClass = sprintf('\%s', $this->class);
|
$baseClass = sprintf('\%s', $this->class);
|
||||||
|
|
||||||
eval("
|
if ('' === trim($className)) {
|
||||||
namespace $namespace;
|
$className = 'InvalidTestName' . Str::random();
|
||||||
|
$classFQN .= $className;
|
||||||
|
}
|
||||||
|
|
||||||
final class $className extends $baseClass implements $hasPrintableTestCaseClassFQN {
|
try {
|
||||||
$traitsCode
|
eval("
|
||||||
|
namespace $namespace;
|
||||||
|
|
||||||
private static \$__filename = '$filename';
|
final class $className extends $baseClass implements $hasPrintableTestCaseClassFQN {
|
||||||
}
|
$traitsCode
|
||||||
");
|
|
||||||
|
private static \$__filename = '$filename';
|
||||||
|
}
|
||||||
|
");
|
||||||
|
} catch (ParseError $caught) {
|
||||||
|
throw new RuntimeException(sprintf('Unable to create test case for test file at %s', $filename), 1, $caught);
|
||||||
|
}
|
||||||
|
|
||||||
return $classFQN;
|
return $classFQN;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,9 +33,9 @@ final class PestDuskCommand extends DuskCommand
|
|||||||
protected function binary()
|
protected function binary()
|
||||||
{
|
{
|
||||||
if ('phpdbg' === PHP_SAPI) {
|
if ('phpdbg' === PHP_SAPI) {
|
||||||
return [PHP_BINARY, '-qrr', 'vendor/bin/pest'];
|
return [PHP_BINARY, '-qrr', 'vendor/pestphp/pest/bin/pest'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [PHP_BINARY, 'vendor/bin/pest'];
|
return [PHP_BINARY, 'vendor/pestphp/pest/bin/pest'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,6 @@ use Illuminate\Console\Command;
|
|||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Pest\Console\Thanks;
|
use Pest\Console\Thanks;
|
||||||
use Pest\Exceptions\InvalidConsoleArgument;
|
use Pest\Exceptions\InvalidConsoleArgument;
|
||||||
use Pest\Support\Str;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -36,14 +35,10 @@ final class PestInstallCommand extends Command
|
|||||||
{
|
{
|
||||||
/* @phpstan-ignore-next-line */
|
/* @phpstan-ignore-next-line */
|
||||||
$pest = base_path('tests/Pest.php');
|
$pest = base_path('tests/Pest.php');
|
||||||
/* @phpstan-ignore-next-line */
|
$stubs = 'stubs/Laravel';
|
||||||
$helpers = base_path('tests/Helpers.php');
|
|
||||||
$stubs = $this->isLumen() ? 'stubs/Lumen' : 'stubs/Laravel';
|
|
||||||
|
|
||||||
foreach ([$pest, $helpers] as $file) {
|
if (File::exists($pest)) {
|
||||||
if (File::exists($file)) {
|
throw new InvalidConsoleArgument(sprintf('%s already exist', $pest));
|
||||||
throw new InvalidConsoleArgument(sprintf('%s already exist', $file));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
File::copy(implode(DIRECTORY_SEPARATOR, [
|
File::copy(implode(DIRECTORY_SEPARATOR, [
|
||||||
@ -52,26 +47,10 @@ final class PestInstallCommand extends Command
|
|||||||
'Pest.php',
|
'Pest.php',
|
||||||
]), $pest);
|
]), $pest);
|
||||||
|
|
||||||
File::copy(implode(DIRECTORY_SEPARATOR, [
|
|
||||||
dirname(__DIR__, 3),
|
|
||||||
$stubs,
|
|
||||||
'Helpers.php',
|
|
||||||
]), $helpers);
|
|
||||||
|
|
||||||
$this->output->success('`tests/Pest.php` created successfully.');
|
$this->output->success('`tests/Pest.php` created successfully.');
|
||||||
$this->output->success('`tests/Helpers.php` created successfully.');
|
|
||||||
|
|
||||||
if (!(bool) $this->option('no-interaction')) {
|
if (!(bool) $this->option('no-interaction')) {
|
||||||
(new Thanks($this->output))();
|
(new Thanks($this->output))();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if this is a Lumen application.
|
|
||||||
*/
|
|
||||||
private function isLumen(): bool
|
|
||||||
{
|
|
||||||
/* @phpstan-ignore-next-line */
|
|
||||||
return Str::startsWith(app()->version(), 'Lumen');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ final class PestTestCommand extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'pest:test {name : The name of the file} {--unit : Create a unit test}';
|
protected $signature = 'pest:test {name : The name of the file} {--unit : Create a unit test} {--dusk : Create a Dusk test}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
@ -36,7 +36,7 @@ final class PestTestCommand extends Command
|
|||||||
/** @var string $name */
|
/** @var string $name */
|
||||||
$name = $this->argument('name');
|
$name = $this->argument('name');
|
||||||
|
|
||||||
$type = ((bool) $this->option('unit')) ? 'Unit' : 'Feature';
|
$type = ((bool) $this->option('unit')) ? 'Unit' : (((bool) $this->option('dusk')) ? 'Browser' : 'Feature');
|
||||||
|
|
||||||
$relativePath = sprintf('tests/%s/%s.php',
|
$relativePath = sprintf('tests/%s/%s.php',
|
||||||
$type,
|
$type,
|
||||||
|
|||||||
@ -12,7 +12,7 @@ use Pest\TestSuite;
|
|||||||
use SebastianBergmann\Exporter\Exporter;
|
use SebastianBergmann\Exporter\Exporter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method \Pest\Expectation expect(mixed $value)
|
* @method \Pest\Expectations\Expectation expect(mixed $value)
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -6,5 +6,5 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '0.3.17';
|
return '1.0.3';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,9 @@ final class ChainableClosure
|
|||||||
public static function from(Closure $closure, Closure $next): Closure
|
public static function from(Closure $closure, Closure $next): Closure
|
||||||
{
|
{
|
||||||
return function () use ($closure, $next): void {
|
return function () use ($closure, $next): void {
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
call_user_func_array(Closure::bind($closure, $this, get_class($this)), func_get_args());
|
call_user_func_array(Closure::bind($closure, $this, get_class($this)), func_get_args());
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
call_user_func_array(Closure::bind($next, $this, get_class($this)), func_get_args());
|
call_user_func_array(Closure::bind($next, $this, get_class($this)), func_get_args());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,6 +79,7 @@ final class Container
|
|||||||
|
|
||||||
if ($candidate === null) {
|
if ($candidate === null) {
|
||||||
$type = $param->getType();
|
$type = $param->getType();
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
if ($type !== null && $type->isBuiltin()) {
|
if ($type !== null && $type->isBuiltin()) {
|
||||||
$candidate = $param->getName();
|
$candidate = $param->getName();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -9,6 +9,25 @@ namespace Pest\Support;
|
|||||||
*/
|
*/
|
||||||
final class Str
|
final class Str
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Pool of alpha-numeric characters for generating (unsafe) random strings
|
||||||
|
* from.
|
||||||
|
*/
|
||||||
|
private const POOL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a (unsecure & non-cryptographically safe) random alpha-numeric
|
||||||
|
* string value.
|
||||||
|
*
|
||||||
|
* @param int $length the length of the resulting randomized string
|
||||||
|
*
|
||||||
|
* @see https://github.com/laravel/framework/blob/4.2/src/Illuminate/Support/Str.php#L240-L242
|
||||||
|
*/
|
||||||
|
public static function random(int $length = 16): string
|
||||||
|
{
|
||||||
|
return substr(str_shuffle(str_repeat(self::POOL, 5)), 0, $length);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given `$target` starts with the given `$search`.
|
* Checks if the given `$target` starts with the given `$search`.
|
||||||
*/
|
*/
|
||||||
|
|||||||
10
stubs/Browser.php
Normal file
10
stubs/Browser.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Laravel\Dusk\Browser;
|
||||||
|
|
||||||
|
it('has {name} page', function () {
|
||||||
|
$this->browse(function (Browser $browser) {
|
||||||
|
$browser->visit('/{name}')
|
||||||
|
->assertSee('{name}');
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A basic assert example.
|
|
||||||
*/
|
|
||||||
function assertExample(): void
|
|
||||||
{
|
|
||||||
test()->assertTrue(true);
|
|
||||||
}
|
|
||||||
@ -1,3 +1,45 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Test Case
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The closure you provide to your test functions is always bound to a specific PHPUnit test
|
||||||
|
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
|
||||||
|
| need to change it using the "uses()" function to bind a different classes or traits.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
uses(Tests\TestCase::class)->in('Feature');
|
uses(Tests\TestCase::class)->in('Feature');
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Expectations
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When you're writing tests, you often need to check that values meet certain conditions. The
|
||||||
|
| "expect()" function gives you access to a set of "expectations" methods that you can use
|
||||||
|
| to assert different things. Of course, you may extend the Expectation API at any time.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
expect()->extend('toBeOne', function () {
|
||||||
|
return $this->toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Functions
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
|
||||||
|
| project that you don't want to repeat in every file. Here you can also expose helpers as
|
||||||
|
| global functions to help you to reduce the number of lines of code in your test files.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
function something()
|
||||||
|
{
|
||||||
|
// ..
|
||||||
|
}
|
||||||
|
|||||||
@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A basic assert example.
|
|
||||||
*/
|
|
||||||
function assertExample(): void
|
|
||||||
{
|
|
||||||
test()->assertTrue(true);
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
uses(TestCase::class)->in(__DIR__);
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
|
|
||||||
bootstrap="vendor/autoload.php"
|
|
||||||
colors="true"
|
|
||||||
>
|
|
||||||
<testsuites>
|
|
||||||
<testsuite name="Application Test Suite">
|
|
||||||
<directory suffix="Test.php">./tests</directory>
|
|
||||||
</testsuite>
|
|
||||||
</testsuites>
|
|
||||||
<coverage processUncoveredFiles="true">
|
|
||||||
<include>
|
|
||||||
<directory suffix=".php">./app</directory>
|
|
||||||
</include>
|
|
||||||
</coverage>
|
|
||||||
</phpunit>
|
|
||||||
@ -103,6 +103,27 @@
|
|||||||
PASS Tests\Fixtures\ExampleTest
|
PASS Tests\Fixtures\ExampleTest
|
||||||
✓ it example 2
|
✓ it example 2
|
||||||
|
|
||||||
|
PASS Tests\PHPUnit\CustomAffixes\InvalidTestName
|
||||||
|
✓ it runs file names like `@#$%^&()-_=+.php`
|
||||||
|
|
||||||
|
PASS Tests\PHPUnit\CustomAffixes\ATestWithSpaces
|
||||||
|
✓ it runs file names like `A Test With Spaces.php`
|
||||||
|
|
||||||
|
PASS Tests\PHPUnit\CustomAffixes\AdditionalFileExtensionspec
|
||||||
|
✓ it runs file names like `AdditionalFileExtension.spec.php`
|
||||||
|
|
||||||
|
PASS Tests\PHPUnit\CustomAffixes\ManyExtensionsclasstest
|
||||||
|
✓ it runs file names like `ManyExtensions.class.test.php`
|
||||||
|
|
||||||
|
PASS Tests\PHPUnit\CustomAffixes\TestCaseWithQuotes
|
||||||
|
✓ it runs file names like `Test 'Case' With Quotes.php`
|
||||||
|
|
||||||
|
PASS Tests\PHPUnit\CustomAffixes\kebabcasespec
|
||||||
|
✓ it runs file names like `kebab-case-spec.php`
|
||||||
|
|
||||||
|
PASS Tests\PHPUnit\CustomAffixes\snakecasespec
|
||||||
|
✓ it runs file names like `snake_case_spec.php`
|
||||||
|
|
||||||
PASS Tests\PHPUnit\CustomTestCase\UsesPerDirectory
|
PASS Tests\PHPUnit\CustomTestCase\UsesPerDirectory
|
||||||
✓ closure was bound to CustomTestCase
|
✓ closure was bound to CustomTestCase
|
||||||
|
|
||||||
@ -188,5 +209,5 @@
|
|||||||
✓ it is a test
|
✓ it is a test
|
||||||
✓ it uses correct parent class
|
✓ it uses correct parent class
|
||||||
|
|
||||||
Tests: 7 skipped, 108 passed
|
Tests: 7 skipped, 115 passed
|
||||||
|
|
||||||
10
tests/PHPUnit/CustomAffixes/@#$%^&()-_=+.php
Normal file
10
tests/PHPUnit/CustomAffixes/@#$%^&()-_=+.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE: To preserve cross-platform testing compatibility we cannot use ! * and
|
||||||
|
* other Windows reserved characters in this test's filename.
|
||||||
|
*
|
||||||
|
* See https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
|
||||||
|
*/
|
||||||
|
|
||||||
|
it(sprintf('runs file names like `%s`', basename(__FILE__)))->assertTrue(true);
|
||||||
3
tests/PHPUnit/CustomAffixes/A Test With Spaces.php
Normal file
3
tests/PHPUnit/CustomAffixes/A Test With Spaces.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
it(sprintf('runs file names like `%s`', basename(__FILE__)))->assertTrue(true);
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
it(sprintf('runs file names like `%s`', basename(__FILE__)))->assertTrue(true);
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
it(sprintf('runs file names like `%s`', basename(__FILE__)))->assertTrue(true);
|
||||||
3
tests/PHPUnit/CustomAffixes/Test 'Case' With Quotes.php
Normal file
3
tests/PHPUnit/CustomAffixes/Test 'Case' With Quotes.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
it(sprintf('runs file names like `%s`', basename(__FILE__)))->assertTrue(true);
|
||||||
3
tests/PHPUnit/CustomAffixes/kebab-case-spec.php
Normal file
3
tests/PHPUnit/CustomAffixes/kebab-case-spec.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
it(sprintf('runs file names like `%s`', basename(__FILE__)))->assertTrue(true);
|
||||||
3
tests/PHPUnit/CustomAffixes/snake_case_spec.php
Normal file
3
tests/PHPUnit/CustomAffixes/snake_case_spec.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
it(sprintf('runs file names like `%s`', basename(__FILE__)))->assertTrue(true);
|
||||||
@ -13,7 +13,13 @@ test('visual snapshot of test suite on success', function () {
|
|||||||
|
|
||||||
$process->run();
|
$process->run();
|
||||||
|
|
||||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
return preg_replace([
|
||||||
|
'#\\x1b[[][^A-Za-z]*[A-Za-z]#',
|
||||||
|
'/(Tests\\\PHPUnit\\\CustomAffixes\\\InvalidTestName)([A-Za-z0-9]*)/',
|
||||||
|
], [
|
||||||
|
'',
|
||||||
|
'$1',
|
||||||
|
], $process->getOutput());
|
||||||
};
|
};
|
||||||
|
|
||||||
if (getenv('REBUILD_SNAPSHOTS')) {
|
if (getenv('REBUILD_SNAPSHOTS')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user