Hi,On Wednesday, 3 July 2013 at 2:08 PM, Dieter Adriaenssens wrote:2013/7/3 Ayush Chaudhary <ayushchd@gmail.com>:Hi,Is there a reason why validation.lib.php is not a class with public staticmethod? Is it okay to convert it to a class with all methods' accessspecifier as public static?Did you mean the PMA_SQLValidator class inlibraries/sqlvalidator.class.php? I didn't find a validation.lib.php,or something similar, in the PMA codebase, that contains a class.(libraries/config/validate.lib.php doesn't contain a class)Sorry for not being clear. I was referring to the library libraries/config/validate.lib.php. I am currently writing tests for libraries/config/FormDisplay.class.php, and there are numerous calls to functions from validate.lib.php which cannot be mocked because they are not contained in a class. Also, the same issue holds for libraries/config/FormDisplay.tpl.php
Assuming you mean PMA_SQLValidator, this is not a static class, ie. ithas to be instanciated (= turned into an object), so it can't havestatic methods. [1]To use (or test) this class, you have to create an instance and callthe methods from that instance, fe.$validator = new PMA_SQLValidator();$validator->start();(see libraries/sqlvalidator.lib.php for an example on how toinstanciate and use the PMA_SQLValidator class)BTW : Testing a class instance can sometimes be tricky, especially ifit communicates with, or uses another class. If this is the case, youwill have to use Mock objects [0] and Stubs to simulate the expectedbehaviour of the other class.I wanted to use mocking and just set expectations with parameters, but that won't be possible unless these libraries are converted to classes