getFileInfo($data, $internalPath, $storage)); } else { return new \OC\Files\Node\File($root, $view, $path); } } protected function getNodeClass() { return '\OC\Files\Node\File'; } protected function getNonExistingNodeClass() { return '\OC\Files\Node\NonExistingFile'; } protected function getViewDeleteMethod() { return 'unlink'; } public function testGetContent(): void { /** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */ $root = $this->getMockBuilder('\OC\Files\Node\Root') ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory]) ->getMock(); $hook = function ($file) { throw new \Exception('Hooks are not supposed to be called'); }; $root->listen('\OC\Files', 'preWrite', $hook); $root->listen('\OC\Files', 'postWrite', $hook); $this->view->expects($this->once()) ->method('file_get_contents') ->with('/bar/foo') ->willReturn('bar'); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $this->assertEquals('bar', $node->getContent()); } public function testGetContentNotPermitted(): void { $this->expectException(\OCP\Files\NotPermittedException::class); /** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */ $root = $this->getMockBuilder('\OC\Files\Node\Root') ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory]) ->getMock(); $root->expects($this->any()) ->method('getUser') ->willReturn($this->user); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') ->willReturn($this->getFileInfo(['permissions' => 0])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->getContent(); } public function testPutContent(): void { /** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */ $root = $this->getMockBuilder('\OC\Files\Node\Root') ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory]) ->getMock(); $root->expects($this->any()) ->method('getUser') ->willReturn($this->user); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $this->view->expects($this->once()) ->method('file_put_contents') ->with('/bar/foo', 'bar') ->willReturn(true); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->putContent('bar'); } public function testPutContentNotPermitted(): void { $this->expectException(\OCP\Files\NotPermittedException::class); /** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */ $root = $this->getMockBuilder('\OC\Files\Node\Root') ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory]) ->getMock(); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->putContent('bar'); } public function testGetMimeType(): void { /** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */ $root = $this->getMockBuilder('\OC\Files\Node\Root') ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory]) ->getMock(); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') ->willReturn($this->getFileInfo(['mimetype' => 'text/plain'])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $this->assertEquals('text/plain', $node->getMimeType()); } public function testFOpenRead(): void { $stream = fopen('php://memory', 'w+'); fwrite($stream, 'bar'); rewind($stream); $root = new \OC\Files\Node\Root( $this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory, ); $hook = function ($file) { throw new \Exception('Hooks are not supposed to be called'); }; $root->listen('\OC\Files', 'preWrite', $hook); $root->listen('\OC\Files', 'postWrite', $hook); $this->view->expects($this->once()) ->method('fopen') ->with('/bar/foo', 'r') ->willReturn($stream); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $fh = $node->fopen('r'); $this->assertEquals($stream, $fh); $this->assertEquals('bar', fread($fh, 3)); } public function testFOpenWrite(): void { $stream = fopen('php://memory', 'w+'); $root = new \OC\Files\Node\Root( $this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory, ); $hooksCalled = 0; $hook = function ($file) use (&$hooksCalled) { $hooksCalled++; }; $root->listen('\OC\Files', 'preWrite', $hook); $root->listen('\OC\Files', 'postWrite', $hook); $this->view->expects($this->once()) ->method('fopen') ->with('/bar/foo', 'w') ->willReturn($stream); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $fh = $node->fopen('w'); $this->assertEquals($stream, $fh); fwrite($fh, 'bar'); rewind($fh); $this->assertEquals('bar', fread($stream, 3)); $this->assertEquals(2, $hooksCalled); } public function testFOpenReadNotPermitted(): void { $this->expectException(\OCP\Files\NotPermittedException::class); $root = new \OC\Files\Node\Root( $this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory, ); $hook = function ($file) { throw new \Exception('Hooks are not supposed to be called'); }; $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') ->willReturn($this->getFileInfo(['permissions' => 0])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->fopen('r'); } public function testFOpenReadWriteNoReadPermissions(): void { $this->expectException(\OCP\Files\NotPermittedException::class); $root = new \OC\Files\Node\Root( $this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory, ); $hook = function () { throw new \Exception('Hooks are not supposed to be called'); }; $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_UPDATE])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->fopen('w'); } public function testFOpenReadWriteNoWritePermissions(): void { $this->expectException(\OCP\Files\NotPermittedException::class); $root = new \OC\Files\Node\Root( $this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory, ); $hook = function () { throw new \Exception('Hooks are not supposed to be called'); }; $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->fopen('w'); } } ht: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>jQuery UI Autocomplete - Default functionality</title>
	<link rel="stylesheet" href="../../themes/base/all.css">
	<link rel="stylesheet" href="../demos.css">
	<script src="../../external/requirejs/require.js"></script>
	<script src="../bootstrap.js">
		var availableTags = [
			"ActionScript",
			"AppleScript",
			"Asp",
			"BASIC",
			"C",
			"C++",
			"Clojure",
			"COBOL",
			"ColdFusion",
			"Erlang",
			"Fortran",
			"Groovy",
			"Haskell",
			"Java",
			"JavaScript",
			"Lisp",
			"Perl",
			"PHP",
			"Python",
			"Ruby",
			"Scala",
			"Scheme"
		];
		$( "#tags" ).autocomplete({
			source: availableTags
		});
	</script>
</head>
<body>

<div class="ui-widget">
	<label for="tags">Tags: </label>
	<input id="tags">
</div>

<div class="demo-description">
<p>The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are tags for programming languages, give "ja" (for Java or JavaScript) a try.</p>
<p>The datasource is a simple JavaScript array, provided to the widget using the source-option.</p>
</div>
</body>
</html>