Global Variables TDD helper updated
I’ve update the Globals Adapter in my TDD helper package to allow accessing other global variables beside the superglobals one.
Previously, to access the someVar
global variable in code I would have written
// $someVar is a global var
$this->glad = new \tad\adapters\GlobalsAdapter();
$myVar = $this->glad->globals('someVar');
while a discriminating addition in the code now allows for a more streamlined global variable access
// $someVar is a global var
$this->glad = new \tad\adapters\GlobalsAdapter();
$myVar = $this->glad->someVar();
Normal access to someVar
global variable would use the global
keyword
global $someVar;
$myVar = $someVar;
and while that’s easier to do is also impossible to test in isolation. The Globals
adapter, along with the Functions
one, was born to satisfy my need for totally testable WordPress plugins and themes.