Skip to content

Commit

Permalink
nette/tester 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 21, 2024
1 parent a6d3a6d commit c022ca1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 32 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -19,7 +19,7 @@
"nette/utils": "^4.0"
},
"require-dev": {
"nette/tester": "^2.4",
"nette/tester": "^2.5.2",
"tracy/tracy": "^2.8",
"phpstan/phpstan-nette": "^1.0"
},
Expand Down
13 changes: 6 additions & 7 deletions tests/Schema/Expect.anyOf.phpt
Expand Up @@ -229,13 +229,12 @@ test('First is default', function () {
});


test('Empty set', function () {
Assert::exception(
fn() => Expect::anyOf(),
Nette\InvalidStateException::class,
'The enumeration must not be empty.',
);
});
testException(
'Empty set',
fn() => Expect::anyOf(),
Nette\InvalidStateException::class,
'The enumeration must not be empty.',
);


test('normalization', function () {
Expand Down
11 changes: 5 additions & 6 deletions tests/Schema/Expect.array.phpt
Expand Up @@ -310,12 +310,11 @@ test('arrayOf() & keys II.', function () {
});


test('arrayOf() error', function () {
Assert::exception(
fn() => Expect::arrayOf(['a' => Expect::string()]),
TypeError::class,
);
});
testException(
'arrayOf() error',
fn() => Expect::arrayOf(['a' => Expect::string()]),
TypeError::class,
);


test('type[]', function () {
Expand Down
11 changes: 5 additions & 6 deletions tests/Schema/Expect.list.phpt
Expand Up @@ -99,9 +99,8 @@ test('listOf() & scalar', function () {
});


test('listOf() & error', function () {
Assert::exception(
fn() => Expect::listOf(['a' => Expect::string()]),
TypeError::class,
);
});
testException(
'listOf() & error',
fn() => Expect::listOf(['a' => Expect::string()]),
TypeError::class,
);
11 changes: 5 additions & 6 deletions tests/Schema/Expect.structure.phpt
Expand Up @@ -101,12 +101,11 @@ test('array items', function () {
});


test('default value must be readonly', function () {
Assert::exception(
fn() => Expect::structure([])->default([]),
Nette\InvalidStateException::class,
);
});
testException(
'default value must be readonly',
fn() => Expect::structure([])->default([]),
Nette\InvalidStateException::class,
);


test('with indexed item', function () {
Expand Down
7 changes: 1 addition & 6 deletions tests/bootstrap.php
Expand Up @@ -15,15 +15,10 @@

// configure environment
Tester\Environment::setup();
Tester\Environment::setupFunctions();
date_default_timezone_set('Europe/Prague');


function test(string $title, Closure $function): void
{
$function();
}


function checkValidationErrors(Closure $function, array $messages): Nette\Schema\ValidationException
{
$e = Assert::exception($function, Nette\Schema\ValidationException::class);
Expand Down

0 comments on commit c022ca1

Please sign in to comment.