mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-09 04:48:53 +00:00
Merge branch 'develop-ascraeus' into develop
* develop-ascraeus: [ticket/12777] Add tests for unavailable extension [ticket/12777] Add tests [ticket/12777] Add is_purged() [ticket/12777] Update doc block of is_configured() [ticket/12777] Rename extension status functions and add is_configured()
This commit is contained in:
commit
7ad88ba32b
6 changed files with 92 additions and 14 deletions
|
@ -137,7 +137,7 @@ class acp_extensions
|
||||||
trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
|
trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($phpbb_extension_manager->enabled($ext_name))
|
if ($phpbb_extension_manager->is_enabled($ext_name))
|
||||||
{
|
{
|
||||||
redirect($this->u_action);
|
redirect($this->u_action);
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ class acp_extensions
|
||||||
trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
|
trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($phpbb_extension_manager->enabled($ext_name))
|
if ($phpbb_extension_manager->is_enabled($ext_name))
|
||||||
{
|
{
|
||||||
redirect($this->u_action);
|
redirect($this->u_action);
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ class acp_extensions
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'disable_pre':
|
case 'disable_pre':
|
||||||
if (!$phpbb_extension_manager->enabled($ext_name))
|
if (!$phpbb_extension_manager->is_enabled($ext_name))
|
||||||
{
|
{
|
||||||
redirect($this->u_action);
|
redirect($this->u_action);
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ class acp_extensions
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'disable':
|
case 'disable':
|
||||||
if (!$phpbb_extension_manager->enabled($ext_name))
|
if (!$phpbb_extension_manager->is_enabled($ext_name))
|
||||||
{
|
{
|
||||||
redirect($this->u_action);
|
redirect($this->u_action);
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ class acp_extensions
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete_data_pre':
|
case 'delete_data_pre':
|
||||||
if ($phpbb_extension_manager->enabled($ext_name))
|
if ($phpbb_extension_manager->is_enabled($ext_name))
|
||||||
{
|
{
|
||||||
redirect($this->u_action);
|
redirect($this->u_action);
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ class acp_extensions
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete_data':
|
case 'delete_data':
|
||||||
if ($phpbb_extension_manager->enabled($ext_name))
|
if ($phpbb_extension_manager->is_enabled($ext_name))
|
||||||
{
|
{
|
||||||
redirect($this->u_action);
|
redirect($this->u_action);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ class disable extends command
|
||||||
$this->manager->disable($name);
|
$this->manager->disable($name);
|
||||||
$this->manager->load_extensions();
|
$this->manager->load_extensions();
|
||||||
|
|
||||||
if ($this->manager->enabled($name))
|
if ($this->manager->is_enabled($name))
|
||||||
{
|
{
|
||||||
$output->writeln("<error>Could not disable extension $name</error>");
|
$output->writeln("<error>Could not disable extension $name</error>");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -37,7 +37,7 @@ class enable extends command
|
||||||
$this->manager->enable($name);
|
$this->manager->enable($name);
|
||||||
$this->manager->load_extensions();
|
$this->manager->load_extensions();
|
||||||
|
|
||||||
if ($this->manager->enabled($name))
|
if ($this->manager->is_enabled($name))
|
||||||
{
|
{
|
||||||
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name));
|
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name));
|
||||||
$output->writeln("<info>Successfully enabled extension $name</info>");
|
$output->writeln("<info>Successfully enabled extension $name</info>");
|
||||||
|
|
|
@ -37,7 +37,7 @@ class purge extends command
|
||||||
$this->manager->purge($name);
|
$this->manager->purge($name);
|
||||||
$this->manager->load_extensions();
|
$this->manager->load_extensions();
|
||||||
|
|
||||||
if ($this->manager->enabled($name))
|
if ($this->manager->is_enabled($name))
|
||||||
{
|
{
|
||||||
$output->writeln("<error>Could not purge extension $name</error>");
|
$output->writeln("<error>Could not purge extension $name</error>");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -515,7 +515,7 @@ class manager
|
||||||
* @param string $name Extension name to check NOTE: Can be user input
|
* @param string $name Extension name to check NOTE: Can be user input
|
||||||
* @return bool Depending on whether or not the extension is available
|
* @return bool Depending on whether or not the extension is available
|
||||||
*/
|
*/
|
||||||
public function available($name)
|
public function is_available($name)
|
||||||
{
|
{
|
||||||
return file_exists($this->get_extension_path($name, true));
|
return file_exists($this->get_extension_path($name, true));
|
||||||
}
|
}
|
||||||
|
@ -526,11 +526,49 @@ class manager
|
||||||
* @param string $name Extension name to check
|
* @param string $name Extension name to check
|
||||||
* @return bool Depending on whether or not the extension is enabled
|
* @return bool Depending on whether or not the extension is enabled
|
||||||
*/
|
*/
|
||||||
public function enabled($name)
|
public function is_enabled($name)
|
||||||
{
|
{
|
||||||
return isset($this->extensions[$name]) && $this->extensions[$name]['ext_active'];
|
return isset($this->extensions[$name]) && $this->extensions[$name]['ext_active'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if a given extension is disabled
|
||||||
|
*
|
||||||
|
* @param string $name Extension name to check
|
||||||
|
* @return bool Depending on whether or not the extension is disabled
|
||||||
|
*/
|
||||||
|
public function is_disabled($name)
|
||||||
|
{
|
||||||
|
return isset($this->extensions[$name]) && !$this->extensions[$name]['ext_active'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if a given extension is configured
|
||||||
|
*
|
||||||
|
* All enabled and disabled extensions are considered configured. A purged
|
||||||
|
* extension that is no longer in the database is not configured.
|
||||||
|
*
|
||||||
|
* @param string $name Extension name to check
|
||||||
|
* @return bool Depending on whether or not the extension is configured
|
||||||
|
*/
|
||||||
|
public function is_configured($name)
|
||||||
|
{
|
||||||
|
return isset($this->extensions[$name]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if a given extension is purged
|
||||||
|
*
|
||||||
|
* An extension is purged if it is available, not enabled and not disabled.
|
||||||
|
*
|
||||||
|
* @param string $name Extension name to check
|
||||||
|
* @return bool Depending on whether or not the extension is purged
|
||||||
|
*/
|
||||||
|
public function is_purged($name)
|
||||||
|
{
|
||||||
|
return $this->is_available($name) && !$this->is_configured($name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a \phpbb\finder.
|
* Instantiates a \phpbb\finder.
|
||||||
*
|
*
|
||||||
|
|
|
@ -32,22 +32,62 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
|
||||||
$this->extension_manager = $this->create_extension_manager();
|
$this->extension_manager = $this->create_extension_manager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_available()
|
public function test_all_available()
|
||||||
{
|
{
|
||||||
// barfoo and vendor3/bar should not listed due to missing composer.json. barfoo also has incorrect dir structure.
|
// barfoo and vendor3/bar should not listed due to missing composer.json. barfoo also has incorrect dir structure.
|
||||||
$this->assertEquals(array('vendor/moo', 'vendor2/bar', 'vendor2/foo'), array_keys($this->extension_manager->all_available()));
|
$this->assertEquals(array('vendor/moo', 'vendor2/bar', 'vendor2/foo'), array_keys($this->extension_manager->all_available()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_enabled()
|
public function test_all_enabled()
|
||||||
{
|
{
|
||||||
$this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled()));
|
$this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_configured()
|
public function test_all_configured()
|
||||||
{
|
{
|
||||||
$this->assertEquals(array('vendor/moo', 'vendor2/foo'), array_keys($this->extension_manager->all_configured()));
|
$this->assertEquals(array('vendor/moo', 'vendor2/foo'), array_keys($this->extension_manager->all_configured()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_is_enabled()
|
||||||
|
{
|
||||||
|
$this->assertSame(true, $this->extension_manager->is_enabled('vendor2/foo'));
|
||||||
|
$this->assertSame(false, $this->extension_manager->is_enabled('vendor/moo'));
|
||||||
|
$this->assertSame(false, $this->extension_manager->is_enabled('vendor2/bar'));
|
||||||
|
$this->assertSame(false, $this->extension_manager->is_enabled('bertie/worlddominationplan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_is_disabled()
|
||||||
|
{
|
||||||
|
$this->assertSame(false, $this->extension_manager->is_disabled('vendor2/foo'));
|
||||||
|
$this->assertSame(true, $this->extension_manager->is_disabled('vendor/moo'));
|
||||||
|
$this->assertSame(false, $this->extension_manager->is_disabled('vendor2/bar'));
|
||||||
|
$this->assertSame(false, $this->extension_manager->is_disabled('bertie/worlddominationplan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_is_purged()
|
||||||
|
{
|
||||||
|
$this->assertSame(false, $this->extension_manager->is_purged('vendor2/foo'));
|
||||||
|
$this->assertSame(false, $this->extension_manager->is_purged('vendor/moo'));
|
||||||
|
$this->assertSame(true, $this->extension_manager->is_purged('vendor2/bar'));
|
||||||
|
$this->assertSame(false, $this->extension_manager->is_purged('bertie/worlddominationplan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_is_configured()
|
||||||
|
{
|
||||||
|
$this->assertSame(true, $this->extension_manager->is_configured('vendor2/foo'));
|
||||||
|
$this->assertSame(true, $this->extension_manager->is_configured('vendor/moo'));
|
||||||
|
$this->assertSame(false, $this->extension_manager->is_configured('vendor2/bar'));
|
||||||
|
$this->assertSame(false, $this->extension_manager->is_configured('bertie/worlddominationplan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_is_available()
|
||||||
|
{
|
||||||
|
$this->assertSame(true, $this->extension_manager->is_available('vendor2/foo'));
|
||||||
|
$this->assertSame(true, $this->extension_manager->is_available('vendor/moo'));
|
||||||
|
$this->assertSame(true, $this->extension_manager->is_available('vendor2/bar'));
|
||||||
|
$this->assertSame(false, $this->extension_manager->is_available('bertie/worlddominationplan'));
|
||||||
|
}
|
||||||
|
|
||||||
public function test_enable()
|
public function test_enable()
|
||||||
{
|
{
|
||||||
vendor2\bar\ext::$state = 0;
|
vendor2\bar\ext::$state = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue