Closed borkweb closed 2 years ago
~Whoops, I guess I need to iterate on the slic
stuff. Switching back to draft.~ Done.
@JasonTheAdams - I tried to make a half-step to minimize the extra class and interface, but that actually made things more complex when trying to mock rather than extend...Soooooo, I just went with your suggestion and Config
is now a proper Facade and we have a new class (ConfigComponents
) to offload the static calls to. Added a pile of tests for all of that.
I don't like the readability of this, though.
I just chatted with @lucatume and he showed me a nice way to have the super approachable class while making the statics testable. I'm going to give that a try and see if I can dial it back to testable simplicity.
Update: The @backupStaticAttributes
annotation in PHPUnit didn't play nicely with some Codeception components, so I'm not implementing it this way.
Alrighty. This approach brings us back to a super-simple Config
class without the Facade approach, for readability purposes. This gives us something that engineers that are not deeply steeped in OOP can look at and understand while also giving us a testable object. Approachable and armored code 👍
I did attempt to leverage @backupStaticAttributes
in PHPUnit, but Codeception\Util\Annotation::reflectedClasses
was a problem and blacklisting that static attribute didn't work as expected. So, instead, I've opted to add Config::reset()
, which brings the attributes back to their original state. That method is being invoked within the test class ::tearDown()
method.
This PR adds a
StellarWP\DB\Config
class that is merely a string store, so it is all a pile of static shenanigans. Added docs on initialization and configuration.Additionally, I tacked on the work to convert tric to slic.