Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions tests/EmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,23 @@ public function testGetGravatarUrlWithEmptyEmails(): void
is(null, Email::getGravatarUrl(''));
}

public function provideCheckCases(): iterable
public function testRandomEmail(): void
{
isTrue((bool)Email::check(Email::random()));
isTrue(Email::isValid(Email::random()));

isNotSame(Email::random(), Email::random());
isNotSame(Email::random(), Email::random());
isNotSame(Email::random(), Email::random());
}

public function testCheckDns(): void
{
isFalse(Email::checkDns('123'));
isTrue(Email::checkDns('denis@gmail.com'));
}

public static function provideCheckCases(): iterable
{
return [
[
Expand Down Expand Up @@ -128,7 +144,7 @@ public function provideCheckCases(): iterable
];
}

public function provideGetDomainsCases(): iterable
public static function provideGetDomainsCases(): iterable
{
return [
[
Expand Down Expand Up @@ -166,7 +182,7 @@ public function provideGetDomainsCases(): iterable
];
}

public function provideGetDomainsInAlphabeticalOrderCases(): iterable
public static function provideGetDomainsInAlphabeticalOrderCases(): iterable
{
return [
[
Expand Down Expand Up @@ -199,12 +215,12 @@ public function provideGetDomainsInAlphabeticalOrderCases(): iterable
];
}

public function getEmptyProvider(): iterable
public static function getEmptyProvider(): iterable
{
return [[[]], [false], [''], [0]];
}

public function provideGetGravatarUrlCases(): iterable
public static function provideGetGravatarUrlCases(): iterable
{
return [
0 => [
Expand Down Expand Up @@ -251,20 +267,4 @@ public function provideGetGravatarUrlCases(): iterable
],
];
}

public function testRandomEmail(): void
{
isTrue((bool)Email::check(Email::random()));
isTrue(Email::isValid(Email::random()));

isNotSame(Email::random(), Email::random());
isNotSame(Email::random(), Email::random());
isNotSame(Email::random(), Email::random());
}

public function testCheckDns(): void
{
isFalse(Email::checkDns('123'));
isTrue(Email::checkDns('denis@gmail.com'));
}
}
56 changes: 28 additions & 28 deletions tests/EnvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,6 @@
*/
class EnvTest extends PHPUnit
{
public function provideConvertOptionsCases(): iterable
{
return [
['NULL', Env::VAR_NULL, null],
['null', Env::VAR_NULL, null],

['false', Env::VAR_BOOL, false],
['FALSE', Env::VAR_BOOL, false],
['0', Env::VAR_BOOL, false],
['true', Env::VAR_BOOL, true],
['True', Env::VAR_BOOL, true],
['1', Env::VAR_BOOL, true],

['42', Env::VAR_INT, 42],
['FALSE', Env::VAR_INT, 0],

['42.42', Env::VAR_FLOAT, 42.42],
['42', Env::VAR_FLOAT, 42.0],
['FALSE', Env::VAR_FLOAT, 0.],

['"hello"', Env::VAR_STRING, 'hello'],
["'hello'", Env::VAR_STRING, 'hello'],

['"hello"', 0, '"hello"'],
["'hello'", 0, "'hello'"],
];
}

/**
* @dataProvider provideConvertOptionsCases
* @param mixed $value
Expand Down Expand Up @@ -141,4 +113,32 @@ public function testIsExists(): void
isTrue(Env::isExists('FOO_EMPTY_2'));
isFalse(Env::isExists('FOO_QWERTY_2'));
}

public static function provideConvertOptionsCases(): iterable
{
return [
['NULL', Env::VAR_NULL, null],
['null', Env::VAR_NULL, null],

['false', Env::VAR_BOOL, false],
['FALSE', Env::VAR_BOOL, false],
['0', Env::VAR_BOOL, false],
['true', Env::VAR_BOOL, true],
['True', Env::VAR_BOOL, true],
['1', Env::VAR_BOOL, true],

['42', Env::VAR_INT, 42],
['FALSE', Env::VAR_INT, 0],

['42.42', Env::VAR_FLOAT, 42.42],
['42', Env::VAR_FLOAT, 42.0],
['FALSE', Env::VAR_FLOAT, 0.],

['"hello"', Env::VAR_STRING, 'hello'],
["'hello'", Env::VAR_STRING, 'hello'],

['"hello"', 0, '"hello"'],
["'hello'", 0, "'hello'"],
];
}
}
218 changes: 109 additions & 109 deletions tests/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,6 @@ public function testInt($exepted, $actual): void
isSame($exepted, Filter::_($actual, 'int'));
}

public function provideIntCases(): iterable
{
return [
[0, null],
[0, false],
[0, ''],
[0, 0],
[1, 1],
[1, '1'],
[1, '01'],
[-1, '-01'],
[-15, ' - 1 5 '],
[-17, ' - 1 asd 7 '],
[-1, ' - 1 . 0 '],
[-1, ' - 1 , 5 '],
[-1, ' - 1 - 0 '],
[3, ' + 3'],
[-4, ' - 4'],
[-5, ' +- 5'],
[6, ' -+ 6'],
];
}

/**
* @dataProvider provideFloatCases
* @param mixed $excepted
Expand All @@ -70,38 +47,6 @@ public function testFloat($excepted, $actual, $round = null): void
}
}

public function provideFloatCases(): iterable
{
return [
[0.0, null],
[0.0, false],
[0.0, ''],
[0.0, 'asdasd'],
[0.0, 0],
[1.0, 1],
[123456789.0, 123456789],
[1.0, '1'],
[1.0, '01'],
[-1.0, '-01'],
[-10.0, ' - 1 0 '],
[-1.5, ' - 1,5 '],
[-1.5, ' - 1.5 '],
[-1.512, ' - 1.5123 ', 3],
[-15123.0, ' - 1 asd 5123 ', 3],
[15123.0, ' + 1 asd 5123 ', 3],

[-12.451, 'abc-12,451'],
[-12.452, 'abc-12.452'],
[-12.453, '-abc12.453'],
[-12.454, 'abc-12.454abc'],
[-12.455, 'abc-12. 455'],
[-12.456, 'abc-12. 456 .7'],
[2.6e-19, '26.3e-20', 20],
[2.53E-19, '25.3e-20', 100],
[2.4e-9, '24.3e-10'],
];
}

/**
* @dataProvider provideBoolCases
* @param mixed $excepted
Expand All @@ -112,60 +57,6 @@ public function testBool($excepted, $actual): void
isSame($excepted, Filter::_($actual, 'bool'));
}

public function provideBoolCases(): iterable
{
return [
[true, '1'],
[true, ' 1'],
[true, '1 '],
[true, '10'],
[true, '-1'],
[true, true],
[true, 27],
[true, 1.0],
[true, -1],
[true, -1.0],
[true, 10],
[true, 10.0],
[true, 10.0],
[true, 'true'],
[true, 'TRUE'],
[true, 'yes'],
[true, 'YES'],
[true, 'y'],
[true, 'Y'],
[true, 'oui'],
[true, 'vrai'],
[true, 'ДА'],
[true, 'Д'],
[true, '*'],
[true, '+'],
[true, '++'],
[true, '+++'],
[true, '++++'],
[true, '+++++'],

[false, ''],
[false, ' '],
[false, ' 0'],
[false, '0 '],
[false, false],
[false, null],
[false, 0],
[false, '0'],
[false, '0.'],
[false, '0.0'],
[false, '0.00'],
[false, 'false'],
[false, 'no'],
[false, 'n'],
[false, 'non'],
[false, 'faux'],
[false, 'НЕТ'],
[false, '-'],
];
}

public function testDigests(): void
{
$string = " 0 1 a2b 3c!@#$%^&*()-= <>\t";
Expand Down Expand Up @@ -362,4 +253,113 @@ public function testJson(): void
isSame($data, (array)Filter::json($obj));
isSame($data, (array)Filter::json($data));
}

public static function provideIntCases(): iterable
{
return [
[0, null],
[0, false],
[0, ''],
[0, 0],
[1, 1],
[1, '1'],
[1, '01'],
[-1, '-01'],
[-15, ' - 1 5 '],
[-17, ' - 1 asd 7 '],
[-1, ' - 1 . 0 '],
[-1, ' - 1 , 5 '],
[-1, ' - 1 - 0 '],
[3, ' + 3'],
[-4, ' - 4'],
[-5, ' +- 5'],
[6, ' -+ 6'],
];
}

public static function provideFloatCases(): iterable
{
return [
[0.0, null],
[0.0, false],
[0.0, ''],
[0.0, 'asdasd'],
[0.0, 0],
[1.0, 1],
[123456789.0, 123456789],
[1.0, '1'],
[1.0, '01'],
[-1.0, '-01'],
[-10.0, ' - 1 0 '],
[-1.5, ' - 1,5 '],
[-1.5, ' - 1.5 '],
[-1.512, ' - 1.5123 ', 3],
[-15123.0, ' - 1 asd 5123 ', 3],
[15123.0, ' + 1 asd 5123 ', 3],

[-12.451, 'abc-12,451'],
[-12.452, 'abc-12.452'],
[-12.453, '-abc12.453'],
[-12.454, 'abc-12.454abc'],
[-12.455, 'abc-12. 455'],
[-12.456, 'abc-12. 456 .7'],
[2.6e-19, '26.3e-20', 20],
[2.53E-19, '25.3e-20', 100],
[2.4e-9, '24.3e-10'],
];
}

public static function provideBoolCases(): iterable
{
return [
[true, '1'],
[true, ' 1'],
[true, '1 '],
[true, '10'],
[true, '-1'],
[true, true],
[true, 27],
[true, 1.0],
[true, -1],
[true, -1.0],
[true, 10],
[true, 10.0],
[true, 10.0],
[true, 'true'],
[true, 'TRUE'],
[true, 'yes'],
[true, 'YES'],
[true, 'y'],
[true, 'Y'],
[true, 'oui'],
[true, 'vrai'],
[true, 'ДА'],
[true, 'Д'],
[true, '*'],
[true, '+'],
[true, '++'],
[true, '+++'],
[true, '++++'],
[true, '+++++'],

[false, ''],
[false, ' '],
[false, ' 0'],
[false, '0 '],
[false, false],
[false, null],
[false, 0],
[false, '0'],
[false, '0.'],
[false, '0.0'],
[false, '0.00'],
[false, 'false'],
[false, 'no'],
[false, 'n'],
[false, 'non'],
[false, 'faux'],
[false, 'НЕТ'],
[false, '-'],
];
}
}
Loading