‪TYPO3CMS  10.4
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 
41  protected ‪$subject;
42 
46  protected function ‪setUp(): void
47  {
48  parent::setUp();
49  $this->subject = new ‪FileSpool(‪Environment::getVarPath() . '/spool/');
50  $this->subject->setMessageLimit(10);
51  $this->subject->setTimeLimit(1);
52  }
53 
58  public function ‪spoolsMessagesCorrectly(int $count)
59  {
60  for ($i = 1; $i <= $count; $i++) {
61  $sentMessage = $this->subject->send(
62  new RawMessage('test message ' . $i),
63  new Envelope(new Address('sender@example.com'), [new Address('recipient@example.com')])
64  );
65  }
66 
67  self::assertEquals($count, $this->subject->flushQueue(new NullTransport()));
68  }
69 
75  public static function ‪messageCountProvider()
76  {
77  return [
78  'spools 0 messages' => [0],
79  'spools 1 message' => [1],
80  'spools 2 messages' => [2],
81  ];
82  }
83 }
‪TYPO3\CMS\Core\Tests\Unit\Mail\FileSpoolTest\messageCountProvider
‪static array messageCountProvider()
Definition: FileSpoolTest.php:73
‪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:56
‪TYPO3\CMS\Core\Tests\Unit\Mail\FileSpoolTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: FileSpoolTest.php:35
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Core\Tests\Unit\Mail\FileSpoolTest\setUp
‪setUp()
Definition: FileSpoolTest.php:44
‪TYPO3\CMS\Core\Tests\Unit\Mail\FileSpoolTest\$subject
‪FileSpool $subject
Definition: FileSpoolTest.php:39
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static string getVarPath()
Definition: Environment.php:192