Add grouping feature
This commit is contained in:
@@ -239,6 +239,101 @@ class plugin_luxtools_test extends DokuWikiTest
|
||||
$this->assertStringContainsString('height="150"', $xhtml);
|
||||
}
|
||||
|
||||
/**
|
||||
* Grouping wrapper should use default flex mode with zero gap.
|
||||
*/
|
||||
public function test_grouping_default_flex()
|
||||
{
|
||||
$imagePath = TMP_DIR . '/filelistdata/exampleimage.png';
|
||||
$syntax = '<grouping>'
|
||||
. '{{image>' . $imagePath . '|One|120}}'
|
||||
. '{{image>' . $imagePath . '|Two|120}}'
|
||||
. '</grouping>';
|
||||
|
||||
$instructions = p_get_instructions($syntax);
|
||||
$xhtml = p_render('xhtml', $instructions, $info);
|
||||
|
||||
$doc = new Document();
|
||||
$doc->html($xhtml);
|
||||
|
||||
$structure = [
|
||||
'div.luxtools-grouping.luxtools-grouping--flex' => 1,
|
||||
'div.luxtools-grouping .luxtools-imagebox' => 2,
|
||||
];
|
||||
$this->structureCheck($doc, $structure);
|
||||
|
||||
$style = (string)$doc->find('div.luxtools-grouping')->first()->attr('style');
|
||||
$this->assertStringContainsString('--luxtools-grouping-cols: 2', $style);
|
||||
$this->assertStringContainsString('--luxtools-grouping-gap: 0', $style);
|
||||
$this->assertStringContainsString('--luxtools-grouping-justify: start', $style);
|
||||
$this->assertStringContainsString('--luxtools-grouping-align: start', $style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Grouping wrapper should accept custom flex layout and gap.
|
||||
*/
|
||||
public function test_grouping_custom_flex()
|
||||
{
|
||||
$imagePath = TMP_DIR . '/filelistdata/exampleimage.png';
|
||||
$syntax = '<grouping layout="flex" gap="8px">'
|
||||
. '{{image>' . $imagePath . '|One|120}}'
|
||||
. '{{image>' . $imagePath . '|Two|120}}'
|
||||
. '</grouping>';
|
||||
|
||||
$instructions = p_get_instructions($syntax);
|
||||
$xhtml = p_render('xhtml', $instructions, $info);
|
||||
|
||||
$doc = new Document();
|
||||
$doc->html($xhtml);
|
||||
|
||||
$structure = [
|
||||
'div.luxtools-grouping.luxtools-grouping--flex' => 1,
|
||||
'div.luxtools-grouping .luxtools-imagebox' => 2,
|
||||
];
|
||||
$this->structureCheck($doc, $structure);
|
||||
|
||||
$style = (string)$doc->find('div.luxtools-grouping')->first()->attr('style');
|
||||
$this->assertStringContainsString('--luxtools-grouping-gap: 8px', $style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Grouping wrapper should accept justify and align controls.
|
||||
*/
|
||||
public function test_grouping_justify_and_align()
|
||||
{
|
||||
$imagePath = TMP_DIR . '/filelistdata/exampleimage.png';
|
||||
$syntax = '<grouping layout="flex" justify="space-between" align="center">'
|
||||
. '{{image>' . $imagePath . '|One|120}}'
|
||||
. '{{image>' . $imagePath . '|Two|120}}'
|
||||
. '</grouping>';
|
||||
|
||||
$instructions = p_get_instructions($syntax);
|
||||
$xhtml = p_render('xhtml', $instructions, $info);
|
||||
|
||||
$doc = new Document();
|
||||
$doc->html($xhtml);
|
||||
|
||||
$style = (string)$doc->find('div.luxtools-grouping')->first()->attr('style');
|
||||
$this->assertStringContainsString('--luxtools-grouping-justify: space-between', $style);
|
||||
$this->assertStringContainsString('--luxtools-grouping-align: center', $style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unknown grouping attributes should render a warning string.
|
||||
*/
|
||||
public function test_grouping_unknown_option_warning()
|
||||
{
|
||||
$imagePath = TMP_DIR . '/filelistdata/exampleimage.png';
|
||||
$syntax = '<grouping gpa="0.5rem">'
|
||||
. '{{image>' . $imagePath . '|One|120}}'
|
||||
. '</grouping>';
|
||||
|
||||
$instructions = p_get_instructions($syntax);
|
||||
$xhtml = p_render('xhtml', $instructions, $info);
|
||||
|
||||
$this->assertStringContainsString('[grouping: unknown option(s): gpa]', $xhtml);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the built-in file endpoint includes the host page id so file.php can
|
||||
* enforce per-page ACL.
|
||||
|
||||
Reference in New Issue
Block a user