blob: 283391650b5890637860ff7ecdfb5a65a4a96243 (
plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Mail\Provider;
use OCP\Mail\Provider\Attachment;
use Test\TestCase;
class AttachmentTest extends TestCase {
/** @var Attachment&MockObject */
private Attachment $attachment;
protected function setUp(): void {
parent::setUp();
$this->attachment = new Attachment(
'This is the contents of a file',
'example1.txt',
'text/plain',
false
);
}
public function testName(): void {
// test set by constructor
$this->assertEquals('example1.txt', $this->attachment->getName());
// test set by setter
$this->attachment->setName('example2.txt');
$this->assertEquals('example2.txt', $this->attachment->getName());
}
public function testType(): void {
// test set by constructor
$this->assertEquals('text/plain', $this->attachment->getType());
// test set by setter
$this->attachment->setType('text/html');
$this->assertEquals('text/html', $this->attachment->getType());
}
public function testContents(): void {
// test set by constructor
$this->assertEquals('This is the contents of a file', $this->attachment->getContents());
// test set by setter
$this->attachment->setContents('This is the modified contents of a file');
$this->assertEquals('This is the modified contents of a file', $this->attachment->getContents());
}
public function testEmbedded(): void {
// test set by constructor
$this->assertEquals(false, $this->attachment->getEmbedded());
// test set by setter
$this->attachment->setEmbedded(true);
$this->assertEquals(true, $this->attachment->getEmbedded());
}
}
|