<commit_before><?php

require_once(AK_LIB_DIR.DS.'AkPlugin'.DS.'AkPluginManager.php');

class AkPluginManagerTestCase extends AkUnitTest
{
    function test_remove_repositories_config()
    {
        Ak::directory_delete(AK_PLUGINS_DIR.DS.'acts_as_versioned');
        @Ak::file_delete(AK_CONFIG_DIR.DS.'plugin_repositories.txt');
    }

    function setup()
    {
        $this->PluginManager =& new AkPluginManager();
        @Ak::file_delete(AK_TMP_DIR.DS.'plugin_repositories.yaml');
    }

    function test_should_get_available_repositories()
    {
        $repositories = $this->PluginManager->getAvailableRepositories();
        $this->assertTrue(in_array('http://svn.akelos.org/plugins', $repositories));
    }

    function test_should_add_new_repository()
    {
        $this->PluginManager->addRepository('http://svn.editam.com/plugins');
        $this->PluginManager->addRepository('http://svn.example.com/plugins');
        $repositories = $this->PluginManager->getAvailableRepositories();
        $this->assertTrue(in_array('http://svn.akelos.org/plugins', $repositories));
        $this->assertTrue(in_array('http://svn.editam.com/plugins', $repositories));
    }

    function test_should_remove_repository()
    {
        $repositories = $this->PluginManager->getAvailableRepositories(true);
        $this->assertEqual(count($repositories), 3);

        $this->PluginManager->removeRepository('http://svn.editam.com/plugins');
        $repositories = $this->PluginManager->getAvailableRepositories(true);
        $this->assertFalse(in_array('http://svn.editam.com/plugins', $repositories));
        $this->assertEqual(count($repositories), 2);

        $this->PluginManager->removeRepository('http://svn.example.com/plugins');
        $repositories = $this->PluginManager->getAvailableRepositories(true);
        $this->assertEqual(count($repositories), 1);
    }

    function test_should_get_remote_plugin_list()
    {
        $plugins = $this->PluginManager->getPlugins();
        $this->assertEqual($plugins['acts_as_versioned'], 'http://svn.akelos.org/plugins');
    }

    function test_should_install_plugin()
    {
        $this->PluginManager->installPlugin('acts_as_versioned');
        $this->assertTrue(in_array('acts_as_versioned', $this->PluginManager->getInstalledPlugins()));
    }

    function test_should_update_plugin()
    {
        Ak::directory_delete(AK_PLUGINS_DIR.DS.'acts_as_versioned'.DS.'lib');
        $this->assertFalse(file_exists(AK_PLUGINS_DIR.DS.'acts_as_versioned'.DS.'lib'.DS.'ActsAsVersioned.php'));
        $this->PluginManager->updatePlugin('acts_as_versioned');
        $this->assertTrue(file_exists(AK_PLUGINS_DIR.DS.'acts_as_versioned'.DS.'lib'.DS.'ActsAsVersioned.php'));
    }

    function test_should_uninstall_plugin()
    {
        clearstatcache();
        $this->PluginManager->uninstallPlugin('acts_as_versioned');
        $this->assertFalse(is_dir(AK_PLUGINS_DIR.DS.'acts_as_versioned'));
    }

    function test_should_get_remote_repositories_listing()
    {
        $repositories = $this->PluginManager->_getRepositoriesFromRemotePage();
        $this->assertEqual($repositories[0], $this->PluginManager->main_repository);
    }<commit_msg>We need to remove the testing plugin in order to avoid conflicts with controller tests.<commit_after><?php

require_once(AK_LIB_DIR.DS.'AkPlugin'.DS.'AkPluginManager.php');

class AkPluginManagerTestCase extends AkUnitTest
{
    function test_remove_repositories_config()
    {
        Ak::directory_delete(AK_PLUGINS_DIR.DS.'acts_as_versioned');
        @Ak::file_delete(AK_CONFIG_DIR.DS.'plugin_repositories.txt');
    }

    function setup()
    {
        $this->PluginManager =& new AkPluginManager();
        @Ak::file_delete(AK_TMP_DIR.DS.'plugin_repositories.yaml');
    }

    function test_should_get_available_repositories()
    {
        $repositories = $this->PluginManager->getAvailableRepositories();
        $this->assertTrue(in_array('http://svn.akelos.org/plugins', $repositories));
    }

    function test_should_add_new_repository()
    {
        $this->PluginManager->addRepository('http://svn.editam.com/plugins');
        $this->PluginManager->addRepository('http://svn.example.com/plugins');
        $repositories = $this->PluginManager->getAvailableRepositories();
        $this->assertTrue(in_array('http://svn.akelos.org/plugins', $repositories));
        $this->assertTrue(in_array('http://svn.editam.com/plugins', $repositories));
    }

    function test_should_remove_repository()
    {
        $repositories = $this->PluginManager->getAvailableRepositories(true);
        $this->assertEqual(count($repositories), 3);

        $this->PluginManager->removeRepository('http://svn.editam.com/plugins');
        $repositories = $this->PluginManager->getAvailableRepositories(true);
        $this->assertFalse(in_array('http://svn.editam.com/plugins', $repositories));
        $this->assertEqual(count($repositories), 2);

        $this->PluginManager->removeRepository('http://svn.example.com/plugins');
        $repositories = $this->PluginManager->getAvailableRepositories(true);
        $this->assertEqual(count($repositories), 1);
    }

    function test_should_get_remote_plugin_list()
    {
        $plugins = $this->PluginManager->getPlugins();
        $this->assertEqual($plugins['acts_as_versioned'], 'http://svn.akelos.org/plugins');
    }

    function test_should_install_plugin()
    {
        $this->PluginManager->installPlugin('acts_as_versioned');
        $this->assertTrue(in_array('acts_as_versioned', $this->PluginManager->getInstalledPlugins()));
    }

    function test_should_update_plugin()
    {
        Ak::directory_delete(AK_PLUGINS_DIR.DS.'acts_as_versioned'.DS.'lib');
        $this->assertFalse(file_exists(AK_PLUGINS_DIR.DS.'acts_as_versioned'.DS.'lib'.DS.'ActsAsVersioned.php'));
        $this->PluginManager->updatePlugin('acts_as_versioned');
        $this->assertTrue(file_exists(AK_PLUGINS_DIR.DS.'acts_as_versioned'.DS.'lib'.DS.'ActsAsVersioned.php'));
    }

    function test_should_uninstall_plugin()
    {
        clearstatcache();
        $this->PluginManager->uninstallPlugin('acts_as_versioned');
        $this->assertFalse(is_dir(AK_PLUGINS_DIR.DS.'acts_as_versioned'));
    }

    function test_should_get_remote_repositories_listing()
    {
        $repositories = $this->PluginManager->_getRepositoriesFromRemotePage();
        $this->assertEqual($repositories[0], $this->PluginManager->main_repository);
    }
    
    function test_remove_plugin()
    {
        Ak::directory_delete(AK_PLUGINS_DIR.DS.'acts_as_versioned');
    }
{'fraction_non_alphanumeric': 0.1488976140138931, 'fraction_numerical': 0.0012080942313500453, 'mean_word_length': 4.08678955453149, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 95, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2000598', 'n_tokens_mistral': 2081, 'n_tokens_neox': 2015, 'n_words': 173}