From 9a1e333bbdbb9b60caf04d97e38f9570bf514a31 Mon Sep 17 00:00:00 2001 From: mbiencinto Date: Thu, 8 Apr 2021 14:48:00 +0200 Subject: [PATCH] [SR-120] - add isEnabled function --- EventSubscriber/AmpOptimizerSubscriber.php | 8 ++++++++ .../EventSubscriber/AmpOptimizerSubscriberTest.php | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/EventSubscriber/AmpOptimizerSubscriber.php b/EventSubscriber/AmpOptimizerSubscriber.php index befb325..33670b0 100644 --- a/EventSubscriber/AmpOptimizerSubscriber.php +++ b/EventSubscriber/AmpOptimizerSubscriber.php @@ -133,4 +133,12 @@ public function setEnabled(bool $enabled): void { $this->config['transform_enabled'] = $enabled; } + + /** + * @return bool + */ + public function isEnabled(): bool + { + return $this->config['transform_enabled']; + } } \ No newline at end of file diff --git a/Tests/Unit/EventSubscriber/AmpOptimizerSubscriberTest.php b/Tests/Unit/EventSubscriber/AmpOptimizerSubscriberTest.php index f55d76d..306d1ff 100644 --- a/Tests/Unit/EventSubscriber/AmpOptimizerSubscriberTest.php +++ b/Tests/Unit/EventSubscriber/AmpOptimizerSubscriberTest.php @@ -278,6 +278,16 @@ public function testDisabledByProperty() $instance->onKernelResponse($event); } + /** + * Test isEnabled property + */ + public function testIsEnabledProperty() + { + $instance = $this->getInstanceDisabledByProperty(); + $instance->setEnabled(false); + $this->assertFalse($instance->isEnabled()); + } + /** * Provide instance to test with disabled by property and test calls * @return AmpOptimizerSubscriber