[ticket/17535] Update test fix

PHPBB-17535

Signed-off-by: Matt Friedman <maf675@gmail.com>
This commit is contained in:
Matt Friedman 2025-07-18 08:55:06 -07:00
parent 833ed86283
commit 69fa84b41b
No known key found for this signature in database

View file

@ -80,18 +80,22 @@ class phpbb_help_manager_test extends phpbb_test_case
->method('lang') ->method('lang')
->willReturnCallback(fn(string $arg) => strtoupper($arg)); ->willReturnCallback(fn(string $arg) => strtoupper($arg));
$matcher = $this->exactly(count($questions) + 1); $expected_calls = [
$this->template->expects($matcher) ['faq_block', [
'BLOCK_TITLE' => strtoupper($block_name),
'SWITCH_COLUMN' => $switch_expected,
]],
...$template_call_args
];
$this->template->expects($this->exactly(count($questions) + 1))
->method('assign_block_vars') ->method('assign_block_vars')
->willReturnCallback(function ($arg1, $arg2) use ($matcher, $block_name, $switch_expected, $template_call_args) { ->willReturnCallback(function($blockName, $blockVars) use (&$expected_calls) {
$callNr = $matcher->numberOfInvocations(); static $call = 0;
match (true) { $this->assertEquals($expected_calls[$call][0], $blockName);
$callNr == 1 => $this->assertEquals([$arg1, $arg2], ['faq_block', [ $this->assertEquals($expected_calls[$call][1], $blockVars);
'BLOCK_TITLE' => strtoupper($block_name), $call++;
'SWITCH_COLUMN' => $switch_expected, });
]]),
$callNr > 1 => $this->assertEquals([$arg1, $arg2], $template_call_args[$callNr - 2]),
};});
$this->manager->add_block($block_name, $switch, $questions); $this->manager->add_block($block_name, $switch, $questions);
@ -137,21 +141,25 @@ class phpbb_help_manager_test extends phpbb_test_case
->method('lang') ->method('lang')
->willReturnCallback(fn(string $arg) => strtoupper($arg)); ->willReturnCallback(fn(string $arg) => strtoupper($arg));
$matcher = $this->exactly(2); $expected_calls = [
$this->template->expects($matcher) ['faq_block', [
'BLOCK_TITLE' => strtoupper($block_name[0]),
'SWITCH_COLUMN' => $switch_expected[0],
]],
['faq_block', [
'BLOCK_TITLE' => strtoupper($block_name[1]),
'SWITCH_COLUMN' => $switch_expected[1],
]]
];
$this->template->expects($this->exactly(count($expected_calls)))
->method('assign_block_vars') ->method('assign_block_vars')
->willReturnCallback(function ($arg1, $arg2) use ($matcher, $block_name, $switch_expected) { ->willReturnCallback(function($blockName, $blockVars) use (&$expected_calls) {
$callNr = $matcher->numberOfInvocations(); static $call = 0;
match (true) { $this->assertEquals($expected_calls[$call][0], $blockName);
$callNr == 1 => $this->assertEquals([$arg1, $arg2], ['faq_block', [ $this->assertEquals($expected_calls[$call][1], $blockVars);
'BLOCK_TITLE' => strtoupper($block_name[0]), $call++;
'SWITCH_COLUMN' => $switch_expected[0], });
]]),
$callNr == 2 => $this->assertEquals([$arg1, $arg2], ['faq_block', [
'BLOCK_TITLE' => strtoupper($block_name[1]),
'SWITCH_COLUMN' => $switch_expected[1],
]]),
};});
$this->manager->add_block($block_name[0], true); $this->manager->add_block($block_name[0], true);
$this->assertTrue($this->manager->switched_column()); $this->assertTrue($this->manager->switched_column());