Skip to content
Snippets Groups Projects
Commit 06a4ab04 authored by Jan Kuchař's avatar Jan Kuchař
Browse files

test fn.assertFunction.wrongNumberOfArguments: added assertion for messages

parent 3343ecf9
No related branches found
No related tags found
No related merge requests found
......@@ -4,15 +4,23 @@ require __DIR__ . '/bootstrap.php';
require __DIR__ . '/testClasses.php';
use function Grifart\AssertFunction\{assertFunction, optional, parameters};
use Tester\Assert;
$position = 'assert-function-signature/tests/fn.assertFunction.wrongNumberOfArguments.phpt:9';
$f1 = function(T1 $t1, T2 $t2): T3 {return new T3;};
// Wrong number of arguments
Assert::exception(function () use ($f1) {
assertFunction($f1, parameters(T1::class), T3::class);
}, \AssertionError::class);
Assert::exception(
function () use ($f1) {
assertFunction($f1, parameters(T1::class), T3::class);
},
\AssertionError::class,
"$position Given wrong number of parameters. Expected 1, 2 given."
);
Assert::exception(function () use ($f1) {
assertFunction($f1, parameters(T1::class, T2::class, T1::class), T3::class);
}, \AssertionError::class);
Assert::exception(
function () use ($f1) {
assertFunction($f1, parameters(T1::class, T2::class, T1::class), T3::class);
},
\AssertionError::class,
"$position Given wrong number of parameters. Expected 3, 2 given."
);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment