respect-validation/tests/unit/Rules/NotBlankTest.php

72 lines
1.5 KiB
PHP
Raw Normal View History

2015-10-14 06:02:53 +02:00
<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
2015-10-14 06:02:53 +02:00
*/
declare(strict_types=1);
2015-10-14 06:02:53 +02:00
namespace Respect\Validation\Rules;
use Respect\Validation\Test\RuleTestCase;
2015-10-14 06:02:53 +02:00
use stdClass;
/**
* @group rule
*
* @covers \Respect\Validation\Rules\NotBlank
*
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Gabriel Caruso <carusogabriel34@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
2015-10-14 06:02:53 +02:00
*/
final class NotBlankTest extends RuleTestCase
2015-10-14 06:02:53 +02:00
{
/**
* {@inheritDoc}
2015-10-14 06:02:53 +02:00
*/
public static function providerForValidInput(): array
2015-10-14 06:02:53 +02:00
{
$object = new stdClass();
$object->foo = true;
2015-10-14 06:02:53 +02:00
$rule = new NotBlank();
return [
[$rule, 1],
[$rule, ' oi'],
[$rule, [5]],
[$rule, [1]],
[$rule, $object],
];
2015-10-14 06:02:53 +02:00
}
/**
* {@inheritDoc}
2015-10-14 06:02:53 +02:00
*/
public static function providerForInvalidInput(): array
2015-10-14 06:02:53 +02:00
{
$rule = new NotBlank();
2015-10-18 03:44:47 +02:00
return [
[$rule, null],
[$rule, ''],
[$rule, []],
[$rule, ' '],
[$rule, 0],
[$rule, '0'],
[$rule, 0],
[$rule, '0.0'],
[$rule, false],
[$rule, ['']],
[$rule, [' ']],
[$rule, [0]],
[$rule, ['0']],
[$rule, [false]],
[$rule, [[''], [0]]],
[$rule, new stdClass()],
2015-10-18 03:44:47 +02:00
];
2015-10-14 06:02:53 +02:00
}
}