Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMaurício Meneghini Fauth <mauricio@fauth.dev>2021-09-02 19:20:50 +0300
committerMaurício Meneghini Fauth <mauricio@fauth.dev>2021-09-02 19:20:50 +0300
commit8f2f3eff405c1d724ad502ed3bdcb0a5cef72671 (patch)
treea2b07578a6b302ffbd9b8d4505aa44211369a2fc /test
parent5725516656e8d537adab523cfe5db3baf2057921 (diff)
Remove the `Core::isValid` method
This improves the type checking and simplifies the code. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'test')
-rw-r--r--test/classes/CoreTest.php411
1 files changed, 0 insertions, 411 deletions
diff --git a/test/classes/CoreTest.php b/test/classes/CoreTest.php
index fd2a1f22f6..6b1427c940 100644
--- a/test/classes/CoreTest.php
+++ b/test/classes/CoreTest.php
@@ -600,49 +600,6 @@ class CoreTest extends AbstractNetworkTestCase
}
/**
- * Test for Core::ifSetOr
- */
- public function testVarSet(): void
- {
- $default = 'foo';
- $in = 'bar';
- $out = Core::isValid($in, 'similar', $default) ? $in : $default;
- $this->assertEquals($in, $out);
- }
-
- /**
- * Test for Core::ifSetOr
- */
- public function testVarSetWrongType(): void
- {
- $default = 'foo';
- $in = 'bar';
- $out = Core::isValid($in, 'boolean', $default) ? $in : $default;
- $this->assertEquals($out, $default);
- }
-
- /**
- * Test for Core::ifSetOr
- */
- public function testVarNotSet(): void
- {
- $default = 'foo';
- // $in is not set!
- $out = Core::isValid($in, 'similar', $default) ? $in : $default;
- $this->assertEquals($out, $default);
- }
-
- /**
- * Test for Core::ifSetOr
- */
- public function testVarNotSetNoDefault(): void
- {
- // $in is not set!
- $out = Core::isValid($in, 'similar', null) ? $in : null;
- $this->assertNull($out);
- }
-
- /**
* Test for unserializing
*
* @param string $url URL to test
@@ -703,374 +660,6 @@ class CoreTest extends AbstractNetworkTestCase
}
/**
- * Test for Core::isValid
- *
- * @param mixed $var Variable to check
- * @param mixed $type Type
- * @param mixed $compare Compared value
- *
- * @dataProvider providerTestNoVarType
- */
- public function testNoVarType($var, $type, $compare): void
- {
- $this->assertTrue(Core::isValid($var, $type, $compare));
- }
-
- /**
- * Data provider for testNoVarType
- *
- * @return array
- */
- public static function providerTestNoVarType(): array
- {
- return [
- [
- 0,
- false,
- 0,
- ],
- [
- 0,
- false,
- 1,
- ],
- [
- 1,
- false,
- null,
- ],
- [
- 1.1,
- false,
- null,
- ],
- [
- '',
- false,
- null,
- ],
- [
- ' ',
- false,
- null,
- ],
- [
- '0',
- false,
- null,
- ],
- [
- 'string',
- false,
- null,
- ],
- [
- [],
- false,
- null,
- ],
- [
- [
- 1,
- 2,
- 3,
- ],
- false,
- null,
- ],
- [
- true,
- false,
- null,
- ],
- [
- false,
- false,
- null,
- ],
- ];
- }
-
- /**
- * Test for Core::isValid
- */
- public function testVarNotSetAfterTest(): void
- {
- Core::isValid($var);
- $this->assertFalse(isset($var));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testNotSet(): void
- {
- $this->assertFalse(Core::isValid($var));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testEmptyString(): void
- {
- $var = '';
- $this->assertFalse(Core::isValid($var));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testNotEmptyString(): void
- {
- $var = '0';
- $this->assertTrue(Core::isValid($var));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testZero(): void
- {
- $var = 0;
- $this->assertTrue(Core::isValid($var));
- $this->assertTrue(Core::isValid($var, 'int'));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testNullFail(): void
- {
- $var = null;
- $this->assertFalse(Core::isValid($var));
-
- $var = 'null_text';
- $this->assertFalse(Core::isValid($var, 'null'));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testNotSetArray(): void
- {
- $array = ['x' => null];
- $this->assertFalse(Core::isValid($array['x']));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testScalarString(): void
- {
- $var = 'string';
- $this->assertTrue(Core::isValid($var, 'len'));
- $this->assertTrue(Core::isValid($var, 'scalar'));
- $this->assertTrue(Core::isValid($var));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testScalarInt(): void
- {
- $var = 1;
- $this->assertTrue(Core::isValid($var, 'int'));
- $this->assertTrue(Core::isValid($var, 'scalar'));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testScalarFloat(): void
- {
- $var = 1.1;
- $this->assertTrue(Core::isValid($var, 'float'));
- $this->assertTrue(Core::isValid($var, 'double'));
- $this->assertTrue(Core::isValid($var, 'scalar'));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testScalarBool(): void
- {
- $var = true;
- $this->assertTrue(Core::isValid($var, 'scalar'));
- $this->assertTrue(Core::isValid($var, 'bool'));
- $this->assertTrue(Core::isValid($var, 'boolean'));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testNotScalarArray(): void
- {
- $var = ['test'];
- $this->assertFalse(Core::isValid($var, 'scalar'));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testNotScalarNull(): void
- {
- $var = null;
- $this->assertFalse(Core::isValid($var, 'scalar'));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testNumericInt(): void
- {
- $var = 1;
- $this->assertTrue(Core::isValid($var, 'numeric'));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testNumericFloat(): void
- {
- $var = 1.1;
- $this->assertTrue(Core::isValid($var, 'numeric'));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testNumericZero(): void
- {
- $var = 0;
- $this->assertTrue(Core::isValid($var, 'numeric'));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testNumericString(): void
- {
- $var = '+0.1';
- $this->assertTrue(Core::isValid($var, 'numeric'));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testValueInArray(): void
- {
- $var = 'a';
- $this->assertTrue(Core::isValid($var, ['a', 'b']));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testValueNotInArray(): void
- {
- $var = 'c';
- $this->assertFalse(Core::isValid($var, ['a', 'b']));
- }
-
- /**
- * Test for Core::isValid
- */
- public function testNumericIdentical(): void
- {
- $var = 1;
- $compare = 1;
- $this->assertTrue(Core::isValid($var, 'identic', $compare));
-
- $var = 1;
- $compare += 2;
- $this->assertFalse(Core::isValid($var, 'identic', $compare));
-
- $var = 1;
- $compare = '1';
- $this->assertFalse(Core::isValid($var, 'identic', $compare));
- }
-
- /**
- * Test for Core::isValid
- *
- * @param mixed $var Variable
- * @param mixed $compare Compare
- *
- * @dataProvider provideTestSimilarType
- */
- public function testSimilarType($var, $compare): void
- {
- $this->assertTrue(Core::isValid($var, 'similar', $compare));
- $this->assertTrue(Core::isValid($var, 'equal', $compare));
- $this->assertTrue(Core::isValid($compare, 'similar', $var));
- $this->assertTrue(Core::isValid($compare, 'equal', $var));
- }
-
- /**
- * Data provider for testSimilarType
- *
- * @return array
- */
- public function provideTestSimilarType(): array
- {
- return [
- [
- 1,
- 1,
- ],
- [
- 1.5,
- 1.5,
- ],
- [
- true,
- true,
- ],
- [
- 'string',
- 'string',
- ],
- [
- [
- 1,
- 2,
- 3.4,
- ],
- [
- 1,
- 2,
- 3.4,
- ],
- ],
- [
- [
- 1,
- '2',
- '3.4',
- 5,
- 'text',
- ],
- [
- '1',
- '2',
- 3.4,
- '5',
- ],
- ],
- ];
- }
-
- /**
- * Test for Core::isValid
- */
- public function testOtherTypes(): void
- {
- $var = new class {
- };
- $this->assertFalse(Core::isValid($var, 'class'));
- }
-
- /**
* Test for unserializing
*
* @param string $data Serialized data