I am writing a sample unit test that checks a title of a post for a token and if it exists add the post to a category.
In my test for this I am running into something very strange. I have a stubbed method (
Demo_Plugin::get_listing) in my test
Test_Demo_Plugin::test_categorize_post and I use the
ReflectionClass to set a private property (
listing) that would have been set in the
Demo_Plugin::get_listing -- but that doesn't run because I set it as a stubbed method...
I have a dataProvider that feeds a bunch of test data into the
Test_Demo_Plugin::test_categorize_post method and the first set of data works as expected. It feeds in the data and sets the Demo_Plugin::listing as expected. After that it stops stubbing the
Demo_Plugin::get_listing method and actually hits the method. I can't seem to figure out why a stubbed method would get called.
I even tried setting the
Demo_Plugin::listing to public and setting the property in the test class after creating the object and I have the same results. The first run through the
dataProvider works as expected, then it just stops stubbing
Demo_Plugin::get_listing and calls the actual method. How can I get it to continue to use the stub?
Thanks for any help!