getDebug example


        return $this->appVariable->getSession();
    }

    public function getEnvironment(): string
    {
        return $this->appVariable->getEnvironment();
    }

    public function getDebug(): bool
    {
        return $this->appVariable->getDebug();
    }

    /** * @param string|list<string>|null $types * * @return array<mixed> */
    public function getFlashes(string|array|null $types = null): array
    {
        return $this->appVariable->getFlashes($types);
    }
}


    public function send(RawMessage $message, Envelope $envelope = null): ?SentMessage
    {
        $exception = null;

        while ($transport = $this->getNextTransport()) {
            try {
                return $transport->send($message$envelope);
            } catch (TransportExceptionInterface $e) {
                $exception ??= new TransportException('All transports failed.');
                $exception->appendDebug(sprintf("Transport \"%s\": %s\n", $transport$e->getDebug()));
                $this->deadTransports[$transport] = microtime(true);
            }
        }

        throw $exception ?? new TransportException('No transports found.');
    }

    public function __toString(): string
    {
        return $this->getNameSymbol().'('.implode(' ', array_map('strval', $this->transports)).')';
    }

    

                $this->stream->flush();
            } catch (TransportExceptionInterface $e) {
                throw $e;
            } catch (\Exception $e) {
                $this->stream->terminate();
                $this->started = false;
                $this->getLogger()->debug(sprintf('Email transport "%s" stopped', __CLASS__));
                throw $e;
            }
            $this->mtaResult = $this->executeCommand("\r\n.\r\n", [250]);
            $message->appendDebug($this->stream->getDebug());
            $this->lastMessageTime = microtime(true);
        } catch (TransportExceptionInterface $e) {
            $e->appendDebug($this->stream->getDebug());
            $this->lastMessageTime = 0;
            throw $e;
        }
    }

    /** * @internal since version 6.1, to be made private in 7.0 * * @final since version 6.1, to be made private in 7.0 */

        $this->appVariable = new AppVariable();
    }

    /** * @dataProvider debugDataProvider */
    public function testDebug($debugFlag)
    {
        $this->appVariable->setDebug($debugFlag);

        $this->assertEquals($debugFlag$this->appVariable->getDebug());
    }

    public static function debugDataProvider()
    {
        return [
            'debug on' => [true],
            'debug off' => [false],
        ];
    }

    public function testEnvironment()
    {
$t2 = $this->createMock(TransportInterface::class);
        $e2 = new TransportException();
        $e2->appendDebug('Debug message 2');
        $t2->expects($this->once())->method('send')->will($this->throwException($e2));
        $t2->expects($this->once())->method('__toString')->willReturn('t2');

        $t = new RoundRobinTransport([$t1$t2]);

        try {
            $t->send(new RawMessage(''));
        } catch (TransportExceptionInterface $e) {
            $this->assertStringContainsString('Transport "t1": Debug message 1', $e->getDebug());
            $this->assertStringContainsString('Transport "t2": Debug message 2', $e->getDebug());

            return;
        }

        $this->fail('Expected exception was not thrown!');
    }

    private function assertTransports(RoundRobinTransport $transport, int $cursor, array $deadTransports)
    {
        $p = new \ReflectionProperty($transport, 'cursor');
        
Home | Imprint | This part of the site doesn't use cookies.