AttachmentTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace Test\Mail\Provider;
  8. use OCP\Mail\Provider\Attachment;
  9. use Test\TestCase;
  10. class AttachmentTest extends TestCase {
  11. /** @var Attachment&MockObject */
  12. private Attachment $attachment;
  13. protected function setUp(): void {
  14. parent::setUp();
  15. $this->attachment = new Attachment(
  16. 'This is the contents of a file',
  17. 'example1.txt',
  18. 'text/plain',
  19. false
  20. );
  21. }
  22. public function testName(): void {
  23. // test set by constructor
  24. $this->assertEquals('example1.txt', $this->attachment->getName());
  25. // test set by setter
  26. $this->attachment->setName('example2.txt');
  27. $this->assertEquals('example2.txt', $this->attachment->getName());
  28. }
  29. public function testType(): void {
  30. // test set by constructor
  31. $this->assertEquals('text/plain', $this->attachment->getType());
  32. // test set by setter
  33. $this->attachment->setType('text/html');
  34. $this->assertEquals('text/html', $this->attachment->getType());
  35. }
  36. public function testContents(): void {
  37. // test set by constructor
  38. $this->assertEquals('This is the contents of a file', $this->attachment->getContents());
  39. // test set by setter
  40. $this->attachment->setContents('This is the modified contents of a file');
  41. $this->assertEquals('This is the modified contents of a file', $this->attachment->getContents());
  42. }
  43. public function testEmbedded(): void {
  44. // test set by constructor
  45. $this->assertEquals(false, $this->attachment->getEmbedded());
  46. // test set by setter
  47. $this->attachment->setEmbedded(true);
  48. $this->assertEquals(true, $this->attachment->getEmbedded());
  49. }
  50. }