Files
roundcubemail/tests/Framework/BaseReplacer.php
Michael Voříšek 6a53a1d853 Fix CS (whitespace, visibility) (#9297)
* Fix "method_argument_space"

* Fix "control_structure_continuation_position"

* Fix "new_with_parentheses"

* Fix "blank_line_before_statement"

* Fix "visibility_required"

* Fix some "array_indentation"

* Fix some "array_indentation" - unify all "rcube::raise_error" calls

* rm useless eslint ignores and add rules counts

* sort eslint ignores

* fix eslint ignores grammar

* Revert "Fix "blank_line_before_statement""

* fix CS 3.46.0
2024-01-04 14:26:35 +01:00

61 lines
1.6 KiB
PHP

<?php
/**
* Test class to test rcube_base_replacer class
*/
class Framework_BaseReplacer extends PHPUnit\Framework\TestCase
{
/**
* Class constructor
*/
public function test_class()
{
$object = new rcube_base_replacer('test');
$this->assertInstanceOf('rcube_base_replacer', $object, 'Class constructor');
}
/**
* Test replace()
*/
public function test_replace()
{
$base = 'http://thisshouldntbetheurl.bob.com/';
$html = '<A href=http://shouldbethislink.com>Test URL</A>';
$replacer = new rcube_base_replacer($base);
$response = $replacer->replace($html);
$this->assertSame('<A href="http://shouldbethislink.com">Test URL</A>', $response);
}
/**
* Data for absolute_url() test
*/
public function data_absolute_url(): iterable
{
return [
['', 'http://test', 'http://test/'],
['http://test', 'http://anything', 'http://test'],
['cid:test', 'http://anything', 'cid:test'],
['/test', 'http://test', 'http://test/test'],
['./test', 'http://test', 'http://test/test'],
['../test1', 'http://test/test2', 'http://test1'],
['../test1', 'http://test/test2/', 'http://test/test1'],
];
}
/**
* Test absolute_url()
*
* @dataProvider data_absolute_url
*/
public function test_absolute_url($path, $base, $expected)
{
$replacer = new rcube_base_replacer('test');
$result = $replacer->absolute_url($path, $base);
$this->assertSame($expected, $result);
}
}