From bf7a756714bf77fd870ccd174e85ba61389e58aa Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Wed, 17 Sep 2025 16:24:09 +0200 Subject: [PATCH] Add `symfony/mailer/Test` to denied dirs --- lib/composer/autoload_classmap.php | 3 - lib/composer/autoload_static.php | 3 - .../mailer/Test/Constraint/EmailCount.php | 65 ---------- .../mailer/Test/Constraint/EmailIsQueued.php | 39 ------ .../mailer/Test/TransportFactoryTestCase.php | 117 ------------------ .../Dependencies/Composer/iTopComposer.php | 1 + 6 files changed, 1 insertion(+), 227 deletions(-) delete mode 100644 lib/symfony/mailer/Test/Constraint/EmailCount.php delete mode 100644 lib/symfony/mailer/Test/Constraint/EmailIsQueued.php delete mode 100644 lib/symfony/mailer/Test/TransportFactoryTestCase.php diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php index 00d8c02a6..4d2ac1dbf 100644 --- a/lib/composer/autoload_classmap.php +++ b/lib/composer/autoload_classmap.php @@ -2473,9 +2473,6 @@ return array( 'Symfony\\Component\\Mailer\\Messenger\\MessageHandler' => $vendorDir . '/symfony/mailer/Messenger/MessageHandler.php', 'Symfony\\Component\\Mailer\\Messenger\\SendEmailMessage' => $vendorDir . '/symfony/mailer/Messenger/SendEmailMessage.php', 'Symfony\\Component\\Mailer\\SentMessage' => $vendorDir . '/symfony/mailer/SentMessage.php', - 'Symfony\\Component\\Mailer\\Test\\Constraint\\EmailCount' => $vendorDir . '/symfony/mailer/Test/Constraint/EmailCount.php', - 'Symfony\\Component\\Mailer\\Test\\Constraint\\EmailIsQueued' => $vendorDir . '/symfony/mailer/Test/Constraint/EmailIsQueued.php', - 'Symfony\\Component\\Mailer\\Test\\TransportFactoryTestCase' => $vendorDir . '/symfony/mailer/Test/TransportFactoryTestCase.php', 'Symfony\\Component\\Mailer\\Transport' => $vendorDir . '/symfony/mailer/Transport.php', 'Symfony\\Component\\Mailer\\Transport\\AbstractApiTransport' => $vendorDir . '/symfony/mailer/Transport/AbstractApiTransport.php', 'Symfony\\Component\\Mailer\\Transport\\AbstractHttpTransport' => $vendorDir . '/symfony/mailer/Transport/AbstractHttpTransport.php', diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php index a7ccc0f21..d0478b9c6 100644 --- a/lib/composer/autoload_static.php +++ b/lib/composer/autoload_static.php @@ -2838,9 +2838,6 @@ class ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f 'Symfony\\Component\\Mailer\\Messenger\\MessageHandler' => __DIR__ . '/..' . '/symfony/mailer/Messenger/MessageHandler.php', 'Symfony\\Component\\Mailer\\Messenger\\SendEmailMessage' => __DIR__ . '/..' . '/symfony/mailer/Messenger/SendEmailMessage.php', 'Symfony\\Component\\Mailer\\SentMessage' => __DIR__ . '/..' . '/symfony/mailer/SentMessage.php', - 'Symfony\\Component\\Mailer\\Test\\Constraint\\EmailCount' => __DIR__ . '/..' . '/symfony/mailer/Test/Constraint/EmailCount.php', - 'Symfony\\Component\\Mailer\\Test\\Constraint\\EmailIsQueued' => __DIR__ . '/..' . '/symfony/mailer/Test/Constraint/EmailIsQueued.php', - 'Symfony\\Component\\Mailer\\Test\\TransportFactoryTestCase' => __DIR__ . '/..' . '/symfony/mailer/Test/TransportFactoryTestCase.php', 'Symfony\\Component\\Mailer\\Transport' => __DIR__ . '/..' . '/symfony/mailer/Transport.php', 'Symfony\\Component\\Mailer\\Transport\\AbstractApiTransport' => __DIR__ . '/..' . '/symfony/mailer/Transport/AbstractApiTransport.php', 'Symfony\\Component\\Mailer\\Transport\\AbstractHttpTransport' => __DIR__ . '/..' . '/symfony/mailer/Transport/AbstractHttpTransport.php', diff --git a/lib/symfony/mailer/Test/Constraint/EmailCount.php b/lib/symfony/mailer/Test/Constraint/EmailCount.php deleted file mode 100644 index 47a4e621e..000000000 --- a/lib/symfony/mailer/Test/Constraint/EmailCount.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Mailer\Test\Constraint; - -use PHPUnit\Framework\Constraint\Constraint; -use Symfony\Component\Mailer\Event\MessageEvents; - -final class EmailCount extends Constraint -{ - private int $expectedValue; - private ?string $transport; - private bool $queued; - - public function __construct(int $expectedValue, ?string $transport = null, bool $queued = false) - { - $this->expectedValue = $expectedValue; - $this->transport = $transport; - $this->queued = $queued; - } - - public function toString(): string - { - return \sprintf('%shas %s "%d" emails', $this->transport ? $this->transport.' ' : '', $this->queued ? 'queued' : 'sent', $this->expectedValue); - } - - /** - * @param MessageEvents $events - */ - protected function matches($events): bool - { - return $this->expectedValue === $this->countEmails($events); - } - - /** - * @param MessageEvents $events - */ - protected function failureDescription($events): string - { - return \sprintf('the Transport %s (%d %s)', $this->toString(), $this->countEmails($events), $this->queued ? 'queued' : 'sent'); - } - - private function countEmails(MessageEvents $events): int - { - $count = 0; - foreach ($events->getEvents($this->transport) as $event) { - if ( - ($this->queued && $event->isQueued()) - || (!$this->queued && !$event->isQueued()) - ) { - ++$count; - } - } - - return $count; - } -} diff --git a/lib/symfony/mailer/Test/Constraint/EmailIsQueued.php b/lib/symfony/mailer/Test/Constraint/EmailIsQueued.php deleted file mode 100644 index 46436aa06..000000000 --- a/lib/symfony/mailer/Test/Constraint/EmailIsQueued.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Mailer\Test\Constraint; - -use PHPUnit\Framework\Constraint\Constraint; -use Symfony\Component\Mailer\Event\MessageEvent; - -final class EmailIsQueued extends Constraint -{ - public function toString(): string - { - return 'is queued'; - } - - /** - * @param MessageEvent $event - */ - protected function matches($event): bool - { - return $event->isQueued(); - } - - /** - * @param MessageEvent $event - */ - protected function failureDescription($event): string - { - return 'the Email '.$this->toString(); - } -} diff --git a/lib/symfony/mailer/Test/TransportFactoryTestCase.php b/lib/symfony/mailer/Test/TransportFactoryTestCase.php deleted file mode 100644 index 5156086ae..000000000 --- a/lib/symfony/mailer/Test/TransportFactoryTestCase.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Mailer\Test; - -use PHPUnit\Framework\TestCase; -use Psr\Log\LoggerInterface; -use Symfony\Component\Mailer\Exception\IncompleteDsnException; -use Symfony\Component\Mailer\Exception\UnsupportedSchemeException; -use Symfony\Component\Mailer\Transport\Dsn; -use Symfony\Component\Mailer\Transport\TransportFactoryInterface; -use Symfony\Component\Mailer\Transport\TransportInterface; -use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; -use Symfony\Contracts\HttpClient\HttpClientInterface; - -/** - * A test case to ease testing Transport Factory. - * - * @author Konstantin Myakshin - */ -abstract class TransportFactoryTestCase extends TestCase -{ - protected const USER = 'u$er'; - protected const PASSWORD = 'pa$s'; - - protected $dispatcher; - protected $client; - protected $logger; - - abstract public function getFactory(): TransportFactoryInterface; - - abstract public static function supportsProvider(): iterable; - - abstract public static function createProvider(): iterable; - - public static function unsupportedSchemeProvider(): iterable - { - return []; - } - - public static function incompleteDsnProvider(): iterable - { - return []; - } - - /** - * @dataProvider supportsProvider - */ - public function testSupports(Dsn $dsn, bool $supports) - { - $factory = $this->getFactory(); - - $this->assertSame($supports, $factory->supports($dsn)); - } - - /** - * @dataProvider createProvider - */ - public function testCreate(Dsn $dsn, TransportInterface $transport) - { - $factory = $this->getFactory(); - - $this->assertEquals($transport, $factory->create($dsn)); - if (str_contains('smtp', $dsn->getScheme())) { - $this->assertStringMatchesFormat($dsn->getScheme().'://%S'.$dsn->getHost().'%S', (string) $transport); - } - } - - /** - * @dataProvider unsupportedSchemeProvider - */ - public function testUnsupportedSchemeException(Dsn $dsn, ?string $message = null) - { - $factory = $this->getFactory(); - - $this->expectException(UnsupportedSchemeException::class); - if (null !== $message) { - $this->expectExceptionMessage($message); - } - - $factory->create($dsn); - } - - /** - * @dataProvider incompleteDsnProvider - */ - public function testIncompleteDsnException(Dsn $dsn) - { - $factory = $this->getFactory(); - - $this->expectException(IncompleteDsnException::class); - $factory->create($dsn); - } - - protected function getDispatcher(): EventDispatcherInterface - { - return $this->dispatcher ??= $this->createMock(EventDispatcherInterface::class); - } - - protected function getClient(): HttpClientInterface - { - return $this->client ??= $this->createMock(HttpClientInterface::class); - } - - protected function getLogger(): LoggerInterface - { - return $this->logger ??= $this->createMock(LoggerInterface::class); - } -} diff --git a/sources/Dependencies/Composer/iTopComposer.php b/sources/Dependencies/Composer/iTopComposer.php index 2578b06ad..d0512fbf0 100644 --- a/sources/Dependencies/Composer/iTopComposer.php +++ b/sources/Dependencies/Composer/iTopComposer.php @@ -88,6 +88,7 @@ class iTopComposer extends AbstractFolderAnalyzer 'symfony/http-foundation/Test', 'symfony/http-kernel/Tests', 'symfony/service-contracts/Test', + 'symfony/mailer/Test', 'symfony/mime/Test', 'symfony/routing/Tests', 'symfony/stopwatch/Tests',