diff options
Diffstat (limited to 'tests/Integration')
-rw-r--r-- | tests/Integration/Framework/ImapTest.php | 11 | ||||
-rw-r--r-- | tests/Integration/Framework/ImapTestAccount.php | 6 | ||||
-rw-r--r-- | tests/Integration/IMAP/AbstractTest.php | 4 | ||||
-rw-r--r-- | tests/Integration/IMAP/IMAPClientFactoryTest.php | 2 | ||||
-rw-r--r-- | tests/Integration/Service/FolderMapperIntegrationTest.php | 2 | ||||
-rw-r--r-- | tests/Integration/Service/MailTransmissionIntegrationTest.php | 12 | ||||
-rw-r--r-- | tests/Integration/TestCase.php | 13 |
7 files changed, 39 insertions, 11 deletions
diff --git a/tests/Integration/Framework/ImapTest.php b/tests/Integration/Framework/ImapTest.php index 4b9288f72..c0b252fb1 100644 --- a/tests/Integration/Framework/ImapTest.php +++ b/tests/Integration/Framework/ImapTest.php @@ -33,6 +33,7 @@ use OCA\Mail\Account; use OCA\Mail\Db\MailAccount; use OCA\Mail\IMAP\IMAPClientFactory; use OCP\AppFramework\QueryException; +use function in_array; trait ImapTest { @@ -55,7 +56,7 @@ trait ImapTest { $this->client = new Horde_Imap_Client_Socket([ 'username' => 'user@domain.tld', 'password' => 'mypassword', - 'hostspec' => 'localhost', + 'hostspec' => '127.0.0.1', 'port' => 993, 'secure' => 'ssl', ]); @@ -81,6 +82,14 @@ trait ImapTest { } } + public function disconnectImapAccount(): void { + if ($this->client === null) { + return; + } + + $this->client->logout(); + } + /** * @return array<string> */ diff --git a/tests/Integration/Framework/ImapTestAccount.php b/tests/Integration/Framework/ImapTestAccount.php index 0189884e1..846f332fd 100644 --- a/tests/Integration/Framework/ImapTestAccount.php +++ b/tests/Integration/Framework/ImapTestAccount.php @@ -49,14 +49,14 @@ trait ImapTestAccount { $mailAccount = new MailAccount(); $mailAccount->setUserId($this->getTestAccountUserId()); $mailAccount->setEmail('user@domain.tld'); - $mailAccount->setInboundHost('localhost'); + $mailAccount->setInboundHost('127.0.0.1'); $mailAccount->setInboundPort(993); $mailAccount->setInboundSslMode('ssl'); $mailAccount->setInboundUser('user@domain.tld'); $mailAccount->setInboundPassword(OC::$server->getCrypto()->encrypt('mypassword')); - $mailAccount->setOutboundHost('localhost'); - $mailAccount->setOutboundPort(2525); + $mailAccount->setOutboundHost('127.0.0.1'); + $mailAccount->setOutboundPort(25); $mailAccount->setOutboundUser('user@domain.tld'); $mailAccount->setOutboundPassword(OC::$server->getCrypto()->encrypt('mypassword')); $mailAccount->setOutboundSslMode('none'); diff --git a/tests/Integration/IMAP/AbstractTest.php b/tests/Integration/IMAP/AbstractTest.php index 334c395a9..2d28c9702 100644 --- a/tests/Integration/IMAP/AbstractTest.php +++ b/tests/Integration/IMAP/AbstractTest.php @@ -52,13 +52,13 @@ abstract class AbstractTest extends TestCase { $a = new MailAccount(); $a->setId(-1); $a->setName('Mail'); - $a->setInboundHost('localhost'); + $a->setInboundHost('127.0.0.1'); $a->setInboundPort(993); $a->setInboundUser($user); $a->setInboundPassword($password); $a->setInboundSslMode('ssl'); $a->setEmail($user); - $a->setOutboundHost('localhost'); + $a->setOutboundHost('127.0.0.1'); $a->setOutboundPort(465); $a->setOutboundUser($user); $a->setOutboundPassword($password); diff --git a/tests/Integration/IMAP/IMAPClientFactoryTest.php b/tests/Integration/IMAP/IMAPClientFactoryTest.php index 657ad2462..0d0ce7b4d 100644 --- a/tests/Integration/IMAP/IMAPClientFactoryTest.php +++ b/tests/Integration/IMAP/IMAPClientFactoryTest.php @@ -65,7 +65,7 @@ class IMAPClientFactoryTest extends TestCase { $mailAccount = new MailAccount(); $mailAccount->setId(123); $mailAccount->setEmail('user@domain.tld'); - $mailAccount->setInboundHost('localhost'); + $mailAccount->setInboundHost('127.0.0.1'); $mailAccount->setInboundPort(993); $mailAccount->setInboundSslMode('ssl'); $mailAccount->setInboundUser('user@domain.tld'); diff --git a/tests/Integration/Service/FolderMapperIntegrationTest.php b/tests/Integration/Service/FolderMapperIntegrationTest.php index fd08c6961..4b5381299 100644 --- a/tests/Integration/Service/FolderMapperIntegrationTest.php +++ b/tests/Integration/Service/FolderMapperIntegrationTest.php @@ -45,7 +45,7 @@ class FolderMapperIntegrationTest extends TestCase { return new Horde_Imap_Client_Socket([ 'username' => 'user@domain.tld', 'password' => 'mypassword', - 'hostspec' => 'localhost', + 'hostspec' => '127.0.0.1', 'port' => 993, 'secure' => 'ssl', ]); diff --git a/tests/Integration/Service/MailTransmissionIntegrationTest.php b/tests/Integration/Service/MailTransmissionIntegrationTest.php index 7d6f71362..097b20313 100644 --- a/tests/Integration/Service/MailTransmissionIntegrationTest.php +++ b/tests/Integration/Service/MailTransmissionIntegrationTest.php @@ -78,13 +78,13 @@ class MailTransmissionIntegrationTest extends TestCase { 'userId' => $this->user->getUID(), 'name' => 'Test User', 'email' => 'user@domain.tld', - 'inboundHost' => 'localhost', + 'inboundHost' => '127.0.0.1', 'inboundPort' => '993', 'inboundSslMode' => 'ssl', 'inboundUser' => 'user@domain.tld', 'inboundPassword' => $crypo->encrypt('mypassword'), - 'outboundHost' => 'localhost', - 'outboundPort' => '2525', + 'outboundHost' => '127.0.0.1', + 'outboundPort' => '25', 'outboundSslMode' => 'none', 'outboundUser' => 'user@domain.tld', 'outboundPassword' => $crypo->encrypt('mypassword'), @@ -107,6 +107,12 @@ class MailTransmissionIntegrationTest extends TestCase { ); } + protected function tearDown(): void { + if ($this->client !== null) { + $this->client->logout(); + } + } + public function testSendMail() { $message = NewMessageData::fromRequest($this->account, 'recipient@domain.com', null, null, 'greetings', 'hello there', []); diff --git a/tests/Integration/TestCase.php b/tests/Integration/TestCase.php index b8f98234a..7c48af1aa 100644 --- a/tests/Integration/TestCase.php +++ b/tests/Integration/TestCase.php @@ -23,6 +23,8 @@ namespace OCA\Mail\Tests\Integration; use OCA\Mail\Tests\Integration\Framework\ImapTest; use ChristophWurst\Nextcloud\Testing\TestCase as Base; +use function class_uses; +use function in_array; class TestCase extends Base { protected function setUp(): void { @@ -30,7 +32,18 @@ class TestCase extends Base { // If it's an IMAP test, we reset the test account automatically if (in_array(ImapTest::class, class_uses($this))) { + /** @var ImapTest $this */ $this->resetImapAccount(); } } + + protected function tearDown(): void { + parent::tearDown(); + + // If it's an IMAP test, we reset the test account automatically + if (in_array(ImapTest::class, class_uses($this))) { + /** @var ImapTest $this */ + $this->disconnectImapAccount(); + } + } } |