. */ namespace SP\Tests\Mvc\Controller\Validators; use PHPUnit\Framework\TestCase; use SP\Mvc\Controller\Validators\Validator; /** * Class ValidatorTest * * @package SP\Tests\Mvc\Controller\Validators */ class ValidatorTest extends TestCase { const VALID_STRING = 'abcDE123_!'; const VALID_REGEX = '^[a-zA-Z\d_!]+$'; public function testMatchRegex() { $this->assertTrue(Validator::matchRegex(self::VALID_STRING, self::VALID_REGEX)); $regex = '^[a-zA-Z\d]+$'; $this->assertFalse(Validator::matchRegex(self::VALID_STRING, $regex)); } public function testHasLetters() { $this->assertTrue(Validator::hasLetters(self::VALID_STRING)); $string = '123_!'; $this->assertFalse(Validator::hasLetters($string)); } public function testHasUpper() { $this->assertTrue(Validator::hasUpper(self::VALID_STRING)); $string = 'abc123_!'; $this->assertFalse(Validator::hasUpper($string)); } public function testHasSymbols() { $this->assertTrue(Validator::hasSymbols(self::VALID_STRING)); $string = 'abcDE123'; $this->assertFalse(Validator::hasSymbols($string)); } public function testHasNumbers() { $this->assertTrue(Validator::hasNumbers(self::VALID_STRING)); $string = 'abcDE_!'; $this->assertFalse(Validator::hasNumbers($string)); } public function testHasLower() { $this->assertTrue(Validator::hasLower(self::VALID_STRING)); $string = 'DE123_!'; $this->assertFalse(Validator::hasLower($string)); } public function testIsRegex() { $this->assertNotFalse(Validator::isRegex(self::VALID_REGEX)); $regex = '^[a-zA-Z\d+$'; $this->assertFalse(Validator::isRegex($regex)); } }