Files
roundcubemail/tests/Framework/BaseReplacer.php
Michael Voříšek 332c165d28 Fix some basic JS CS (#9328)
* fix "nonblock-statement-body-position" (fixed already)

* fix "comma-dangle"

* fix "no-regex-spaces"

* fix "new-parens"

* fix "object-curly-newline"

* fix "object-property-newline"

* fix "spaced-comment" semimanually

* fix "no-constant-condition" manually

* fix "unicorn/no-hex-escape"

* fix "unicorn/escape-case"

* fix "quote-props"

* fix "no-whitespace-before-property" - fix bug/typo

* fix "unicorn/empty-brace-spaces"

* fix "keyword-spacing"

* fix "dot-notation"

* fix "no-return-assign" manually

* fix "padding-line-between-statements"

* fix "key-spacing"

* fix "no-else-return" semimanually

* fix some "no-undef"

* fix case cs

* Revert "fix "padding-line-between-statements""

* improve switch/case format I.

* improve switch/case format II.

regex: (^ *(break|return).*)\n *(\n)

* fix safe "eqeqeq"

* fix "radix"

* fix v3.49.0 CS (static providers)

* fix "string_implicit_backslashes" in php files

* fix comments align

* fix test static providers

* fix stan

* disable "final_internal_class" rule
2024-02-06 08:28:19 +01: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);
}
}