I did something like this in developing the tests for WP-Gistpen. In my case, I took the default
post factory, as he details it, and changed the
post_type to ‘gistpen’. I was actually going to write a thing about it myself, but he got to it first, so I’m just going to repost his. You can see my factory here.
One of the things I’ll add that wasn’t mentioned in the original article is that you might want to add your new factory as part of the test unit’s general factory, which is what the first class does. I then extend the testunit case to insert my new factory, as well as add a few helper functions I used throughout the test.Edit this post on GitHub.