From ae5d31e4c285e0ce672de780fdacff953fe71bba Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Tue, 1 Nov 2016 22:18:43 -0400 Subject: Add ExternalTaskManager class --- .../Core/ExternalTask/ExternalTaskManagerTest.php | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/units/Core/ExternalTask/ExternalTaskManagerTest.php (limited to 'tests') 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 @@ +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); + } +} -- cgit v1.2.3