framework icon indicating copy to clipboard operation
framework copied to clipboard

Build WordPress factories

Open jlambe opened this issue 2 years ago • 2 comments

Build factories for core WordPress models:

  • [ ] Post factory
  • [ ] Post meta factory
  • [ ] User factory
  • [ ] User meta factory
  • [ ] Comment factory
  • [ ] Comment meta factory
  • [ ] Site factory
  • [ ] Site meta factory
  • [ ] Taxonomy factory
  • [ ] Terms factory
  • [ ] Term meta factory
  • [ ] Options factory

jlambe avatar May 15 '22 20:05 jlambe

What about Corcel ? We used it on several project and it works good. The only bad thing is that it create an extra db connection

We created an extra project based on Corcel which use the $wpdb global not to use an extra connection but it doesn't support table creation via the Schema class (https://github.com/AmphiBee/wordpress-eloquent-models)

ogorzalka avatar May 16 '22 11:05 ogorzalka

I'm aware of the Corcel project...

What I have in mind here is more to provide utility classes for unit testing that hook into WordPress core functions like wp_insert_post() for example.

Because using Eloquent does not trigger the WordPress "side effects" like filters or actions. A code feature from your application may rely on specific hook to trigger and this is something you can't have with Corcel or similar projects for example.

Those factories classes can eventually also be used to insert a new record for sure.

jlambe avatar May 16 '22 12:05 jlambe