In this video, I create a quick plugin that has phpunit setup for unit testing. Then I create a "Products" class that collects WooCommerce products. Beacuse these are unit tests which do not run with WordPress loaded, WooCommerce's WC_Product class, or any WordPress core function is not available.
In this video I introduce some basic assertions and two approaches to mocking functions and classes that are not available when I'm doing unit tests. First, I show how to use a replacement class. I also show how to use a mocking framework to mock classes.
In future videos I'll show how to do more complex mocks and introduce integration testing, which does run with WordPress, MySQL and possibly even WooCommerce loaded in the test environment.
🌲 PHP Testing Setup With Plugin Machine: https://pluginmachine.com/blog/doc/ph...
🌲 Brain Monkey Docs: https://giuseppe-mazzapica.gitbook.io...
🌲 My blog post about mocking WordPress core in unit tests: https://dev.to/shelob9/unit-testing-c...
In questa pagina del sito puoi guardare il video online Quick Intro To Unit Testing WordPress Plugins By Example della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Plugin Machine 20 gennaio 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 806 volte e gli è piaciuto 12 spettatori. Buona visione!