@@ -15,12 +15,44 @@ require __DIR__ . '/../bootstrap.php';
1515
1616Assert::exception (function () {
1717 Validators::assert (true , 'int ' );
18- }, Nette \Utils \AssertionException::class, 'The variable expects to be int, boolean given. ' );
18+ }, Nette \Utils \AssertionException::class, 'The variable expects to be int, bool given. ' );
19+
20+ Assert::exception (function () {
21+ Validators::assert ('' , 'int ' );
22+ }, Nette \Utils \AssertionException::class, "The variable expects to be int, string '' given. " );
23+
24+ Assert::exception (function () {
25+ Validators::assert (str_repeat ('x ' , 1000 ), 'int ' );
26+ }, Nette \Utils \AssertionException::class, 'The variable expects to be int, string given. ' );
1927
2028Assert::exception (function () {
2129 Validators::assert ('1.0 ' , 'int|float ' );
2230}, Nette \Utils \AssertionException::class, "The variable expects to be int or float, string '1.0' given. " );
2331
32+ Assert::exception (function () {
33+ Validators::assert (null , 'int ' );
34+ }, Nette \Utils \AssertionException::class, 'The variable expects to be int, null given. ' );
35+
36+ Assert::exception (function () {
37+ Validators::assert (1.0 , 'int ' );
38+ }, Nette \Utils \AssertionException::class, 'The variable expects to be int, float 1.0 given. ' );
39+
40+ Assert::exception (function () {
41+ Validators::assert (1 , 'float ' );
42+ }, Nette \Utils \AssertionException::class, 'The variable expects to be float, int 1 given. ' );
43+
44+ Assert::exception (function () {
45+ Validators::assert ([], 'int ' );
46+ }, Nette \Utils \AssertionException::class, 'The variable expects to be int, array given. ' );
47+
48+ Assert::exception (function () {
49+ Validators::assert (new stdClass , 'int ' );
50+ }, Nette \Utils \AssertionException::class, 'The variable expects to be int, object stdClass given. ' );
51+
2452Assert::exception (function () {
2553 Validators::assert (1 , 'string|integer:2..5 ' , 'variable ' );
26- }, Nette \Utils \AssertionException::class, 'The variable expects to be string or integer in range 2..5, integer given. ' );
54+ }, Nette \Utils \AssertionException::class, 'The variable expects to be string or integer in range 2..5, int 1 given. ' );
55+
56+ Assert::exception (function () {
57+ Validators::assert ('x ' , '?int ' );
58+ }, Nette \Utils \AssertionException::class, "The variable expects to be ?int, string 'x' given. " );
0 commit comments