Jyxo\Mail\SenderTest::testCompleteEmail PHP Method

testCompleteEmail() public method

Tests a complete email message with all settings.
public testCompleteEmail ( )
    public function testCompleteEmail()
    {
        // Email
        $from = new Email\Address('[email protected]', 'Blog.cz');
        $email = $this->getEmail();
        $email->setFrom($from)->addReplyTo($from)->setPriority(Email::PRIORITY_NORMAL)->setInReplyTo('[email protected]', ['[email protected]', '[email protected]'])->setConfirmReadingTo($from)->addHeader(new Email\Header('Organization', 'Blog.cz'))->addTo(new Email\Address('[email protected]'))->addCc(new Email\Address('[email protected]', 'Test Test3'))->addCc(new Email\Address('[email protected]'))->addBcc(new Email\Address('[email protected]', 'Příliš žluťoučký kůň'));
        // Charset
        $sender = new Sender();
        $charset = 'iso-8859-2';
        $sender->setCharset($charset);
        $this->assertEquals($charset, $sender->getCharset());
        // X-mailer
        $xmailer = 'Blog.cz';
        $sender->setXmailer($xmailer);
        $this->assertEquals($xmailer, $sender->getXmailer());
        // Hostname
        $this->assertEquals('localhost', $sender->getHostname());
        $hostname = 'blog.cz';
        $sender->setHostname($hostname);
        $this->assertEquals($hostname, $sender->getHostname());
        // Encoding
        $reflection = new \ReflectionClass(\Jyxo\Mail\Encoding::class);
        foreach ($reflection->getConstants() as $encoding) {
            $sender->setEncoding($encoding);
            $this->assertEquals($encoding, $sender->getEncoding());
        }
        try {
            $sender->setEncoding('dummy-encoding');
            $this->fail(sprintf('Expected exception %s.', \InvalidArgumentException::class));
        } catch (\PHPUnit_Framework_AssertionFailedError $e) {
            throw $e;
        } catch (\Exception $e) {
            // Correctly thrown exception
            $this->assertInstanceOf(\InvalidArgumentException::class, $e);
        }
        // Email
        $sender->setEmail($email);
        $this->assertSame($email, $sender->getEmail());
        // Sending
        $sender->setEncoding(Encoding::BASE64);
        $result = $sender->send(Sender::MODE_NONE);
        $this->assertResult('sender-complete.eml', $result);
    }