respect-validation/tests/unit/Rules/AbstractRegexRuleTest.php
Henrique Moody fa030637cc
Fix wrong call to PHPUnit assertions
The assertion methods are all static, therefore they should be called
with self::assert* instead of $this->assert*.
2017-11-12 14:35:19 +01:00

37 lines
1.1 KiB
PHP

<?php
/*
* 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.md"
* file that was distributed with this source code.
*/
namespace Respect\Validation\Rules;
use PHPUnit\Framework\TestCase;
class AbstractRegexRuleTest extends TestCase
{
public function testValidateCleanShouldReturnOneIfPatternIsFound()
{
$regexRuleMock = $this->getMockForAbstractClass(AbstractRegexRule::class);
$regexRuleMock->expects($this->once())
->method('getPregFormat')
->will($this->returnValue('/^Respect$/'));
self::assertEquals(1, $regexRuleMock->validateClean('Respect'));
}
public function testValidateCleanShouldReturnZeroIfPatternIsNotFound()
{
$regexRuleMock = $this->getMockForAbstractClass(AbstractRegexRule::class);
$regexRuleMock->expects($this->once())
->method('getPregFormat')
->will($this->returnValue('/^Respect$/'));
self::assertEquals(0, $regexRuleMock->validateClean('Validation'));
}
}