diff --git a/test/classes/PMA_Types_test.php b/test/classes/PMA_Types_test.php index 19f276ecbf..1481763690 100644 --- a/test/classes/PMA_Types_test.php +++ b/test/classes/PMA_Types_test.php @@ -22,10 +22,159 @@ class PMA_TypesTest extends PHPUnit_Framework_TestCase $this->object = new PMA_Types; } + /** + * Test for isUnaryOperator + */ public function testUnary() { $this->assertTrue($this->object->isUnaryOperator('IS NULL')); $this->assertFalse($this->object->isUnaryOperator('=')); } + + /** + * Test for getUnaryOperators + */ + public function testGetUnaryOperators(){ + $this->assertEquals($this->object->getUnaryOperators(), + array( + 'IS NULL', + 'IS NOT NULL', + "= ''", + "!= ''", + ) + ); + } + + /** + * Test for getNullOperators + */ + public function testGetNullOperators(){ + $this->assertEquals($this->object->getNullOperators(), + array( + 'IS NULL', + 'IS NOT NULL', + ) + ); + } + + /** + * Test for getEnumOperators + */ + public function testGetEnumOperators(){ + $this->assertEquals($this->object->getEnumOperators(), + array( + '=', + '!=', + ) + ); + } + + /** + * Test for getTextOperators + */ + public function testgetTextOperators(){ + $this->assertEquals($this->object->getTextOperators(), + array( + 'LIKE', + 'LIKE %...%', + 'NOT LIKE', + '=', + '!=', + 'REGEXP', + 'REGEXP ^...$', + 'NOT REGEXP', + "= ''", + "!= ''", + 'IN (...)', + 'NOT IN (...)', + 'BETWEEN', + 'NOT BETWEEN', + ) + ); + } + + /** + * Test for getNumberOperators + */ + public function testGetNumberOperators(){ + $this->assertEquals($this->object->getNumberOperators(), + array( + '=', + '>', + '>=', + '<', + '<=', + '!=', + 'LIKE', + 'NOT LIKE', + 'IN (...)', + 'NOT IN (...)', + 'BETWEEN', + 'NOT BETWEEN', + ) + ); + } + + /** + * @param string $type Type of field + * @param boolean $null Whether field can be NULL + * @param $output + * + * @dataProvider providerForGetTypeOperators + */ + public function testGetTypeOperators($type, $null, $output){ + $this->assertEquals( + $this->object->getTypeOperators($type, $null), + $output + ); + } + + /** + * data provider for testGetTypeOperators + */ + public function providerForGetTypeOperators(){ + return array( + array( + 'enum', + false, + array( + '=', + '!=', + ) + ), + array( + 'CHAR', + true, + array( + '=', + '>', + '>=', + '<', + '<=', + '!=', + 'LIKE', + 'NOT LIKE', + 'IN (...)', + 'NOT IN (...)', + 'BETWEEN', + 'NOT BETWEEN', + 'IS NULL', + 'IS NOT NULL', + ), + array( + 'int', + false, + array( + '=', + '!=', + ) + ), + ) + ); + } + + public function testGetTypeOperatorsHtml(){ + $this->assertTrue(true); + } } ?>