Initial Drupal 11 with DDEV setup
This commit is contained in:
		
							
								
								
									
										83
									
								
								vendor/symfony/mailer/Test/AbstractTransportFactoryTestCase.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								vendor/symfony/mailer/Test/AbstractTransportFactoryTestCase.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,83 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * 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\Attributes\DataProvider;
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use Symfony\Component\Mailer\Exception\UnsupportedSchemeException;
 | 
			
		||||
use Symfony\Component\Mailer\Transport\Dsn;
 | 
			
		||||
use Symfony\Component\Mailer\Transport\TransportFactoryInterface;
 | 
			
		||||
use Symfony\Component\Mailer\Transport\TransportInterface;
 | 
			
		||||
 | 
			
		||||
abstract class AbstractTransportFactoryTestCase extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    protected const USER = 'u$er';
 | 
			
		||||
    protected const PASSWORD = 'pa$s';
 | 
			
		||||
 | 
			
		||||
    abstract public function getFactory(): TransportFactoryInterface;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @psalm-return iterable<array{0: Dsn, 1: bool}>
 | 
			
		||||
     */
 | 
			
		||||
    abstract public static function supportsProvider(): iterable;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @psalm-return iterable<array{0: Dsn, 1: TransportInterface}>
 | 
			
		||||
     */
 | 
			
		||||
    abstract public static function createProvider(): iterable;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @psalm-return iterable<array{0: Dsn, 1?: string|null}>
 | 
			
		||||
     */
 | 
			
		||||
    abstract public static function unsupportedSchemeProvider(): iterable;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @dataProvider supportsProvider
 | 
			
		||||
     */
 | 
			
		||||
    #[DataProvider('supportsProvider')]
 | 
			
		||||
    public function testSupports(Dsn $dsn, bool $supports)
 | 
			
		||||
    {
 | 
			
		||||
        $factory = $this->getFactory();
 | 
			
		||||
 | 
			
		||||
        $this->assertSame($supports, $factory->supports($dsn));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @dataProvider createProvider
 | 
			
		||||
     */
 | 
			
		||||
    #[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
 | 
			
		||||
     */
 | 
			
		||||
    #[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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										61
									
								
								vendor/symfony/mailer/Test/Constraint/EmailCount.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								vendor/symfony/mailer/Test/Constraint/EmailCount.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,61 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * 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
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private int $expectedValue,
 | 
			
		||||
        private ?string $transport = null,
 | 
			
		||||
        private bool $queued = false,
 | 
			
		||||
    ) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								vendor/symfony/mailer/Test/Constraint/EmailIsQueued.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								vendor/symfony/mailer/Test/Constraint/EmailIsQueued.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,39 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * 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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										36
									
								
								vendor/symfony/mailer/Test/IncompleteDsnTestTrait.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								vendor/symfony/mailer/Test/IncompleteDsnTestTrait.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,36 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * 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\Attributes\DataProvider;
 | 
			
		||||
use Symfony\Component\Mailer\Exception\IncompleteDsnException;
 | 
			
		||||
use Symfony\Component\Mailer\Transport\Dsn;
 | 
			
		||||
 | 
			
		||||
trait IncompleteDsnTestTrait
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @psalm-return iterable<array{0: Dsn}>
 | 
			
		||||
     */
 | 
			
		||||
    abstract public static function incompleteDsnProvider(): iterable;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @dataProvider incompleteDsnProvider
 | 
			
		||||
     */
 | 
			
		||||
    #[DataProvider('incompleteDsnProvider')]
 | 
			
		||||
    public function testIncompleteDsnException(Dsn $dsn)
 | 
			
		||||
    {
 | 
			
		||||
        $factory = $this->getFactory();
 | 
			
		||||
 | 
			
		||||
        $this->expectException(IncompleteDsnException::class);
 | 
			
		||||
        $factory->create($dsn);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										64
									
								
								vendor/symfony/mailer/Test/TransportFactoryTestCase.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								vendor/symfony/mailer/Test/TransportFactoryTestCase.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,64 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the Symfony package.
 | 
			
		||||
 *
 | 
			
		||||
 * (c) Fabien Potencier <fabien@symfony.com>
 | 
			
		||||
 *
 | 
			
		||||
 * 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 Psr\Log\LoggerInterface;
 | 
			
		||||
use Symfony\Component\Mailer\Transport\Dsn;
 | 
			
		||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
 | 
			
		||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A test case to ease testing Transport Factory.
 | 
			
		||||
 *
 | 
			
		||||
 * @author Konstantin Myakshin <molodchick@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * @deprecated since Symfony 7.2, use AbstractTransportFactoryTestCase instead
 | 
			
		||||
 */
 | 
			
		||||
abstract class TransportFactoryTestCase extends AbstractTransportFactoryTestCase
 | 
			
		||||
{
 | 
			
		||||
    use IncompleteDsnTestTrait;
 | 
			
		||||
 | 
			
		||||
    protected EventDispatcherInterface $dispatcher;
 | 
			
		||||
    protected HttpClientInterface $client;
 | 
			
		||||
    protected LoggerInterface $logger;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @psalm-return iterable<array{0: Dsn, 1?: string|null}>
 | 
			
		||||
     */
 | 
			
		||||
    public static function unsupportedSchemeProvider(): iterable
 | 
			
		||||
    {
 | 
			
		||||
        return [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @psalm-return iterable<array{0: Dsn}>
 | 
			
		||||
     */
 | 
			
		||||
    public static function incompleteDsnProvider(): iterable
 | 
			
		||||
    {
 | 
			
		||||
        return [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user