mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Tests - increase code coverage
This commit is contained in:
@@ -152,6 +152,10 @@ class RegexTest extends BaseTestCase
|
|||||||
{
|
{
|
||||||
$string = 'Lorem ipsum dolor sit amet';
|
$string = 'Lorem ipsum dolor sit amet';
|
||||||
|
|
||||||
|
$beginning = '';
|
||||||
|
self::assertFalse(Regex::startsWith($string, $beginning));
|
||||||
|
self::assertFalse(Regex::startsWith('', $string));
|
||||||
|
|
||||||
$beginning = 'Lor';
|
$beginning = 'Lor';
|
||||||
self::assertTrue(Regex::startsWith($string, $beginning));
|
self::assertTrue(Regex::startsWith($string, $beginning));
|
||||||
|
|
||||||
@@ -247,6 +251,9 @@ class RegexTest extends BaseTestCase
|
|||||||
{
|
{
|
||||||
self::assertTrue(Regex::contains($this->simpleText, 'ipsum'));
|
self::assertTrue(Regex::contains($this->simpleText, 'ipsum'));
|
||||||
self::assertFalse(Regex::contains($this->simpleText, 'neque'));
|
self::assertFalse(Regex::contains($this->simpleText, 'neque'));
|
||||||
|
|
||||||
|
self::assertFalse(Regex::contains($this->simpleText, '.'));
|
||||||
|
self::assertTrue(Regex::contains($this->simpleText, 'l'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsFileName()
|
public function testIsFileName()
|
||||||
@@ -457,6 +464,18 @@ class RegexTest extends BaseTestCase
|
|||||||
self::assertEquals($expected, Regex::getArrayValuesByPattern($pattern, $dataArray, true));
|
self::assertEquals($expected, Regex::getArrayValuesByPattern($pattern, $dataArray, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function testGetUrlPatternWithProtocolRequired()
|
||||||
|
{
|
||||||
|
$pattern = '/^([a-z]+:\/\/)([\da-z\.-]+)\.([a-z\.]{2,6})(\/)?([\w\.\-]*)?(\?)?([\w \.\-\/=&]*)\/?$/i';
|
||||||
|
self::assertEquals($pattern, Regex::getUrlPattern(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function testGetUrlPatternWithoutProtocol()
|
||||||
|
{
|
||||||
|
$pattern = '/^([a-z]+:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})(\/)?([\w\.\-]*)?(\?)?([\w \.\-\/=&]*)\/?$/i';
|
||||||
|
self::assertEquals($pattern, Regex::getUrlPattern());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $array The array that should be filtered
|
* @param array $array The array that should be filtered
|
||||||
* @param string $arrayColumnKey Column name
|
* @param string $arrayColumnKey Column name
|
||||||
|
|||||||
Reference in New Issue
Block a user