summaryrefslogtreecommitdiff
path: root/tests/units/Core/Plugin/DirectoryTest.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-24 21:39:36 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-24 21:39:36 -0400
commit8ba05940e9ee76e95ce808d8da163c2af29e4e93 (patch)
treeaa25adca7227774dfbbcddfd5e294ef3e44f7692 /tests/units/Core/Plugin/DirectoryTest.php
parentb9f2d5650d464983a80f84f3ed0845028a355c92 (diff)
Filter non compatible plugins
Diffstat (limited to 'tests/units/Core/Plugin/DirectoryTest.php')
-rw-r--r--tests/units/Core/Plugin/DirectoryTest.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/units/Core/Plugin/DirectoryTest.php b/tests/units/Core/Plugin/DirectoryTest.php
new file mode 100644
index 00000000..13aef4b9
--- /dev/null
+++ b/tests/units/Core/Plugin/DirectoryTest.php
@@ -0,0 +1,44 @@
+<?php
+
+use Kanboard\Core\Plugin\Directory;
+
+require_once __DIR__.'/../../Base.php';
+
+class DirectoryTest extends Base
+{
+ public function testIsCompatible()
+ {
+ $pluginDirectory = new Directory($this->container);
+ $this->assertFalse($pluginDirectory->isCompatible(array('compatible_version' => '1.0.29'), '1.0.28'));
+ $this->assertTrue($pluginDirectory->isCompatible(array('compatible_version' => '1.0.28'), '1.0.28'));
+ $this->assertTrue($pluginDirectory->isCompatible(array('compatible_version' => '1.0.28'), 'master.1234'));
+ }
+
+ public function testGetAvailablePlugins()
+ {
+ $plugins = array(
+ array(
+ 'title' => 'Plugin A',
+ 'compatible_version' => '1.0.30',
+ 'remote_install' => true,
+ ),
+ array(
+ 'title' => 'Plugin B',
+ 'compatible_version' => '1.0.29',
+ 'remote_install' => false,
+ ),
+ );
+
+ $this->container['httpClient']
+ ->expects($this->once())
+ ->method('getJson')
+ ->with('api_url')
+ ->will($this->returnValue($plugins));
+
+ $pluginDirectory = new Directory($this->container);
+ $availablePlugins = $pluginDirectory->getAvailablePlugins('api_url');
+
+ $this->assertCount(1, $availablePlugins);
+ $this->assertEquals('Plugin A', $availablePlugins[0]['title']);
+ }
+}