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...
Auf dieser Seite können Sie das Online-Video Quick Intro To Unit Testing WordPress Plugins By Example mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Plugin Machine 20 Januar 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 806 Mal angesehen und es wurde von 12 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!