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

75 lines
1.8 KiB
PHP
Raw Normal View History

2011-09-25 14:01:28 +02:00
<?php
2015-06-08 16:47:14 +02:00
/*
* This file is part of Respect/Validation.
*
* (c) Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
declare(strict_types=1);
2011-09-25 14:01:28 +02:00
namespace Respect\Validation\Rules;
use Respect\Validation\Test\RuleTestCase;
use stdClass;
2017-11-04 11:21:40 +01:00
/**
* @group rule
*
2017-02-04 14:01:14 +01:00
* @covers \Respect\Validation\Rules\Slug
*
* @author Carlos André Ferrari <caferrari@gmail.com>
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Gabriel Caruso <carusogabriel34@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Marcel dos Santos <marcelgsantos@gmail.com>
*/
final class SlugTest extends RuleTestCase
{
2011-09-25 14:01:28 +02:00
/**
* {@inheritDoc}
2011-09-25 14:01:28 +02:00
*/
public function providerForValidInput(): array
2011-09-25 14:01:28 +02:00
{
$sut = new Slug();
2015-10-18 03:44:47 +02:00
return [
[$sut, 'o-rato-roeu-o-rei-de-roma'],
[$sut, 'o-alganet-e-um-feio'],
[$sut, 'a-e-i-o-u'],
[$sut, 'anticonstitucionalissimamente'],
2015-10-18 03:44:47 +02:00
];
2011-09-25 14:01:28 +02:00
}
/**
* {@inheritDoc}
*/
public function providerForInvalidInput(): array
2011-09-25 14:01:28 +02:00
{
$sut = new Slug();
2015-10-18 03:44:47 +02:00
return [
[$sut, ''],
[$sut, 'o-alganet-é-um-feio'],
[$sut, 'á-é-í-ó-ú'],
[$sut, '-assim-nao-pode'],
[$sut, 'assim-tambem-nao-'],
[$sut, 'nem--assim'],
[$sut, '--nem-assim'],
[$sut, 'Nem mesmo Assim'],
[$sut, 'Ou-ate-assim'],
[$sut, '-Se juntar-tudo-Então-'],
[$sut, 'eAssim-vai'],
[$sut, '@-!teste-teste'],
[$sut, '*teste-teste'],
[$sut, 123],
[$sut, []],
[$sut, 123.321],
[$sut, new stdClass()],
2015-10-18 03:44:47 +02:00
];
2011-09-25 14:01:28 +02:00
}
}