From 8ba05940e9ee76e95ce808d8da163c2af29e4e93 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Tue, 24 May 2016 21:39:36 -0400 Subject: Filter non compatible plugins --- tests/units/Core/Plugin/DirectoryTest.php | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/units/Core/Plugin/DirectoryTest.php (limited to 'tests/units/Core') 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 @@ +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']); + } +} -- cgit v1.2.3