el = new EditLib();
}
protected function tearDown(): void
{
global $prefs;
// restore preference default state
$prefs['feature_use_three_colon_centertag'] = 'n';
}
/**
* Align Divs 'left'
*/
public function testBlockAlignLeft(): void
{
/*
* default
*/
$ex = 'This text is aligned left';
$inData = 'This text is aligned left';
$out = $this->el->parseToWiki($inData);
$this->assertEquals($ex, $out);
/*
* explicit
*/
$ex = '{DIV(align="left")}This text is aligned left{DIV}';
$inData = '
This text is aligned left
';
$out = $this->el->parseToWiki($inData);
$this->assertEquals($ex, $out);
$inData = 'This text is aligned left
';
$out = $this->el->parseToWiki($inData);
$this->assertEquals($ex, $out);
}
/**
* Align Divs 'center'
*/
public function testBlockAlignCentered(): void
{
global $prefs;
/*
* two colon, no line break
*/
$prefs['feature_use_three_colon_centertag'] = 'n';
$ex = '::This text is centered::';
$inData = 'This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$inData = 'This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
/*
* three colon, no line break
*/
$prefs['feature_use_three_colon_centertag'] = 'y';
$ex = ':::This text is centered:::';
$inData = 'This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$inData = 'This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
/*
* two colon, line break
*/
$prefs['feature_use_three_colon_centertag'] = 'n';
$ex = '::This text is centered::\n::This text is centered::';
$inData = 'This text is centered
This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
$inData = 'This text is centered
This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
/*
* three colon, line break
*/
$prefs['feature_use_three_colon_centertag'] = 'y';
$ex = ':::This text is centered:::\n:::This text is centered:::';
$inData = 'This text is centered
This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
$inData = 'This text is centered
This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
/*
* two colon, remove empty lines
*/
$prefs['feature_use_three_colon_centertag'] = 'n';
$ex = '::Center 1::\n::Center 2::';
$inData = 'Center 1
Center 2
';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
/*
* three colon, remove empty lines
*/
$prefs['feature_use_three_colon_centertag'] = 'y';
$ex = ':::Center 1:::\n:::Center 2:::';
$inData = 'Center 1
Center 2
';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
}
/**
* Align Divs 'right'
*/
public function testBlockAlignRight(): void
{
$ex = '{DIV(align="right")}This text is aligned right{DIV}';
/*
* style
*/
$inData = 'This text is aligned right
';
$out = $this->el->parseToWiki($inData);
$this->assertEquals($ex, $out);
/*
* align
*/
$inData = 'This text is aligned right
';
$out = $this->el->parseToWiki($inData);
$this->assertEquals($ex, $out);
}
/**
* Align Divs 'justify'
*/
public function testBlockAlignJustified(): void
{
$ex = '{DIV(align="justify")}This text is justified{DIV}';
/*
* style
*/
$inData = 'This text is justified
';
$out = $this->el->parseToWiki($inData);
$this->assertEquals($ex, $out);
/*
* align
*/
$inData = 'This text is justified
';
$out = $this->el->parseToWiki($inData);
$this->assertEquals($ex, $out);
}
/**
* Align paragraphs 'left'
*
* @group marked-as-incomplete
*/
public function testParagraphAlignLeft(): void
{
$this->markTestIncomplete('Work in progress.');
$ex = '{DIV(type="p", align="left")}This text is aligned{DIV}';
/*
* style
*/
$inData = 'This text is aligned
';
$out = $this->el->parseToWiki($inData);
$this->assertEquals($ex, $out);
/*
* align
*/
$inData = 'This text is aligned
';
$out = $this->el->parseToWiki($inData);
$this->assertEquals($ex, $out);
}
/**
* Centered headings must use style attribute
*/
public function testCenterdHeadings(): void
{
global $prefs;
/*
* unnumbered
*/
$prefs['feature_use_three_colon_centertag'] = 'n';
$inData = 'Heading
';
$ex = '!::Heading::';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$prefs['feature_use_three_colon_centertag'] = 'y';
$inData = 'Heading
';
$ex = '!:::Heading:::';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
/*
* numbered
*/
$prefs['feature_use_three_colon_centertag'] = 'n';
$inData = '1. Heading
';
$ex = '!#::Heading::';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$prefs['feature_use_three_colon_centertag'] = 'y';
$inData = '1. Heading
';
$ex = '!#:::Heading:::';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
}
/**
* Headings 1-6
*/
public function testNumberedHeadings(): void
{
// all levels, no line break
$inData = '9. Heading Level 1
';
$ex = '!# Heading Level 1';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$inData = '9.9. Heading Level 2
';
$ex = '!!# Heading Level 2';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$inData = '9.9.9. Heading Level 3
';
$ex = '!!!# Heading Level 3';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$inData = '9.9.9.9. Heading Level 4
';
$ex = '!!!!# Heading Level 4';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$inData = '9.9.9.9.9. Heading Level 5
';
$ex = '!!!!!# Heading Level 5';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$inData = '9.9.9.9.9.9. Heading Level 6
';
$ex = '!!!!!!# Heading Level 6';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
// all levels, line breaks
$inData = '9. Heading Level 1
and Level 1A
and Level 1B
line
line';
$ex = '!# Heading Level 1 %%% and Level 1A %%% and Level 1B\nline\nline';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
$inData = '9.9. Heading Level 2
and Level 2A
and Level 2B
line
line';
$ex = '!!# Heading Level 2 %%% and Level 2A %%% and Level 2B\nline\nline';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
$inData = '9.9.9. Heading Level 3
and Level 3A
and Level 3B
line
line';
$ex = '!!!# Heading Level 3 %%% and Level 3A %%% and Level 3B\nline\nline';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
$inData = '9.9.9.9. Heading Level 4
and Level 4A
and Level 4B
line
line';
$ex = '!!!!# Heading Level 4 %%% and Level 4A %%% and Level 4B\nline\nline';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
$inData = '9.9.9.9.9. Heading Level 5
and Level 5A
and Level 5B
line
line';
$ex = '!!!!!# Heading Level 5 %%% and Level 5A %%% and Level 5B\nline\nline';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
$inData = '9.9.9.9.9.9. Heading Level 6
and Level 6A
and Level 6B
line
line';
$ex = '!!!!!!# Heading Level 6 %%% and Level 6A %%% and Level 6B\nline\nline';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
}
/**
* Align paragraphs 'center'
*/
public function testParagraphAlignCentered(): void
{
global $prefs;
/*
* two colon, no line break
*/
$prefs['feature_use_three_colon_centertag'] = 'n';
$ex = '::This text is centered::';
$inData = 'This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$inData = 'This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
/*
* three colon, no line break
*/
$prefs['feature_use_three_colon_centertag'] = 'y';
$ex = ':::This text is centered:::';
$inData = 'This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$inData = 'This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
/*
* two colon, line break
*/
$prefs['feature_use_three_colon_centertag'] = 'n';
$ex = '::This text is centered::\n::This text is centered::';
$inData = 'This text is centered
This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
$inData = 'This text is centered
This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
/*
* three colon, line break
*/
$prefs['feature_use_three_colon_centertag'] = 'y';
$ex = ':::This text is centered:::\n:::This text is centered:::';
$inData = 'This text is centered
This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
$inData = 'This text is centered
This text is centered
';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
}
/**
* Align paragraphs 'right'
*
* @group marked-as-incomplete
*/
public function testParagraphAlignRight(): void
{
$this->markTestIncomplete('Work in progress.');
$ex = '{DIV(type="p", align="right")}This text is aligned{DIV}';
/*
* style
*/
$inData = 'This text is aligned
';
$out = $this->el->parseToWiki($inData);
$this->assertEquals($ex, $out);
/*
* align
*/
$inData = 'This text is aligned
';
$out = $this->el->parseToWiki($inData);
$this->assertEquals($ex, $out);
}
/**
* Align paragraphs 'justified'
*
* @group marked-as-incomplete
*/
public function testParagraphAlignJustified(): void
{
$this->markTestIncomplete('Work in progress.');
$ex = '{DIV(type="p", align="justify")}This text is aligned{DIV}';
/*
* style
*/
$inData = 'This text is aligned
';
$out = $this->el->parseToWiki($inData);
$this->assertEquals($ex, $out);
/*
* align
*/
$inData = 'This text is aligned
';
$out = $this->el->parseToWiki($inData);
$this->assertEquals($ex, $out);
}
/**
* Headings 1-6
*/
public function testUnnumberedHeadings(): void
{
// all levels, no line break
$inData = 'Heading Level 1
';
$ex = '!Heading Level 1';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$inData = 'Heading Level 2
';
$ex = '!!Heading Level 2';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$inData = 'Heading Level 3
';
$ex = '!!!Heading Level 3';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$inData = 'Heading Level 4
';
$ex = '!!!!Heading Level 4';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$inData = 'Heading Level 5
';
$ex = '!!!!!Heading Level 5';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
$inData = 'Heading Level 6
';
$ex = '!!!!!!Heading Level 6';
$out = trim($this->el->parseToWiki($inData));
$this->assertEquals($ex, $out);
// all levels, line breaks
$inData = 'Heading Level 1
and Level 1A
and Level 1B
line
line';
$ex = '!Heading Level 1 %%% and Level 1A %%% and Level 1B\nline\nline';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
$inData = 'Heading Level 2
and Level 2A
and Level 2B
line
line';
$ex = '!!Heading Level 2 %%% and Level 2A %%% and Level 2B\nline\nline';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
$inData = 'Heading Level 3
and Level 3A
and Level 3B
line
line';
$ex = '!!!Heading Level 3 %%% and Level 3A %%% and Level 3B\nline\nline';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
$inData = 'Heading Level 4
and Level 4A
and Level 4B
line
line';
$ex = '!!!!Heading Level 4 %%% and Level 4A %%% and Level 4B\nline\nline';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
$inData = 'Heading Level 5
and Level 5A
and Level 5B
line
line';
$ex = '!!!!!Heading Level 5 %%% and Level 5A %%% and Level 5B\nline\nline';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
$inData = 'Heading Level 6
and Level 6A
and Level 6B
line
line';
$ex = '!!!!!!Heading Level 6 %%% and Level 6A %%% and Level 6B\nline\nline';
$out = trim($this->el->parseToWiki($inData));
$out = preg_replace('/\n/', '\n', $out); // fix LF encoding for comparison
$this->assertEquals($ex, $out);
}
}