Files
roundcubemail/tests/Framework/BaseReplacerTest.php
Michael Voříšek 736795326c Fix plugins composer.json format (#9405)
* Check plugins composer.json using CI

* Add "require-dev" and "config.allow-plugins" to plugins

* fix composer.json format - rm invalid email

* fix composer.json format - fix ext require

* fix composer.json format - fix plugin name

* tmp

* Revert "tmp"

* fix ext in ext install

* disable plugin in plugin install until Roundcube is fully autoloadable

* fix composer.json format - fix non-canonical license name

* Revert "Add "require-dev" and "config.allow-plugins" to plugins"

* no composer install for plugins needed

* Revert "fix ext in ext install"

* add standard "Test" suffix to phpunit files

* rm unneeded "suffix" in phpunit config

* simplify phpunit config

* fix default "xhtml" doctype in unit testing

* fix test_format_date test to not rely on other tests

* even more phpunit config simplify

* stricter/unify phpunit params for E2E tests

* run E2E tests on maximal php version too with lowest deps

* "repositories" in bundled plugins are useless as for root package only

* add/unify missing plugin test
2024-04-05 17:55:46 +02:00

63 lines
1.6 KiB
PHP

<?php
use PHPUnit\Framework\TestCase;
/**
* Test class to test rcube_base_replacer class
*/
class Framework_BaseReplacer extends 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 static function provide_absolute_url_cases(): 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 provide_absolute_url_cases
*/
public function test_absolute_url($path, $base, $expected)
{
$replacer = new rcube_base_replacer('test');
$result = $replacer->absolute_url($path, $base);
$this->assertSame($expected, $result);
}
}