feat: toHavePrivateMethodsBesides, toHaveProtectedMethodsBesides, toHavePublicMethodsBesides

This commit is contained in:
Nuno Maduro
2024-08-09 00:24:24 +01:00
parent 347bcfd8a8
commit b6bf01148f
14 changed files with 196 additions and 11 deletions

View File

@ -1,6 +1,6 @@
PASS Tests\Arch
✓ arch "base" preset
✓ arch "php" preset
✓ arch "strict" preset
✓ arch "security" preset
✓ globals
@ -831,6 +831,10 @@
✓ opposite missing prefix
✓ opposite has prefix
PASS Tests\Features\Expect\toHavePrivateMethodsBesides
✓ pass
✓ failures
PASS Tests\Features\Expect\toHaveProperties
✓ pass
✓ failures
@ -849,6 +853,14 @@
✓ failures with message and Any matcher
✓ not failures
PASS Tests\Features\Expect\toHaveProtectedMethodsBesides
✓ pass
✓ failures
PASS Tests\Features\Expect\toHavePublicMethodsBesides
✓ pass
✓ failures
PASS Tests\Features\Expect\toHaveSameSize
✓ failures with wrong type
✓ pass
@ -1547,4 +1559,4 @@
WARN Tests\Visual\Version
- visual snapshot of help command output
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 17 todos, 24 skipped, 1078 passed (2632 assertions)
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 17 todos, 24 skipped, 1084 passed (2644 assertions)

View File

@ -0,0 +1,12 @@
<?php
use Pest\Arch\Exceptions\ArchExpectationFailedException;
use Tests\Fixtures\Arch\ToHavePublicMethodsBesides\UserController;
test('pass', function () {
expect(UserController::class)->not->toHavePrivateMethodsBesides(['privateMethod']);
});
test('failures', function () {
expect(UserController::class)->not->toHavePrivateMethodsBesides([]);
})->throws(ArchExpectationFailedException::class);

View File

@ -0,0 +1,12 @@
<?php
use Pest\Arch\Exceptions\ArchExpectationFailedException;
use Tests\Fixtures\Arch\ToHavePublicMethodsBesides\UserController;
test('pass', function () {
expect(UserController::class)->not->toHaveProtectedMethodsBesides(['protectedMethod']);
});
test('failures', function () {
expect(UserController::class)->not->toHaveProtectedMethodsBesides([]);
})->throws(ArchExpectationFailedException::class);

View File

@ -0,0 +1,12 @@
<?php
use Pest\Arch\Exceptions\ArchExpectationFailedException;
use Tests\Fixtures\Arch\ToHavePublicMethodsBesides\UserController;
test('pass', function () {
expect(UserController::class)->not->toHavePublicMethodsBesides(['publicMethod']);
});
test('failures', function () {
expect(UserController::class)->not->toHavePublicMethodsBesides([]);
})->throws(ArchExpectationFailedException::class);

View File

@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace Tests\Fixtures\Arch\ToHavePublicMethodsBesides;
class UserController
{
public function publicMethod(): string
{
return '';
}
protected function protectedMethod(): string
{
return '';
}
private function privateMethod(): string
{
return '';
}
}

View File

@ -16,7 +16,7 @@ $run = function () {
test('parallel', function () use ($run) {
expect($run('--exclude-group=integration'))
->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 17 todos, 19 skipped, 1064 passed (2602 assertions)')
->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 17 todos, 19 skipped, 1070 passed (2612 assertions)')
->toContain('Parallel: 3 processes');
})->skipOnWindows();