Files
Salvatore Martire a5612458d6 test(integration): split CommandLine for reuse
CommandLine defines both logic to run occ commands in integration tests
as wel as behat steps. This is problematic as if two contexts are loaded
and both need the ability to run occ commands, they will cause a
conflict due to the steps being defined more than once.

Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
2026-09-14 19:21:35 +02:00

40 lines
927 B
PHP

<?php
/**
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
trait Mail {
// OccRunner trait is expected to be used in the class that uses this
// trait.
/**
* @var string
*/
private $fakeSmtpServerPid;
/**
* @AfterScenario
*/
public function killDummyMailServer() {
if (!$this->fakeSmtpServerPid) {
return;
}
exec('kill ' . $this->fakeSmtpServerPid);
$this->runOcc(['config:system:delete', 'mail_smtpport']);
}
/**
* @Given /^dummy mail server is listening$/
*/
public function dummyMailServerIsListening() {
// Default smtpport (25) is restricted for regular users, so the
// FakeSMTP uses 2525 instead.
$this->runOcc(explode(' ', 'config:system:set mail_smtpport --value=2525 --type integer'));
$this->fakeSmtpServerPid = exec('php features/bootstrap/FakeSMTPHelper.php >/dev/null 2>&1 & echo $!');
}
}