diff options
author | Julius Härtl <jus@bitgrid.net> | 2017-06-30 11:21:15 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2017-06-30 11:21:15 +0200 |
commit | 01093604d30b1639f5e23a7be408bc7d387e39ef (patch) | |
tree | 7e3d41bc45c59251a6ee502a770f21b204b93bf8 /tests/lib/CapabilitiesManagerTest.php | |
parent | 42d9be4529cdb56997c2e37273b765677b2af7f5 (diff) | |
download | nextcloud-server-01093604d30b1639f5e23a7be408bc7d387e39ef.tar.gz nextcloud-server-01093604d30b1639f5e23a7be408bc7d387e39ef.zip |
Add tests for public capabilties
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'tests/lib/CapabilitiesManagerTest.php')
-rw-r--r-- | tests/lib/CapabilitiesManagerTest.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/lib/CapabilitiesManagerTest.php b/tests/lib/CapabilitiesManagerTest.php index 75fbdb8d89f..139940eb306 100644 --- a/tests/lib/CapabilitiesManagerTest.php +++ b/tests/lib/CapabilitiesManagerTest.php @@ -24,6 +24,7 @@ namespace Test; use OC\CapabilitiesManager; use OCP\AppFramework\QueryException; use OCP\Capabilities\ICapability; +use OCP\Capabilities\IPublicCapability; use OCP\ILogger; class CapabilitiesManagerTest extends TestCase { @@ -35,6 +36,7 @@ class CapabilitiesManagerTest extends TestCase { private $logger; public function setUp() { + parent::setUp(); $this->logger = $this->getMockBuilder('OCP\ILogger')->getMock(); $this->manager = new CapabilitiesManager($this->logger); } @@ -60,6 +62,24 @@ class CapabilitiesManagerTest extends TestCase { } /** + * Test a public capabilitie + */ + public function testPublicCapability() { + $this->manager->registerCapability(function() { + return new PublicSimpleCapability1(); + }); + $this->manager->registerCapability(function() { + return new SimpleCapability2(); + }); + $this->manager->registerCapability(function() { + return new SimpleCapability3(); + }); + + $res = $this->manager->getCapabilities(true); + $this->assertEquals(['foo' => 1], $res); + } + + /** * Test that we need something that implents ICapability * @expectedException \InvalidArgumentException * @expectedExceptionMessage The given Capability (Test\NoCapability) does not implement the ICapability interface @@ -160,6 +180,14 @@ class SimpleCapability3 implements ICapability { } } +class PublicSimpleCapability1 implements IPublicCapability { + public function getCapabilities() { + return [ + 'foo' => 1 + ]; + } +} + class NoCapability { public function getCapabilities() { return [ |