File: EmbeddedFileTest.php

package info (click to toggle)
libphp-swiftmailer 5.2.2-1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,532 kB
  • ctags: 6,451
  • sloc: php: 26,587; xml: 22; sh: 18; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 1,742 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php

class Swift_Mime_EmbeddedFileTest extends Swift_Mime_AttachmentTest
{
    public function testNestingLevelIsAttachment()
    {
        //Overridden
    }

    public function testNestingLevelIsEmbedded()
    {
        $file = $this->_createEmbeddedFile($this->_createHeaderSet(),
            $this->_createEncoder(), $this->_createCache()
            );
        $this->assertEquals(
            Swift_Mime_MimeEntity::LEVEL_RELATED, $file->getNestingLevel()
            );
    }

    public function testIdIsAutoGenerated()
    {
        $headers = $this->_createHeaderSet(array(), false);
        $headers->shouldReceive('addIdHeader')
                ->once()
                ->with('Content-ID', '/^.*?@.*?$/D');

        $file = $this->_createEmbeddedFile($headers, $this->_createEncoder(),
            $this->_createCache()
            );
    }

    public function testDefaultDispositionIsInline()
    {
        $headers = $this->_createHeaderSet(array(), false);
        $headers->shouldReceive('addParameterizedHeader')
                ->once()
                ->with('Content-Disposition', 'inline');
        $headers->shouldReceive('addParameterizedHeader')
                ->zeroOrMoreTimes();

        $file = $this->_createEmbeddedFile($headers, $this->_createEncoder(),
            $this->_createCache()
            );
    }

    // -- Private helpers

    protected function _createAttachment($headers, $encoder, $cache, $mimeTypes = array())
    {
        return $this->_createEmbeddedFile($headers, $encoder, $cache, $mimeTypes);
    }

    private function _createEmbeddedFile($headers, $encoder, $cache)
    {
        return new Swift_Mime_EmbeddedFile($headers, $encoder, $cache, new Swift_Mime_Grammar());
    }
}