1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-27 18:00:30 +02:00

More parser tests.

This commit is contained in:
Cameron
2021-01-15 14:24:28 -08:00
parent 14fac98f56
commit b94acc09e2
2 changed files with 102 additions and 8 deletions

View File

@@ -1506,7 +1506,6 @@ class e_parse
break;
case 'table' : // strip <br /> from inside of <table>
$convertNL = false;
// break;
@@ -2665,7 +2664,7 @@ class e_parse
* @return string
* @see e107.htaccess
*/
private function thumbUrlSEF($url = '', $options = array())
public function thumbUrlSEF($url = '', $options = array())
{
if(!empty($options['full']))
@@ -2713,6 +2712,14 @@ class e_parse
// Build URL for ReWriteRule ^media\/img\/(a)?([\d]*)x(a)?([\d]*)\/(.*)?$ thumb.php?src=e_MEDIA_IMAGE/$5&$1w=$2&$3h=$4
$sefUrl = $base . $sefPath;
if(!empty($options['scale']))
{
$multiInt = (int) $options['scale'];
$options['w'] = $options['w'] * $multiInt;
$options['h'] = $options['h'] * $multiInt;
}
if(!empty($options['aw']) || !empty($options['ah']))
{
$sefUrl .= 'a' . intval($options['aw']) . 'xa' . intval($options['ah']);
@@ -4493,10 +4500,13 @@ class e_parse
$autoplay = !empty($parm['autoplay']) ? 'autoplay ' : '';
$controls = !empty($parm['controls']) ? 'controls' : '';
$text = '<audio controls style="max-width:100%" ' . $autoplay . $controls . '>
<source src="' . $file . '" type="' . $mime . '">
Your browser does not support the audio tag.
</audio>';
$text = '<audio controls style="max-width:100%" ' . $autoplay . $controls . '>';
$text .= "\n";
$text .= '<source src="' . $file . '" type="' . $mime . '">';
$text .= "\n";
$text .= 'Your browser does not support the audio tag.';
$text .= "\n";
$text .= '</audio>';
return $text;

View File

@@ -353,6 +353,10 @@ while(&#036;row = &#036;sql-&gt;fetch())
'text' => '[php]<?php $something = "something";[/php]', // legacy usage, now deprecated.
'expected' => "",
),
3 => array(
'text' => "[table][tr]\n[td]cell[/td]\n[/tr][/table]",
'expected' => "<table class='table table-striped table-bordered bbcode-table'><tr>\n<td>cell</td>\n</tr></table>",
),
);
@@ -521,9 +525,26 @@ while(&#036;row = &#036;sql-&gt;fetch())
}
/*
public function testToNumber()
{
$result = $this->tp->toNumber('v2a');
$this->assertEquals('2', $result);
$result = $this->tp->toNumber('v1.5');
$this->assertEquals('1.5', $result);
$result = $this->tp->toNumber('v3.5');
$this->assertEquals('3.5', $result);
}
/*
public function testthumbUrlSEF()
{
// $this->tp->thumbUrlSEF($url);
}
*/
@@ -959,6 +980,9 @@ while(&#036;row = &#036;sql-&gt;fetch())
$this->assertTrue($valid);
}
}
private function isValidXML($xmlContent)
@@ -1031,6 +1055,52 @@ while(&#036;row = &#036;sql-&gt;fetch())
}
}
public function testThumbUrlSEF()
{
$urls = array(
0 => array(
'path' => '{e_MEDIA_IMAGE}butterfly.jpg',
'options' => array('w'=>300, 'h'=>200),
'expected' =>'/media/img/300x200/butterfly.jpg'
),
1 => array(
'path' => '{e_THEME}dummy/Freesample.svg',
'options' => array('w'=>300, 'h'=>200),
'expected' =>'/theme/img/300x200/dummy/Freesample.svg'
),
2 => array(
'path' => '{e_AVATAR}avatar.jpg',
'options' => array('w'=>100, 'h'=>100),
'expected' =>'/media/avatar/100x100/avatar.jpg'
),
/*2 => array(
'path' => '{e_MEDIA_IMAGE}gallery/images/butterfly.jpg',
'options' => array('w'=>300, 'h'=>200, 'type'=>'webp'),
'expected' =>'/media/img/300x200/gallery/images/butterfly.webp'
),*/
3 => array(
'path' => '{e_MEDIA_IMAGE}gallery/images/butterfly.jpg',
'options' => array('w'=>300, 'h'=>200, 'scale'=>'2x'),
'expected' =>'/media/img/600x400/gallery/images/butterfly.jpg'
),
);
foreach($urls as $val)
{
$actual = $this->tp->thumbUrlSEF($val['path'],$val['options']);
$this->assertStringContainsString($val['expected'], $actual);
//echo $$actual."\n\n";
}
}
/*
public function testParseBBCodes()
@@ -2101,12 +2171,26 @@ while(&#036;row = &#036;sql-&gt;fetch())
{
}
*/
public function testIsImage()
{
$this->assertTrue($this->tp->isImage('/path-to-file/myfile.jpg'));
$this->assertFalse($this->tp->isImage('/path-to-file/myfile.mov'));
}
public function testtoAudio()
{
$expected = '<audio controls style="max-width:100%" >
<source src="/e107_media/000000test/myfile.mp3" type="audio/mpeg">
Your browser does not support the audio tag.
</audio>';
$result = $this->tp->toAudio('{e_MEDIA}myfile.mp3');
$this->assertEquals($expected, $result);
}
/*
public function testToVideo()
{