Hi,
I was going through the existing tests. The test 'testIsHttps' under
test/classes/PMA_Config_test.php looks wrong as isHttps() should be returning true for the
second test case. However, the function isHttps() uses a local static variable, which is
why the test is passing as in the construct, the PmaAbsoluteUri is initialised with null
and isHttps() is hence returning false in all subsequent calls.
I am not sure why a local static variable was used here. A better test for this method
would be if we could reset the static variable before each assertion. Since its a local
static variable, I couldn't find a proper way to reset the static variable. Should we
not move the static variable in the scope of the class? In fact, even if we don't use
a static variable, we could just make is_https a class member and initialise it to NULL in
the constructor. This would eventually achieve the same result in a neater way.
Also, what approach do we take for resetting static variables if needed for unit testing?
One thing I came across was using Reflection_Helper::set_static_variable($class, $name,
$new_value)?
--
Ayush Chaudhary