From 01093604d30b1639f5e23a7be408bc7d387e39ef Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Fri, 30 Jun 2017 11:21:15 +0200 Subject: Add tests for public capabilties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- tests/lib/CapabilitiesManagerTest.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/lib/CapabilitiesManagerTest.php') 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); } @@ -59,6 +61,24 @@ class CapabilitiesManagerTest extends TestCase { $this->assertEquals(['foo' => 1], $res); } + /** + * 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 @@ -160,6 +180,14 @@ class SimpleCapability3 implements ICapability { } } +class PublicSimpleCapability1 implements IPublicCapability { + public function getCapabilities() { + return [ + 'foo' => 1 + ]; + } +} + class NoCapability { public function getCapabilities() { return [ -- cgit v1.2.3