ldc-flucollector/tests/Client/UtilsTest.php

80 lines
2.3 KiB
PHP
Raw Normal View History

2023-10-04 09:45:04 +02:00
<?php
namespace Tests\Client;
use Illuminate\Support\Str;
use Tests\TestCase;
use UWIL\Flucollector\Utils;
class UtilsTest extends TestCase
{
/**
* Test Utils validator
*
* @return void
*/
public function testUtilsValidator()
{
$this->expectNotToPerformAssertions();
Utils::makeValidator([
'nullable' => null
], ['nullable' => 'nullable'])();
Utils::makeValidator([], ['sometimes' => 'sometimes'])();
Utils::makeValidator([
'int' => 2
], ['int' => 'int'])();
Utils::makeValidator([
'required' => 2
], ['required' => 'required'])();
Utils::makeValidator([
'bool' => 1
], ['bool' => 'bool'])();
Utils::makeValidator([
'bool' => 0
], ['bool' => 'bool'])();
Utils::makeValidator([
'bool' => true
], ['bool' => 'bool'])();
Utils::makeValidator([
'uuid' => (string)Str::uuid()
], ['uuid' => 'uuid|string'])();
Utils::makeValidator([
'date' => date('Y-m-d')
], ['date' => 'date'])();
Utils::makeValidator([
'email' => 'email@gmail.com'
], ['email' => 'email'])();
Utils::makeValidator([
'array' => []
], ['array' => 'array'])();
Utils::makeValidator([
'mixedCase' => 'azeZ'
], ['mixedCase' => 'mixedCase'])();
Utils::makeValidator([
'containDigit' => 'azeZ2'
], ['containDigit' => 'containDigit'])();
Utils::makeValidator([
'containSymbol' => 'azeZ2,'
], ['containSymbol' => 'containSymbol'])();
Utils::makeValidator([
'min' => 2,
], ['min' => 'min:2'])();
Utils::makeValidator([
'min' => 'az',
], ['min' => 'min:2']);
Utils::makeValidator([
'max' => 2,
], ['max' => 'max:2'])();
Utils::makeValidator([
'max' => 'az',
], ['max' => 'max:2'])();
Utils::makeValidator([
'date_format' => date('Y-m-d H:i:s'),
], ['date_format' => 'date_format:Y-m-d H:i:s'])();
Utils::makeValidator([
'closure' => 'value',
], ['closure' => [function ($attribute, $value, $fail) {
}]])();
}
}