Jyxo\Mail\Email\Attachment\InlineStringAttachmentTest::test PHP Method

test() public method

Runs the test.
public test ( )
    public function test()
    {
        $content = file_get_contents(DIR_FILES . '/mail/logo.gif');
        $name = 'logo.gif';
        $cid = 'logo.gif';
        $mimeType = 'image/gif';
        $attachment = new InlineStringAttachment($content, $name, $cid, $mimeType);
        $this->assertEquals($content, $attachment->getContent());
        $this->assertEquals($name, $attachment->getName());
        $this->assertEquals($mimeType, $attachment->getMimeType());
        $this->assertEquals(\Jyxo\Mail\Email\Attachment::DISPOSITION_INLINE, $attachment->getDisposition());
        $this->assertTrue($attachment->isInline());
        $this->assertEquals($cid, $attachment->getCid());
        $this->assertEquals('', $attachment->getEncoding());
        // It is possible to set an encoding
        $reflection = new \ReflectionClass(\Jyxo\Mail\Encoding::class);
        foreach ($reflection->getConstants() as $encoding) {
            $attachment->setEncoding($encoding);
            $this->assertEquals($encoding, $attachment->getEncoding());
        }
        // Incompatible encoding
        try {
            $attachment->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);
        }
    }
InlineStringAttachmentTest