3 require_once(AK_LIB_DIR
.DS
.'AkPlugin'.DS
.'AkPluginManager.php');
5 class AkPluginManagerTestCase
extends AkUnitTest
7 function test_remove_repositories_config()
9 Ak
::directory_delete(AK_PLUGINS_DIR
.DS
.'acts_as_versioned');
10 @Ak
::file_delete(AK_CONFIG_DIR
.DS
.'plugin_repositories.txt');
15 $this->PluginManager
=& new AkPluginManager();
16 @Ak
::file_delete(AK_TMP_DIR
.DS
.'plugin_repositories.yaml');
19 function test_should_get_available_repositories()
21 $repositories = $this->PluginManager
->getAvailableRepositories();
22 $this->assertTrue(in_array('http://svn.akelos.org/plugins', $repositories));
25 function test_should_add_new_repository()
27 $this->PluginManager
->addRepository('http://svn.editam.com/plugins');
28 $this->PluginManager
->addRepository('http://svn.example.com/plugins');
29 $repositories = $this->PluginManager
->getAvailableRepositories();
30 $this->assertTrue(in_array('http://svn.akelos.org/plugins', $repositories));
31 $this->assertTrue(in_array('http://svn.editam.com/plugins', $repositories));
34 function test_should_remove_repository()
36 $repositories = $this->PluginManager
->getAvailableRepositories(true);
37 $this->assertEqual(count($repositories), 3);
39 $this->PluginManager
->removeRepository('http://svn.editam.com/plugins');
40 $repositories = $this->PluginManager
->getAvailableRepositories(true);
41 $this->assertFalse(in_array('http://svn.editam.com/plugins', $repositories));
42 $this->assertEqual(count($repositories), 2);
44 $this->PluginManager
->removeRepository('http://svn.example.com/plugins');
45 $repositories = $this->PluginManager
->getAvailableRepositories(true);
46 $this->assertEqual(count($repositories), 1);
49 function test_should_get_remote_plugin_list()
51 $plugins = $this->PluginManager
->getPlugins();
52 $this->assertEqual($plugins['acts_as_versioned'], 'http://svn.akelos.org/plugins');
55 function test_should_install_plugin()
57 $this->PluginManager
->installPlugin('acts_as_versioned');
58 $this->assertTrue(in_array('acts_as_versioned', $this->PluginManager
->getInstalledPlugins()));
61 function test_should_update_plugin()
63 Ak
::directory_delete(AK_PLUGINS_DIR
.DS
.'acts_as_versioned'.DS
.'lib');
64 $this->assertFalse(file_exists(AK_PLUGINS_DIR
.DS
.'acts_as_versioned'.DS
.'lib'.DS
.'ActsAsVersioned.php'));
65 $this->PluginManager
->updatePlugin('acts_as_versioned');
66 $this->assertTrue(file_exists(AK_PLUGINS_DIR
.DS
.'acts_as_versioned'.DS
.'lib'.DS
.'ActsAsVersioned.php'));
69 function test_should_uninstall_plugin()
71 $this->PluginManager
->uninstallPlugin('acts_as_versioned');
72 $this->assertFalse(is_dir(AK_PLUGINS_DIR
.DS
.'acts_as_versioned'));
75 function test_should_get_remote_repositories_listing()
77 $repositories = $this->PluginManager
->_getRepositoriesFromRemotePage();
78 $this->assertEqual($repositories[0], $this->PluginManager
->main_repository
);