mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a312cecede | |||
| 4be97ed314 | |||
| 5101b9dce3 | |||
| 2ffafd445d | |||
| 6068ef6150 | |||
| 8c0b933fcd | |||
| 991e02649a |
@ -18,15 +18,15 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1.0",
|
"php": "^8.1.0",
|
||||||
"brianium/paratest": "^7.2.7",
|
"brianium/paratest": "^7.2.9",
|
||||||
"nunomaduro/collision": "^7.9.0",
|
"nunomaduro/collision": "^7.9.0",
|
||||||
"nunomaduro/termwind": "^1.15.1",
|
"nunomaduro/termwind": "^1.15.1",
|
||||||
"pestphp/pest-plugin": "^2.1.1",
|
"pestphp/pest-plugin": "^2.1.1",
|
||||||
"pestphp/pest-plugin-arch": "^2.3.3",
|
"pestphp/pest-plugin-arch": "^2.3.3",
|
||||||
"phpunit/phpunit": "^10.3.5"
|
"phpunit/phpunit": "^10.4.0"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"phpunit/phpunit": ">10.3.5",
|
"phpunit/phpunit": ">10.4.0",
|
||||||
"sebastian/exporter": "<5.1.0",
|
"sebastian/exporter": "<5.1.0",
|
||||||
"webmozart/assert": "<1.11.0"
|
"webmozart/assert": "<1.11.0"
|
||||||
},
|
},
|
||||||
@ -52,7 +52,7 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"pestphp/pest-dev-tools": "^2.16.0",
|
"pestphp/pest-dev-tools": "^2.16.0",
|
||||||
"pestphp/pest-plugin-type-coverage": "^2.2.0",
|
"pestphp/pest-plugin-type-coverage": "^2.4.0",
|
||||||
"symfony/process": "^6.3.4"
|
"symfony/process": "^6.3.4"
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
|
|||||||
@ -967,6 +967,7 @@ final class Expectation
|
|||||||
}
|
}
|
||||||
|
|
||||||
Assert::assertInstanceOf($exception, $e, $message);
|
Assert::assertInstanceOf($exception, $e, $message);
|
||||||
|
|
||||||
$callback($e);
|
$callback($e);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -1141,4 +1142,20 @@ final class Expectation
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the value is a url
|
||||||
|
*
|
||||||
|
* @return self<TValue>
|
||||||
|
*/
|
||||||
|
public function toBeUrl(string $message = ''): self
|
||||||
|
{
|
||||||
|
if ($message === '') {
|
||||||
|
$message = "Failed asserting that {$this->value} is a url.";
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert::assertTrue(Str::isUrl((string) $this->value), $message);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '2.20.0';
|
return '2.22.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
@ -297,6 +297,7 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
array_merge_recursive($testResultSum->phpDeprecations(), $testResult->phpDeprecations()),
|
array_merge_recursive($testResultSum->phpDeprecations(), $testResult->phpDeprecations()),
|
||||||
array_merge_recursive($testResultSum->phpNotices(), $testResult->phpNotices()),
|
array_merge_recursive($testResultSum->phpNotices(), $testResult->phpNotices()),
|
||||||
array_merge_recursive($testResultSum->phpWarnings(), $testResult->phpWarnings()),
|
array_merge_recursive($testResultSum->phpWarnings(), $testResult->phpWarnings()),
|
||||||
|
$testResultSum->numberOfIssuesIgnoredByBaseline() + $testResult->numberOfIssuesIgnoredByBaseline(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,6 +326,8 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
$testResultSum->phpDeprecations(),
|
$testResultSum->phpDeprecations(),
|
||||||
$testResultSum->phpNotices(),
|
$testResultSum->phpNotices(),
|
||||||
$testResultSum->phpWarnings(),
|
$testResultSum->phpWarnings(),
|
||||||
|
$testResultSum->numberOfIssuesIgnoredByBaseline(),
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->printer->printResults(
|
$this->printer->printResults(
|
||||||
|
|||||||
@ -108,4 +108,12 @@ final class Str
|
|||||||
{
|
{
|
||||||
return sprintf('`%s` → %s', $describeDescription, $testDescription);
|
return sprintf('`%s` → %s', $describeDescription, $testDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if a given value is a valid URL.
|
||||||
|
*/
|
||||||
|
public static function isUrl(string $value): bool
|
||||||
|
{
|
||||||
|
return (bool) filter_var($value, FILTER_VALIDATE_URL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.20.0.
|
Pest Testing Framework 2.22.0.
|
||||||
|
|
||||||
USAGE: pest <file> [options]
|
USAGE: pest <file> [options]
|
||||||
|
|
||||||
@ -14,6 +14,9 @@
|
|||||||
--cache-directory [dir] ............................ Specify cache directory
|
--cache-directory [dir] ............................ Specify cache directory
|
||||||
--generate-configuration Generate configuration file with suggested settings
|
--generate-configuration Generate configuration file with suggested settings
|
||||||
--migrate-configuration ....... Migrate configuration file to current format
|
--migrate-configuration ....... Migrate configuration file to current format
|
||||||
|
--generate-baseline [file] .................... Generate baseline for issues
|
||||||
|
--use-baseline [file] ........................ Use baseline to ignore issues
|
||||||
|
--ignore-baseline ..................... Do not use baseline to ignore issues
|
||||||
|
|
||||||
SELECTION OPTIONS:
|
SELECTION OPTIONS:
|
||||||
--bail ........................... Stop execution upon first not-passed test
|
--bail ........................... Stop execution upon first not-passed test
|
||||||
@ -89,7 +92,7 @@
|
|||||||
--testdox-html [file] .. Write test results in TestDox format (HTML) to file
|
--testdox-html [file] .. Write test results in TestDox format (HTML) to file
|
||||||
--testdox-text [file] Write test results in TestDox format (plain text) to file
|
--testdox-text [file] Write test results in TestDox format (plain text) to file
|
||||||
--log-events-text [file] ............... Stream events as plain text to file
|
--log-events-text [file] ............... Stream events as plain text to file
|
||||||
--log-events-verbose-text [file] Stream events as plain text (with telemetry information) to file
|
--log-events-verbose-text [file] Stream events as plain text with extended information to file
|
||||||
--no-logging ....... Ignore logging configured in the XML configuration file
|
--no-logging ....... Ignore logging configured in the XML configuration file
|
||||||
|
|
||||||
CODE COVERAGE OPTIONS:
|
CODE COVERAGE OPTIONS:
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.20.0.
|
Pest Testing Framework 2.22.0.
|
||||||
|
|
||||||
|
|||||||
@ -590,6 +590,13 @@
|
|||||||
✓ pass
|
✓ pass
|
||||||
✓ failures
|
✓ failures
|
||||||
✓ failures with custom message
|
✓ failures with custom message
|
||||||
|
✓ not failures
|
||||||
|
|
||||||
|
PASS Tests\Features\Expect\toBeUrl
|
||||||
|
✓ pass
|
||||||
|
✓ failures
|
||||||
|
✓ failures with custom message
|
||||||
|
✓ failures with default message
|
||||||
✓ not failures
|
✓ not failures
|
||||||
|
|
||||||
PASS Tests\Features\Expect\toBeUuid
|
PASS Tests\Features\Expect\toBeUuid
|
||||||
@ -1345,4 +1352,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, 953 passed (2269 assertions)
|
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 958 passed (2281 assertions)
|
||||||
24
tests/Features/Expect/toBeUrl.php
Normal file
24
tests/Features/Expect/toBeUrl.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
|
test('pass', function () {
|
||||||
|
expect('https://pestphp.com')->toBeUrl()
|
||||||
|
->and('pestphp.com')->not->toBeUrl();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('failures', function () {
|
||||||
|
expect('pestphp.com')->toBeUrl();
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
|
test('failures with custom message', function () {
|
||||||
|
expect('pestphp.com')->toBeUrl('oh no!');
|
||||||
|
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||||
|
|
||||||
|
test('failures with default message', function () {
|
||||||
|
expect('pestphp.com')->toBeUrl();
|
||||||
|
})->throws(ExpectationFailedException::class, 'Failed asserting that pestphp.com is a url.');
|
||||||
|
|
||||||
|
test('not failures', function () {
|
||||||
|
expect('https://pestphp.com')->not->toBeUrl();
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
@ -57,8 +57,9 @@ test('failures 3', function () {
|
|||||||
expect(function () {
|
expect(function () {
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
})->toThrow(function (RuntimeException $e) {
|
})->toThrow(function (RuntimeException $e) {
|
||||||
|
//
|
||||||
});
|
});
|
||||||
})->throws(ExpectationFailedException::class, 'Failed asserting that Exception Object');
|
})->throws(ExpectationFailedException::class, 'Failed asserting that an object is an instance of class RuntimeException.');
|
||||||
|
|
||||||
test('failures 4', function () {
|
test('failures 4', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
@ -73,7 +74,7 @@ test('failures 5', function () {
|
|||||||
expect(function () {
|
expect(function () {
|
||||||
throw new Exception('actual message');
|
throw new Exception('actual message');
|
||||||
})->toThrow('expected message');
|
})->toThrow('expected message');
|
||||||
})->throws(ExpectationFailedException::class, 'Failed asserting that \'actual message\' contains "expected message".');
|
})->throws(ExpectationFailedException::class, 'Failed asserting that \'actual message\' [ASCII](length: 14) contains "expected message" [ASCII](length: 16).');
|
||||||
|
|
||||||
test('failures 6', function () {
|
test('failures 6', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
|
|||||||
@ -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, 942 passed (2254 assertions)')
|
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 947 passed (2266 assertions)')
|
||||||
->toContain('Parallel: 3 processes');
|
->toContain('Parallel: 3 processes');
|
||||||
})->skipOnWindows();
|
})->skipOnWindows();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user