dont add in unit tests - so controllers which use the component can be tested easier

This commit is contained in:
bs
2026-09-15 22:03:00 -07:00
parent 0ea3971ac1
commit 49772771d0
@@ -62,7 +62,7 @@ class ContactUsComponent extends Component {
* @return \Cake\Datasource\EntityInterface|\CakeContactUs\Model\Entity\ContactUsFormSubmission * @return \Cake\Datasource\EntityInterface|\CakeContactUs\Model\Entity\ContactUsFormSubmission
*/ */
public function newContactUsForm() { public function newContactUsForm() {
if ($this->getConfig('requireCaptcha')) { if ($this->getConfig('requireCaptcha') && PHP_SAPI !== 'cli') {
$this->ContactUsFormSubmissions->addBehavior('Captcha.Captcha'); $this->ContactUsFormSubmissions->addBehavior('Captcha.Captcha');
} }
@@ -78,8 +78,7 @@ class ContactUsComponent extends Component {
if (!isset($postData)) { if (!isset($postData)) {
$postData = $this->getController()->getRequest()->getData(); $postData = $this->getController()->getRequest()->getData();
} }
$postData['client_ip'] = array_key_exists('client_ip', $postData) && $postData['client_ip'] ? $postData['client_ip'] = $postData['client_ip'] ??
$postData['client_ip'] :
($this->getConfig('clientIpHeader') ? ($this->getConfig('clientIpHeader') ?
$this->getController()->getRequest()->getHeaderLine($this->getConfig('clientIpHeader')) : $this->getController()->getRequest()->getHeaderLine($this->getConfig('clientIpHeader')) :
$this->getController()->getRequest()->clientIp() $this->getController()->getRequest()->clientIp()
@@ -90,7 +89,6 @@ class ContactUsComponent extends Component {
'contactUsFormSubmission' => $contactUsFormSubmission, 'contactUsFormSubmission' => $contactUsFormSubmission,
], $this->getController()); ], $this->getController());
$result = $event->getResult(); $result = $event->getResult();
if ($result instanceof EntityInterface) { if ($result instanceof EntityInterface) {
$postData = $result->toArray(); $postData = $result->toArray();
$contactUsFormSubmission = $this->ContactUsFormSubmissions->patchEntity($contactUsFormSubmission, $postData); $contactUsFormSubmission = $this->ContactUsFormSubmissions->patchEntity($contactUsFormSubmission, $postData);