[ticket/17049] Make installation of extensions for catalog test more stable

PHPBB3-17049
This commit is contained in:
Marc Alexander 2022-10-16 20:58:52 +02:00
parent 7a7190ff5a
commit afc2747a04
No known key found for this signature in database
GPG key ID: 50E0D2423696F995

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 3 where 'Scroll Page' and 'Scroll To Top' should be listed
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=catalog&start=40&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)
{
return strpos($node->text(), 'Scroll Page') !== false;
}
)->selectLink($this->lang('INSTALL'))->link();
$extension_filter = function($crawler, $extension_name, &$install_link)
{
$extension_filter = $crawler->filter('tr')->reduce(
function ($node, $i) use ($extension_name)
{
return strpos($node->text(), $extension_name) !== false;
}
);
$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();
}
)->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');
}
// Attempt to install vse/scrollpage extension
$crawler = self::$client->click($scrollpage_install_link);