-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathTextDocumentCreatorTest.php
More file actions
68 lines (53 loc) · 1.94 KB
/
Copy pathTextDocumentCreatorTest.php
File metadata and controls
68 lines (53 loc) · 1.94 KB
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
<?php
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Text\Tests;
use OCA\Text\DirectEditing\TextDocumentCreator;
use OCP\IAppConfig;
use OCP\IL10N;
class TextDocumentCreatorTest extends \PHPUnit\Framework\TestCase {
private TextDocumentCreator $textDocumentCreator;
private IL10N $l10n;
private IAppConfig $appConfig;
protected function setUp(): void {
$this->l10n = $this->createMock(IL10N::class);
$this->appConfig = $this->createMock(IAppConfig::class);
$this->textDocumentCreator = new TextDocumentCreator($this->l10n, $this->appConfig);
}
public function testGetId(): void {
$this->assertEquals('textdocument', $this->textDocumentCreator->getId());
}
public function testGetName(): void {
$this->l10n->expects($this->once())
->method('t')
->with('Text document')
->willReturn('Text document');
$this->assertEquals('Text document', $this->textDocumentCreator->getName());
}
public function testGetDefaultExtension(): void {
$this->appConfig->expects($this->once())
->method('getValueString')
->with('text', 'default_file_extension', 'md')
->willReturn('md');
$this->assertEquals('md', $this->textDocumentCreator->getExtension());
}
public function testGetExtensionFromConfig(): void {
$this->appConfig->expects($this->once())
->method('getValueString')
->with('text', 'default_file_extension', 'md')
->willReturn('txt');
$this->assertEquals('txt', $this->textDocumentCreator->getExtension());
}
public function testGetDefaultMimetype(): void {
$this->assertEquals('text/markdown', $this->textDocumentCreator->getMimetype());
}
public function testGetMimetypeFromConfig(): void {
$this->appConfig->expects($this->once())
->method('getValueString')
->with('text', 'default_file_extension', 'md')
->willReturn('txt');
$this->assertEquals('text/plain', $this->textDocumentCreator->getMimetype());
}
}