diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-03-07 10:03:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-07 10:03:00 +0100 |
commit | 3156d95e14049ea5490fe50fa39db95e23ff9f9e (patch) | |
tree | 63c9203cdf1bcd355f8232930f7f2f569c00266a /tests | |
parent | 65cc155a1168ef0307d4d6bbe593611c34d1b89b (diff) | |
parent | 16ac8eaac9779f9ab297ab99fa5211e37563002c (diff) | |
download | nextcloud-server-3156d95e14049ea5490fe50fa39db95e23ff9f9e.tar.gz nextcloud-server-3156d95e14049ea5490fe50fa39db95e23ff9f9e.zip |
Merge pull request #8652 from nextcloud/navigation-controller-etag
Add ETag to NavigationController
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Core/Controller/NavigationControllerTest.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/Core/Controller/NavigationControllerTest.php b/tests/Core/Controller/NavigationControllerTest.php index 1143ed003f0..86173405c1c 100644 --- a/tests/Core/Controller/NavigationControllerTest.php +++ b/tests/Core/Controller/NavigationControllerTest.php @@ -23,6 +23,7 @@ namespace Tests\Core\Controller; use OC\Core\Controller\NavigationController; +use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\INavigationManager; use OCP\IRequest; @@ -126,4 +127,34 @@ class NavigationControllerTest extends TestCase { } } + public function testGetAppNavigationEtagMatch() { + $navigation = [ ['id' => 'files', 'href' => '/index.php/apps/files', 'icon' => 'icon' ] ]; + $this->request->expects($this->once()) + ->method('getHeader') + ->with('If-None-Match') + ->willReturn(md5(json_encode($navigation))); + $this->navigationManager->expects($this->once()) + ->method('getAll') + ->with('link') + ->willReturn($navigation); + $actual = $this->controller->getAppsNavigation(); + $this->assertInstanceOf(DataResponse::class, $actual); + $this->assertEquals(Http::STATUS_NOT_MODIFIED, $actual->getStatus()); + } + + public function testGetSettingsNavigationEtagMatch() { + $navigation = [ ['id' => 'logout', 'href' => '/index.php/apps/files', 'icon' => 'icon' ] ]; + $this->request->expects($this->once()) + ->method('getHeader') + ->with('If-None-Match') + ->willReturn(md5(json_encode([ ['id' => 'logout', 'href' => 'logout', 'icon' => 'icon' ] ]))); + $this->navigationManager->expects($this->once()) + ->method('getAll') + ->with('settings') + ->willReturn($navigation); + $actual = $this->controller->getSettingsNavigation(); + $this->assertInstanceOf(DataResponse::class, $actual); + $this->assertEquals(Http::STATUS_NOT_MODIFIED, $actual->getStatus()); + } + } |