protected function setResponse($allow, $message) { $mock = $this->getMock(CleantalkComponent::className(), ['sendRequest'], [['apiKey' => CLEANTALK_TEST_API_KEY]]); $mock->expects($this->once())->method('sendRequest')->will($this->returnValue(new CleantalkResponse(['allow' => $allow, 'comment' => $message]))); Yii::$app->set('antispam', $mock); }
protected function getSendRequestMock($response) { $mock = $this->getMock(CleantalkComponent::className(), ['sendRequest'], [['apiKey' => CLEANTALK_TEST_API_KEY]]); $mock->expects($this->once())->method('sendRequest')->will($this->returnValue(new CleantalkResponse($response))); return $mock; }