aboutsummaryrefslogtreecommitdiffstats
path: root/build/integration/features/bootstrap/Mail.php
diff options
context:
space:
mode:
Diffstat (limited to 'build/integration/features/bootstrap/Mail.php')
-rw-r--r--build/integration/features/bootstrap/Mail.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/build/integration/features/bootstrap/Mail.php b/build/integration/features/bootstrap/Mail.php
new file mode 100644
index 00000000000..d48ed6399c5
--- /dev/null
+++ b/build/integration/features/bootstrap/Mail.php
@@ -0,0 +1,39 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+trait Mail {
+ // CommandLine 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->invokingTheCommand('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->invokingTheCommand('config:system:set mail_smtpport --value=2525 --type integer');
+
+ $this->fakeSmtpServerPid = exec('php features/bootstrap/FakeSMTPHelper.php >/dev/null 2>&1 & echo $!');
+ }
+}