diff --git a/lib/Subscription/CaptchaRenderer.php b/lib/Subscription/CaptchaRenderer.php index c8e46ee84c..404e43456f 100644 --- a/lib/Subscription/CaptchaRenderer.php +++ b/lib/Subscription/CaptchaRenderer.php @@ -17,10 +17,14 @@ class CaptchaRenderer { /** @var CaptchaSession */ private $captcha_session; - function __construct(UrlHelper $url_helper, WPFunctions $wp, CaptchaSession $captcha_session) { + /** @var Url */ + private $subscription_url_factory; + + function __construct(UrlHelper $url_helper, WPFunctions $wp, CaptchaSession $captcha_session, Url $subscription_url_factory) { $this->url_helper = $url_helper; $this->wp = $wp; $this->captcha_session = $captcha_session; + $this->subscription_url_factory = $subscription_url_factory; } public function getCaptchaPageTitle() { @@ -91,7 +95,7 @@ class CaptchaRenderer { $width = 220; $height = 60; - $captcha_url = Url::getCaptchaImageUrl($width, $height); + $captcha_url = $this->subscription_url_factory->getCaptchaImageUrl($width, $height); $form_html .= '
'; $form_html .= '

'; diff --git a/lib/Subscription/Url.php b/lib/Subscription/Url.php index 5c9491143e..ab6cb331d8 100644 --- a/lib/Subscription/Url.php +++ b/lib/Subscription/Url.php @@ -26,8 +26,8 @@ class Url { return self::getSubscriptionUrl($post, 'captcha', null); } - static function getCaptchaImageUrl($width, $height) { - $post = self::getPost(self::getSetting('subscription.pages.captcha')); + function getCaptchaImageUrl($width, $height) { + $post = self::getPost($this->settings->get('subscription.pages.captcha')); return self::getSubscriptionUrl($post, 'captchaImage', null, ['width' => $width, 'height' => $height]); } diff --git a/tests/integration/Subscription/UrlTest.php b/tests/integration/Subscription/UrlTest.php index 89c62a05eb..8a475cbfa7 100644 --- a/tests/integration/Subscription/UrlTest.php +++ b/tests/integration/Subscription/UrlTest.php @@ -55,7 +55,7 @@ class UrlTest extends \MailPoetTest { } function testItReturnsTheCaptchaImageUrl() { - $url = Url::getCaptchaImageUrl(250, 100); + $url = $this->url->getCaptchaImageUrl(250, 100); expect($url)->notNull(); expect($url)->contains('action=captchaImage'); expect($url)->contains('endpoint=subscription');