‪TYPO3CMS  11.5
FileSpoolTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Symfony\Component\Mailer\Envelope;
21 use Symfony\Component\Mailer\Transport\NullTransport;
22 use Symfony\Component\Mime\Address;
23 use Symfony\Component\Mime\RawMessage;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
31 class ‪FileSpoolTest extends UnitTestCase
32 {
36  protected ‪$resetSingletonInstances = true;
37 
38  protected ?‪FileSpool ‪$subject;
39 
43  protected function ‪setUp(): void
44  {
45  parent::setUp();
46  $this->subject = new ‪FileSpool(‪Environment::getVarPath() . '/spool/');
47  $this->subject->setMessageLimit(10);
48  $this->subject->setTimeLimit(1);
49  }
50 
55  public function ‪spoolsMessagesCorrectly(int $count): void
56  {
57  for ($i = 1; $i <= $count; $i++) {
58  $this->subject->send(
59  new RawMessage('test message ' . $i),
60  new Envelope(new Address('sender@example.com'), [new Address('recipient@example.com')])
61  );
62  }
63 
64  self::assertEquals($count, $this->subject->flushQueue(new NullTransport()));
65  }
66 
72  public static function ‪messageCountProvider(): array
73  {
74  return [
75  'spools 0 messages' => [0],
76  'spools 1 message' => [1],
77  'spools 2 messages' => [2],
78  ];
79  }
80 }
‪TYPO3\CMS\Core\Tests\Unit\Mail\FileSpoolTest\messageCountProvider
‪static array messageCountProvider()
Definition: FileSpoolTest.php:71
‪TYPO3\CMS\Core\Tests\Unit\Mail
Definition: FileSpoolTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Mail\FileSpoolTest
Definition: FileSpoolTest.php:32
‪TYPO3\CMS\Core\Mail\FileSpool
Definition: FileSpool.php:40
‪TYPO3\CMS\Core\Tests\Unit\Mail\FileSpoolTest\spoolsMessagesCorrectly
‪spoolsMessagesCorrectly(int $count)
Definition: FileSpoolTest.php:54
‪TYPO3\CMS\Core\Tests\Unit\Mail\FileSpoolTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: FileSpoolTest.php:35
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:43
‪TYPO3\CMS\Core\Tests\Unit\Mail\FileSpoolTest\setUp
‪setUp()
Definition: FileSpoolTest.php:42
‪TYPO3\CMS\Core\Tests\Unit\Mail\FileSpoolTest\$subject
‪FileSpool $subject
Definition: FileSpoolTest.php:37
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static string getVarPath()
Definition: Environment.php:218