Repository navigation
Expand file tree
/
Copy pathNotesControllerTest.php
More file actions
62 lines (49 loc) · 1.53 KB
/
Copy pathNotesControllerTest.php
File metadata and controls
62 lines (49 loc) · 1.53 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
<?php
/**
* ownCloud - Notes
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2015
*/
namespace OCA\Notes\Controller;
use PHPUnit\Framework\TestCase;
use OCP\AppFramework\App;
use OCP\Files\File;
class NotesControllerTest extends TestCase {
private $controller;
private $userId = 'test';
private $notesFolder = '/test/files/Notes';
private $fs;
public function setUp(): void {
$app = new App('notes');
$container = $app->getContainer();
$container->registerService('UserId', function ($c) {
return $this->userId;
});
$this->controller = $container->query(
'OCA\Notes\Controller\NotesController'
);
$this->fs = $container->query(
'OCP\Files\IRootFolder'
);
$this->fs->newFolder($this->notesFolder);
}
public function testUpdate() {
$note = $this->controller->create('test')->getData();
$this->assertEquals('test', $note->getContent());
$note2 = $this->controller->update($note->getId(), 'test2')->getData();
$this->assertEquals('test2', $note2->getContent());
$this->assertEquals($note->getId(), $note2->getId());
$notes = $this->controller->index()->getData();
$this->assertCount(1, $notes);
$this->assertEquals('test2', $notes[0]->getContent());
$file = $this->fs->get($this->notesFolder . '/test2.txt');
$this->assertTrue($file instanceof File);
}
public function tearDown(): void {
$this->fs->get($this->notesFolder)->delete();
}
}