/** * Miscellaneous calls to improve test coverage and some small tests. */ public function testMiscellaneous() { $this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed'); $this->Mail->addCustomHeader('SomeHeader: Some Value'); $this->Mail->clearCustomHeaders(); $this->Mail->clearAttachments(); $this->Mail->isHTML(false); $this->Mail->isSMTP(); $this->Mail->isMail(); $this->Mail->isSendmail(); $this->Mail->isQmail(); $this->Mail->setLanguage('fr'); $this->Mail->Sender = ''; $this->Mail->createHeader(); $this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded'); $this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed'); $this->assertTrue($this->Mail->set('AllowEmpty', null), 'Null property set failed'); $this->assertTrue($this->Mail->set('AllowEmpty', false), 'Valid property set of null property failed'); //Test pathinfo $a = '/mnt/files/飛兒樂 團光茫.mp3'; $q = PHPMailer::mb_pathinfo($a); $this->assertEquals($q['dirname'], '/mnt/files', 'UNIX dirname not matched'); $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'UNIX basename not matched'); $this->assertEquals($q['extension'], 'mp3', 'UNIX extension not matched'); $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'UNIX filename not matched'); $this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_DIRNAME), '/mnt/files', 'Dirname path element not matched'); $this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_BASENAME), '飛兒樂 團光茫.mp3', 'Basename path element not matched'); $this->assertEquals(PHPMailer::mb_pathinfo($a, 'filename'), '飛兒樂 團光茫', 'Filename path element not matched'); $a = 'c:\\mnt\\files\\飛兒樂 團光茫.mp3'; $q = PHPMailer::mb_pathinfo($a); $this->assertEquals($q['dirname'], 'c:\\mnt\\files', 'Windows dirname not matched'); $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'Windows basename not matched'); $this->assertEquals($q['extension'], 'mp3', 'Windows extension not matched'); $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'Windows filename not matched'); $this->assertEquals(PHPMailer::filenameToType('abc.jpg?xyz=1'), 'image/jpeg', 'Query string not ignored in filename'); $this->assertEquals(PHPMailer::filenameToType('abc.xyzpdq'), 'application/octet-stream', 'Default MIME type not applied to unknown extension'); //Line break normalization $eol = $this->Mail->LE; $b1 = "1\r2\r3\r"; $b2 = "1\n2\n3\n"; $b3 = "1\r\n2\r3\n"; $this->Mail->LE = "\n"; $t1 = "1{$this->Mail->LE}2{$this->Mail->LE}3{$this->Mail->LE}"; $this->assertEquals($this->Mail->fixEOL($b1), $t1, 'Failed to normalize line breaks (1)'); $this->assertEquals($this->Mail->fixEOL($b2), $t1, 'Failed to normalize line breaks (2)'); $this->assertEquals($this->Mail->fixEOL($b3), $t1, 'Failed to normalize line breaks (3)'); $this->Mail->LE = "\r\n"; $t1 = "1{$this->Mail->LE}2{$this->Mail->LE}3{$this->Mail->LE}"; $this->assertEquals($this->Mail->fixEOL($b1), $t1, 'Failed to normalize line breaks (4)'); $this->assertEquals($this->Mail->fixEOL($b2), $t1, 'Failed to normalize line breaks (5)'); $this->assertEquals($this->Mail->fixEOL($b3), $t1, 'Failed to normalize line breaks (6)'); $this->Mail->LE = $eol; }
/** * Miscellaneous calls to improve test coverage and some small tests. */ public function testMiscellaneous() { $this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed'); $this->Mail->addCustomHeader('SomeHeader: Some Value'); $this->Mail->clearCustomHeaders(); $this->Mail->clearAttachments(); $this->Mail->isHTML(false); $this->Mail->isSMTP(); $this->Mail->isMail(); $this->Mail->isSendmail(); $this->Mail->isQmail(); $this->Mail->setLanguage('fr'); $this->Mail->Sender = ''; $this->Mail->createHeader(); $this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded'); $this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed'); $this->assertTrue($this->Mail->set('AllowEmpty', null), 'Null property set failed'); $this->assertTrue($this->Mail->set('AllowEmpty', false), 'Valid property set of null property failed'); //Test pathinfo $a = '/mnt/files/飛兒樂 團光茫.mp3'; $q = PHPMailer::mb_pathinfo($a); $this->assertEquals($q['dirname'], '/mnt/files', 'UNIX dirname not matched'); $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'UNIX basename not matched'); $this->assertEquals($q['extension'], 'mp3', 'UNIX extension not matched'); $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'UNIX filename not matched'); $this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_DIRNAME), '/mnt/files', 'Dirname path element not matched'); $this->assertEquals(PHPMailer::mb_pathinfo($a, 'filename'), '飛兒樂 團光茫', 'Filename path element not matched'); $a = 'c:\\mnt\\files\\飛兒樂 團光茫.mp3'; $q = PHPMailer::mb_pathinfo($a); $this->assertEquals($q['dirname'], 'c:\\mnt\\files', 'Windows dirname not matched'); $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'Windows basename not matched'); $this->assertEquals($q['extension'], 'mp3', 'Windows extension not matched'); $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'Windows filename not matched'); }