From 15ff72afb0abd4a3467cec0c6d3f85cac43a696b Mon Sep 17 00:00:00 2001 From: Andrey Savchenko Date: Tue, 22 Jan 2019 16:14:14 +0200 Subject: [PATCH] Added WooCommerce events. Fixes #29 --- CHANGELOG.md | 3 +++ src/Event/WooCommerce_Events.php | 24 ++++++++++++++++++++++++ src/Provider/Hook_Event_Provider.php | 12 +++++++----- tests/Event/EventTest.php | 14 ++++++++++++++ 4 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 src/Event/WooCommerce_Events.php diff --git a/CHANGELOG.md b/CHANGELOG.md index c6ee2c9..5dbd195 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased +### Added +- WooCommerce events + ### Fixed - headers error from new line in Server Timing diff --git a/src/Event/WooCommerce_Events.php b/src/Event/WooCommerce_Events.php new file mode 100644 index 0000000..8f31d37 --- /dev/null +++ b/src/Event/WooCommerce_Events.php @@ -0,0 +1,24 @@ + new Core_Events(), - 'genesis' => new Genesis_Events(), - 'hybrid' => new Hybrid_Events(), - 'tha' => new THA_Events(), - 'yoast' => new Yoast_Events(), + 'core' => new Core_Events(), + 'genesis' => new Genesis_Events(), + 'hybrid' => new Hybrid_Events(), + 'tha' => new THA_Events(), + 'woocommerce' => new WooCommerce_Events(), + 'yoast' => new Yoast_Events(), ]; }; } diff --git a/tests/Event/EventTest.php b/tests/Event/EventTest.php index f9bbbaa..809d476 100644 --- a/tests/Event/EventTest.php +++ b/tests/Event/EventTest.php @@ -7,6 +7,7 @@ use Rarst\Laps\Event\Core_Events; use Rarst\Laps\Event\Genesis_Events; use Rarst\Laps\Event\Hybrid_Events; use Rarst\Laps\Event\THA_Events; +use Rarst\Laps\Event\WooCommerce_Events; use Rarst\Laps\Event\Yoast_Events; use Rarst\Laps\Tests\LapsTestCase; @@ -62,6 +63,19 @@ class EventTest extends LapsTestCase { $this->assertNotEmpty( $events ); } + public function testWooCommerce() { + + $woocommerce = new WooCommerce_Events(); + $this->assertEmpty( $woocommerce->get_events() ); + + $this->getMockBuilder( 'WooCommerce' )->allowMockingUnknownTypes()->getMock(); + + $events = $woocommerce->get_events(); + + $this->assertInternalType( 'array', $events ); + $this->assertNotEmpty( $events ); + } + public function testYoast() { $yoast = new Yoast_Events();