mirror of
https://github.com/Respect/Validation.git
synced 2026-03-15 23:05:45 +01:00
28 lines
749 B
PHP
28 lines
749 B
PHP
<?php
|
|
namespace Respect\Validation\Rules;
|
|
|
|
class RegexTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
public function testRegexOk()
|
|
{
|
|
$v = new Regex('/^[a-z]+$/');
|
|
$this->assertTrue($v->validate('wpoiur'));
|
|
$this->assertFalse($v->validate('wPoiUur'));
|
|
|
|
$v = new Regex('/^[a-z]+$/i');
|
|
$this->assertTrue($v->validate('wPoiur'));
|
|
$this->assertTrue($v->check('wPoiur'));
|
|
$this->assertTrue($v->assert('wPoiur'));
|
|
}
|
|
|
|
/**
|
|
* @expectedException Respect\Validation\Exceptions\RegexException
|
|
*/
|
|
public function testRegexNot()
|
|
{
|
|
$v = new Regex('/^w+$/');
|
|
$this->assertFalse($v->validate('w poiur'));
|
|
$this->assertFalse($v->assert('w poiur'));
|
|
}
|
|
}
|
|
|