mirror of
https://github.com/Respect/Validation.git
synced 2026-03-15 14:55:44 +01:00
39 lines
1.5 KiB
PHP
39 lines
1.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
test('Scenario #1', catchMessages(
|
|
fn() => v::create()
|
|
->key('mysql', v::create()
|
|
->key('host', v::stringType())
|
|
->key('user', v::stringType())->key('password', v::stringType())
|
|
->key('schema', v::stringType()))
|
|
->key('postgresql', v::create()
|
|
->key('host', v::stringType())
|
|
->key('user', v::stringType())
|
|
->key('password', v::stringType())
|
|
->key('schema', v::stringType()))
|
|
->assert(['mysql' => ['host' => 42, 'schema' => 42], 'postgresql' => ['user' => 42, 'password' => 42]]),
|
|
fn(array $messages) => expect($messages)->toBe([
|
|
'__root__' => '`["mysql": ["host": 42, "schema": 42], "postgresql": ["user": 42, "password": 42]]` must pass all the rules',
|
|
'mysql' => [
|
|
'__root__' => '`.mysql` must pass all the rules',
|
|
'host' => '`.host` must be a string',
|
|
'user' => '`.user` must be present',
|
|
'password' => '`.password` must be present',
|
|
'schema' => '`.schema` must be a string',
|
|
],
|
|
'postgresql' => [
|
|
'__root__' => '`.postgresql` must pass all the rules',
|
|
'host' => '`.host` must be present',
|
|
'user' => '`.user` must be a string',
|
|
'password' => '`.password` must be a string',
|
|
'schema' => '`.schema` must be present',
|
|
],
|
|
]),
|
|
));
|