mirror of
https://github.com/e107inc/e107.git
synced 2025-07-28 10:20:45 +02:00
More parser tests.
This commit is contained in:
@@ -1506,7 +1506,6 @@ class e_parse
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'table' : // strip <br /> from inside of <table>
|
case 'table' : // strip <br /> from inside of <table>
|
||||||
|
|
||||||
$convertNL = false;
|
$convertNL = false;
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
@@ -2665,7 +2664,7 @@ class e_parse
|
|||||||
* @return string
|
* @return string
|
||||||
* @see e107.htaccess
|
* @see e107.htaccess
|
||||||
*/
|
*/
|
||||||
private function thumbUrlSEF($url = '', $options = array())
|
public function thumbUrlSEF($url = '', $options = array())
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!empty($options['full']))
|
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
|
// 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;
|
$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']))
|
if(!empty($options['aw']) || !empty($options['ah']))
|
||||||
{
|
{
|
||||||
$sefUrl .= 'a' . intval($options['aw']) . 'xa' . intval($options['ah']);
|
$sefUrl .= 'a' . intval($options['aw']) . 'xa' . intval($options['ah']);
|
||||||
@@ -4493,10 +4500,13 @@ class e_parse
|
|||||||
$autoplay = !empty($parm['autoplay']) ? 'autoplay ' : '';
|
$autoplay = !empty($parm['autoplay']) ? 'autoplay ' : '';
|
||||||
$controls = !empty($parm['controls']) ? 'controls' : '';
|
$controls = !empty($parm['controls']) ? 'controls' : '';
|
||||||
|
|
||||||
$text = '<audio controls style="max-width:100%" ' . $autoplay . $controls . '>
|
$text = '<audio controls style="max-width:100%" ' . $autoplay . $controls . '>';
|
||||||
<source src="' . $file . '" type="' . $mime . '">
|
$text .= "\n";
|
||||||
Your browser does not support the audio tag.
|
$text .= '<source src="' . $file . '" type="' . $mime . '">';
|
||||||
</audio>';
|
$text .= "\n";
|
||||||
|
$text .= 'Your browser does not support the audio tag.';
|
||||||
|
$text .= "\n";
|
||||||
|
$text .= '</audio>';
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
|
|
||||||
|
@@ -353,6 +353,10 @@ while($row = $sql->fetch())
|
|||||||
'text' => '[php]<?php $something = "something";[/php]', // legacy usage, now deprecated.
|
'text' => '[php]<?php $something = "something";[/php]', // legacy usage, now deprecated.
|
||||||
'expected' => "",
|
'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($row = $sql->fetch())
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
public function testToNumber()
|
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($row = $sql->fetch())
|
|||||||
$this->assertTrue($valid);
|
$this->assertTrue($valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isValidXML($xmlContent)
|
private function isValidXML($xmlContent)
|
||||||
@@ -1031,6 +1055,52 @@ while($row = $sql->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()
|
public function testParseBBCodes()
|
||||||
@@ -2101,12 +2171,26 @@ while($row = $sql->fetch())
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public function testIsImage()
|
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()
|
public function testToVideo()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user