settings = SettingsController::getInstance(); $this->urlDecorator = new UrlDecorator(WPFunctions::get(), $this->settings); } public function testItDoesntDoAnythingWhenNoReferralId() { $this->settings->set(ReferralDetector::REFERRAL_SETTING_NAME, null); $url = 'http://example.com'; expect($this->urlDecorator->decorate($url))->equals($url); } public function testItCorrectlyAddsReferralId() { $this->settings->set(ReferralDetector::REFERRAL_SETTING_NAME, 'abcdefgh'); expect($this->urlDecorator->decorate('http://example.com/')) ->equals('http://example.com/?ref=abcdefgh'); expect($this->urlDecorator->decorate('http://example.com/?param=value')) ->equals('http://example.com/?param=value&ref=abcdefgh'); expect($this->urlDecorator->decorate('http://example.com/?param=value#hash/?param=val')) ->equals('http://example.com/?param=value&ref=abcdefgh#hash/?param=val'); } }