|
@@ 619-663 (lines=45) @@
|
| 616 |
|
$this->assertEquals($expectedMessage, $builtMessage); |
| 617 |
|
} |
| 618 |
|
|
| 619 |
|
public function testBuildMessageWithAttachmentsPlain() |
| 620 |
|
{ |
| 621 |
|
$path = __DIR__ . '/test.txt'; |
| 622 |
|
$textContent = 'Dummy Content'; |
| 623 |
|
$this->makeTmpFile($path, $textContent); |
| 624 |
|
|
| 625 |
|
$encodedContent = chunk_split(base64_encode($textContent)); |
| 626 |
|
$type = 'text/plain'; |
| 627 |
|
$title = 'Test File'; |
| 628 |
|
$message = 'Plain text message'; |
| 629 |
|
|
| 630 |
|
$archangel = new Archangel(); |
| 631 |
|
|
| 632 |
|
$boundaryMixedProperty = $this->getProtectedProperty('boundaryMixed'); |
| 633 |
|
$boundaryMixed = $boundaryMixedProperty->getValue($archangel); |
| 634 |
|
$plainMsgMethod = $this->getProtectedMethod('buildPlainMessageHeader'); |
| 635 |
|
$plainMsgHeaders = $plainMsgMethod->invoke($archangel); |
| 636 |
|
|
| 637 |
|
$expectedMessage = array(); |
| 638 |
|
array_push($expectedMessage, "--{$boundaryMixed}"); |
| 639 |
|
$expectedMessage += $plainMsgHeaders; |
| 640 |
|
array_push($expectedMessage, $message); |
| 641 |
|
array_push($expectedMessage, "--{$boundaryMixed}"); |
| 642 |
|
array_push($expectedMessage, "Content-Type: {$type}; name=\"{$title}\""); |
| 643 |
|
array_push($expectedMessage, 'Content-Transfer-Encoding: base64'); |
| 644 |
|
array_push($expectedMessage, 'Content-Disposition: attachment'); |
| 645 |
|
array_push($expectedMessage, ''); |
| 646 |
|
array_push($expectedMessage, $encodedContent); |
| 647 |
|
array_push($expectedMessage, "--{$boundaryMixed}--"); |
| 648 |
|
$expectedMessage = implode(Archangel::LINE_BREAK, $expectedMessage); |
| 649 |
|
|
| 650 |
|
$plainMessageProperty = $this->getProtectedProperty('plainMessage'); |
| 651 |
|
$plainMessageProperty->setValue($archangel, $message); |
| 652 |
|
$htmlMessageProperty = $this->getProtectedProperty('htmlMessage'); |
| 653 |
|
$htmlMessageProperty->setValue($archangel, ''); |
| 654 |
|
$attachmentProperty = $this->getProtectedProperty('attachments'); |
| 655 |
|
$attachmentProperty->setValue($archangel, array( |
| 656 |
|
array('path' => $path, 'type' => $type, 'title' => $title) |
| 657 |
|
)); |
| 658 |
|
$buildMethod = $this->getProtectedMethod('buildMessageWithAttachments'); |
| 659 |
|
$builtMessage = $buildMethod->invoke($archangel); |
| 660 |
|
|
| 661 |
|
unlink($path); |
| 662 |
|
$this->assertEquals($expectedMessage, $builtMessage); |
| 663 |
|
} |
| 664 |
|
|
| 665 |
|
public function testBuildMessageWithAttachmentsHtml() |
| 666 |
|
{ |
|
@@ 665-709 (lines=45) @@
|
| 662 |
|
$this->assertEquals($expectedMessage, $builtMessage); |
| 663 |
|
} |
| 664 |
|
|
| 665 |
|
public function testBuildMessageWithAttachmentsHtml() |
| 666 |
|
{ |
| 667 |
|
$path = __DIR__ . '/test.txt'; |
| 668 |
|
$textContent = 'Dummy Content'; |
| 669 |
|
$this->makeTmpFile($path, $textContent); |
| 670 |
|
|
| 671 |
|
$encodedContent = chunk_split(base64_encode($textContent)); |
| 672 |
|
$type = 'text/plain'; |
| 673 |
|
$title = 'Test File'; |
| 674 |
|
$message = '<p>HTML Message.</p>'; |
| 675 |
|
|
| 676 |
|
$archangel = new Archangel(); |
| 677 |
|
|
| 678 |
|
$boundaryMixedProperty = $this->getProtectedProperty('boundaryMixed'); |
| 679 |
|
$boundaryMixed = $boundaryMixedProperty->getValue($archangel); |
| 680 |
|
$htmlMsgMethod = $this->getProtectedMethod('buildHtmlMessageHeader'); |
| 681 |
|
$htmlMsgHeaders = $htmlMsgMethod->invoke($archangel); |
| 682 |
|
|
| 683 |
|
$expectedMessage = array(); |
| 684 |
|
array_push($expectedMessage, "--{$boundaryMixed}"); |
| 685 |
|
$expectedMessage += $htmlMsgHeaders; |
| 686 |
|
array_push($expectedMessage, $message); |
| 687 |
|
array_push($expectedMessage, "--{$boundaryMixed}"); |
| 688 |
|
array_push($expectedMessage, "Content-Type: {$type}; name=\"{$title}\""); |
| 689 |
|
array_push($expectedMessage, 'Content-Transfer-Encoding: base64'); |
| 690 |
|
array_push($expectedMessage, 'Content-Disposition: attachment'); |
| 691 |
|
array_push($expectedMessage, ''); |
| 692 |
|
array_push($expectedMessage, $encodedContent); |
| 693 |
|
array_push($expectedMessage, "--{$boundaryMixed}--"); |
| 694 |
|
$expectedMessage = implode(Archangel::LINE_BREAK, $expectedMessage); |
| 695 |
|
|
| 696 |
|
$plainMessageProperty = $this->getProtectedProperty('plainMessage'); |
| 697 |
|
$plainMessageProperty->setValue($archangel, ''); |
| 698 |
|
$htmlMessageProperty = $this->getProtectedProperty('htmlMessage'); |
| 699 |
|
$htmlMessageProperty->setValue($archangel, $message); |
| 700 |
|
$attachmentProperty = $this->getProtectedProperty('attachments'); |
| 701 |
|
$attachmentProperty->setValue($archangel, array( |
| 702 |
|
array('path' => $path, 'type' => $type, 'title' => $title) |
| 703 |
|
)); |
| 704 |
|
$buildMethod = $this->getProtectedMethod('buildMessageWithAttachments'); |
| 705 |
|
$builtMessage = $buildMethod->invoke($archangel); |
| 706 |
|
|
| 707 |
|
unlink($path); |
| 708 |
|
$this->assertEquals($expectedMessage, $builtMessage); |
| 709 |
|
} |
| 710 |
|
|
| 711 |
|
public function testBuildMessageWithAttachmentsMultipart() |
| 712 |
|
{ |