Merge pull request #6420 from marc1706/ticket/17049

[ticket/17049] Improve extension catalog display and tests
This commit is contained in:
Marc Alexander 2022-10-16 21:38:25 +02:00 committed by GitHub
commit 910ffaad76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 104 additions and 15 deletions

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1 @@
[]

View file

@ -189,7 +189,7 @@ class acp_extensions
$this->list_enabled_exts($phpbb_extension_manager, $managed_packages);
$this->list_disabled_exts($phpbb_extension_manager, $managed_packages);
$this->list_available_exts($phpbb_extension_manager, $managed_packages);
$this->list_available_exts($managed_packages);
$this->tpl_name = 'acp_ext_list';
@ -928,12 +928,11 @@ class acp_extensions
/**
* Lists all the available extensions and dumps to the template
*
* @param \phpbb\extension\manager $phpbb_extension_manager An instance of the extension manager
* @param array $managed_packages List of managed packages
*
* @return null
*/
public function list_available_exts(\phpbb\extension\manager $phpbb_extension_manager, array $managed_packages)
public function list_available_exts(array $managed_packages)
{
$uninstalled = array_diff_key($this->ext_manager->all_available(), $this->ext_manager->all_configured());

View file

@ -318,6 +318,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('exts_composer_json
INSERT INTO phpbb_config (config_name, config_value) VALUES ('exts_composer_vendor_dir', 'vendor-ext/');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('exts_composer_enable_on_install', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('exts_composer_purge_on_remove', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('exts_composer_minimum_stability', 'stable');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('storage\attachment\provider', 'phpbb\storage\provider\local');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('storage\attachment\config\path', 'files');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('storage\attachment\config\subfolders', '0');

View file

@ -0,0 +1,36 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\db\migration\data\v400;
use phpbb\db\migration\migration;
class extensions_composer_3 extends migration
{
public function effectively_installed(): bool
{
return $this->config->offsetExists('exts_composer_minimum_stability');
}
public function update_data(): array
{
return [
['config.add', ['exts_composer_minimum_stability', 'stable']],
];
}
public static function depends_on(): array
{
return ['\phpbb\db\migration\data\v400\extensions_composer'];
}
}

View file

@ -268,24 +268,45 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
public function test_extensions_catalog_installing_extension()
{
// Lets check page 6 where 'Scroll Page' and 'Scroll To Top' should be listed
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=catalog&start=100&sid=' . $this->sid);
// Let's check the overview, multiple packages should be listed
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=catalog&sid=' . $this->sid);
$this->assertContainsLang('ACP_EXTENSIONS_CATALOG', $this->get_content());
$this->assertGreaterThan(1, $crawler->filter('tr')->count());
$this->assertGreaterThan(1, $crawler->selectLink($this->lang('INSTALL'))->count());
$pages = (int) $crawler->filter('div.pagination li:nth-last-child(2) a')->first()->text();
// Get Install links for both extensions
$scrollpage_install_link = $crawler->filter('tr')->reduce(
function ($node, $i)
$extension_filter = function($crawler, $extension_name, &$install_link)
{
return (bool) (strpos($node->text(), 'Scroll Page') !== false);
$extension_filter = $crawler->filter('tr')->reduce(
function ($node, $i) use ($extension_name)
{
return strpos($node->text(), $extension_name) !== false;
}
)->selectLink($this->lang('INSTALL'))->link();
);
$scrolltotop_install_link = $crawler->filter('tr')->reduce(
function ($node, $i)
if ($extension_filter->count())
{
return (bool) (strpos($node->text(), 'Scroll To Top') !== false);
$install_link = $extension_filter->selectLink($this->lang('INSTALL'))->link();
}
};
for ($i = 0; $i < $pages; $i++)
{
if ($i != 0)
{
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&start=' . $i * 20 . '&mode=catalog&sid=' . $this->sid);
}
$extension_filter($crawler, 'Scroll Page', $scrollpage_install_link);
$extension_filter($crawler, 'Scroll To Top', $scrolltotop_install_link);
}
if (!isset($scrolltotop_install_link) || !isset($scrollpage_install_link))
{
$this->fail('Failed acquiring install links for test extensions');
}
)->selectLink($this->lang('INSTALL'))->link();
// Attempt to install vse/scrollpage extension
$crawler = self::$client->click($scrollpage_install_link);

View file

@ -37,8 +37,19 @@ class phpbb_test_case_helpers
// First, move any extensions setup on the board to a temp directory
$this->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/');
// Back up vendor-ext directory
$this->copy_dir($phpbb_root_path . 'vendor-ext/', $phpbb_root_path . 'store/temp_vendor-ext/');
// Back up composer-ext.* files
copy($phpbb_root_path . 'composer-ext.json', $phpbb_root_path . 'store/temp_composer-ext.json');
copy($phpbb_root_path . 'composer-ext.lock', $phpbb_root_path . 'store/temp_composer-ext.lock');
// Then empty the ext/ directory on the board (for accurate test cases)
$this->empty_dir($phpbb_root_path . 'ext/');
// Then empty the vendor-ext/ directory and add back .git-keep
$this->empty_dir($phpbb_root_path . 'vendor-ext/');
file_put_contents($phpbb_root_path . 'vendor-ext/.git-keep', '');
}
// Copy our ext/ files from the test case to the board
@ -68,6 +79,25 @@ class phpbb_test_case_helpers
$this->empty_dir($phpbb_root_path . 'store/temp_ext/');
}
if (file_exists($phpbb_root_path . 'store/temp_vendor-ext/'))
{
$this->empty_dir($phpbb_root_path . 'vendor-ext/');
$this->copy_dir($phpbb_root_path . 'store/temp_vendor-ext/', $phpbb_root_path . 'vendor-ext/');
$this->empty_dir($phpbb_root_path . 'store/temp_vendor-ext/');
}
if (file_exists($phpbb_root_path . 'store/temp_composer-ext.json'))
{
copy($phpbb_root_path . 'store/temp_composer-ext.json', $phpbb_root_path . 'composer-ext.json');
}
if (file_exists($phpbb_root_path . 'store/temp_composer-ext.lock'))
{
copy($phpbb_root_path . 'store/temp_composer-ext.lock', $phpbb_root_path . 'composer-ext.lock');
}
if (file_exists($phpbb_root_path . 'store/temp_ext/'))
{
$this->empty_dir($phpbb_root_path . 'store/temp_ext/');