summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-11-01 22:18:43 -0400
committerFrederic Guillot <fred@kanboard.net>2016-11-01 22:18:43 -0400
commitae5d31e4c285e0ce672de780fdacff953fe71bba (patch)
tree5a0f3995633da429417cdc0cfbad920c3e9b4bc9 /tests
parenta3ffb3b40e5459a4e671739e8265cc26d7f6b84b (diff)
Add ExternalTaskManager class
Diffstat (limited to 'tests')
-rw-r--r--tests/units/Core/ExternalTask/ExternalTaskManagerTest.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/units/Core/ExternalTask/ExternalTaskManagerTest.php b/tests/units/Core/ExternalTask/ExternalTaskManagerTest.php
new file mode 100644
index 00000000..e6f4e069
--- /dev/null
+++ b/tests/units/Core/ExternalTask/ExternalTaskManagerTest.php
@@ -0,0 +1,44 @@
+<?php
+
+use Kanboard\Core\ExternalTask\ExternalTaskManager;
+
+require_once __DIR__.'/../../Base.php';
+
+class ExternalTaskManagerTest extends Base
+{
+ public function testProviderNotFound()
+ {
+ $this->setExpectedException('Kanboard\Core\ExternalTask\ProviderNotFoundException');
+
+ $manager = new ExternalTaskManager();
+ $manager->getProvider('foobar');
+ }
+
+ public function testRegister()
+ {
+ $provider = $this->getMock('Kanboard\Core\ExternalTask\ExternalTaskProviderInterface');
+ $provider->expects($this->any())->method('getName')->willReturn('MyProvider');
+
+ $manager = new ExternalTaskManager();
+ $manager->register($provider);
+
+ $this->assertInstanceOf('Kanboard\Core\ExternalTask\ExternalTaskProviderInterface', $manager->getProvider('MyProvider'));
+ }
+
+ public function testGetList()
+ {
+ $provider1 = $this->getMock('Kanboard\Core\ExternalTask\ExternalTaskProviderInterface');
+ $provider1->expects($this->any())->method('getName')->willReturn('MyProvider1');
+
+ $provider2 = $this->getMock('Kanboard\Core\ExternalTask\ExternalTaskProviderInterface');
+ $provider2->expects($this->any())->method('getName')->willReturn('MyProvider2');
+
+ $manager = new ExternalTaskManager();
+ $manager->register($provider1);
+ $manager->register($provider2);
+ $providers = $manager->getProvidersList();
+
+ $expected = array('MyProvider1' => 'MyProvider1', 'MyProvider2' => 'MyProvider2');
+ $this->assertEquals($expected, $providers);
+ }
+}