<div>Hi, </div><div><span style="color: rgb(160, 160, 168); "><br></span></div><div><span style="color: rgb(160, 160, 168); ">On Wednesday, 3 July 2013 at 2:08 PM, Dieter Adriaenssens wrote:</span></div>
                <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
                    <span><div><div><div>2013/7/3 Ayush Chaudhary <<a href="mailto:ayushchd@gmail.com">ayushchd@gmail.com</a>>:</div><blockquote type="cite"><div><div>Hi,</div><div><br></div><div>Is there a reason why validation.lib.php is not a class with public static</div><div>method? Is it okay to convert it to a class with all methods' access</div><div>specifier as public static?</div></div></blockquote><div><br></div><div>Did you mean the PMA_SQLValidator class in</div><div>libraries/sqlvalidator.class.php? I didn't find a validation.lib.php,</div><div>or something similar, in the PMA codebase, that contains a class.</div><div>(libraries/config/validate.lib.php doesn't contain a class)</div><div><br></div></div></div></span></blockquote><div>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</div><div><br></div><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;"><span><div><div><div></div><div>Assuming you mean PMA_SQLValidator, this is not a static class, ie. it</div><div>has to be instanciated (= turned into an object), so it can't have</div><div>static methods. [1]</div><div>To use (or test) this class, you have to create an instance and call</div><div>the methods from that instance, fe.</div><div><br></div><div>$validator = new PMA_SQLValidator();</div><div><br></div><div>$validator->start();</div><div><br></div><div>(see libraries/sqlvalidator.lib.php for an example on how to</div><div>instanciate and use the PMA_SQLValidator class)</div><div><br></div><div>BTW : Testing a class instance can sometimes be tricky, especially if</div><div>it communicates with, or uses another class. If this is the case, you</div><div>will have to use Mock objects [0] and Stubs to simulate the expected</div><div>behaviour of the other class.</div><div><br></div></div></div></span></blockquote><div>I wanted to use mocking and just set expectations with parameters, but that won't be possible unless these libraries are converted to classes </div><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;"><span><div><div><div></div><div>I hope this helps.</div><div><br></div><div>[0] <a href="http://phpunit.de/manual/3.0/en/mock-objects.html">http://phpunit.de/manual/3.0/en/mock-objects.html</a></div><div>[1] explanation of instances and static members. It's explained for</div><div>Java so the syntax doesn't match 100% with PHP, but the concept is</div><div>analogous : <a href="http://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html">http://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html</a></div><div><br></div><div>Kind regards,</div><div><br></div><div>Dieter</div><div><br></div><div><br></div><blockquote type="cite"><div><div>--</div><div>Ayush Chaudhary</div><div><br></div><div><br></div><div>------------------------------------------------------------------------------</div><div>This <a href="http://SF.net">SF.net</a> email is sponsored by Windows:</div><div><br></div><div>Build for Windows Store.</div><div><br></div><div><a href="http://p.sf.net/sfu/windows-dev2dev">http://p.sf.net/sfu/windows-dev2dev</a></div><div>_______________________________________________</div><div>Phpmyadmin-devel mailing list</div><div><a href="mailto:Phpmyadmin-devel@lists.sourceforge.net">Phpmyadmin-devel@lists.sourceforge.net</a></div><div><a href="https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel">https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel</a></div></div></blockquote><div><br></div><div><br></div><div><br></div><div>--</div><div>Kind regards,</div><div><br></div><div>Dieter Adriaenssens</div><div><br></div><div>------------------------------------------------------------------------------</div><div>This <a href="http://SF.net">SF.net</a> email is sponsored by Windows:</div><div><br></div><div>Build for Windows Store.</div><div><br></div><div><a href="http://p.sf.net/sfu/windows-dev2dev">http://p.sf.net/sfu/windows-dev2dev</a></div><div>_______________________________________________</div><div>Phpmyadmin-devel mailing list</div><div><a href="mailto:Phpmyadmin-devel@lists.sourceforge.net">Phpmyadmin-devel@lists.sourceforge.net</a></div><div><a href="https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel">https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel</a></div></div></div></span>
                 
                 
                 
                 
                </blockquote>
                 
                <div>
                    Thanks,
                </div><div>Ayush</div>