Add PHPUnit 10.x and 11.x support (#9480)

* Add PHPUnit 10.x and 11.x support

* fix undefined TestCase::getName() for PHPUnit 10+

* Add PHPUnit attributes but keep annotations
This commit is contained in:
Michael Voříšek
2024-06-13 18:40:29 +02:00
committed by GitHub
parent d8b2c3b659
commit 6377477eb2
38 changed files with 137 additions and 3 deletions

View File

@@ -23,7 +23,7 @@
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.2",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^9.6 || ^10.0 || ^11.0",
"roundcube/acl": "*",
"roundcube/additional_message_headers": "*",
"roundcube/archive": "*",

View File

@@ -2,6 +2,7 @@
namespace Tests\Browser\Plugins\AttachmentReminder;
use PHPUnit\Framework\Attributes\Depends;
use Roundcube\Tests\Browser\Bootstrap;
use Roundcube\Tests\Browser\Components\Dialog;
use Roundcube\Tests\Browser\TestCase;
@@ -60,6 +61,7 @@ class PluginTest extends TestCase
*
* @depends testPreferences
*/
#[Depends('testPreferences')]
public function testMailCompose()
{
$this->browse(static function ($browser) {

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Plugins\Tests;
use PHPUnit\Framework\Attributes\DataProvider;
use Roundcube\Tests\ActionTestCase;
use function Roundcube\Tests\invokeMethod;
@@ -67,6 +68,7 @@ class ManagesieveEngineTest extends ActionTestCase
*
* @dataProvider provide_strip_value_cases
*/
#[DataProvider('provide_strip_value_cases')]
public function test_strip_value($expected, $args)
{
$rcube = \rcube::get_instance();

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Plugins\Tests;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class ManagesieveScriptTest extends TestCase
@@ -11,6 +12,7 @@ class ManagesieveScriptTest extends TestCase
*
* @dataProvider provide_parser_cases
*/
#[DataProvider('provide_parser_cases')]
public function test_parser($input, $output, $message)
{
// get capabilities list from the script
@@ -75,6 +77,7 @@ class ManagesieveScriptTest extends TestCase
/**
* @dataProvider provide_tokenizer_cases
*/
#[DataProvider('provide_tokenizer_cases')]
public function test_tokenizer($num, $input, $output)
{
$res = json_encode(\rcube_sieve_script::tokenize($input, $num));

View File

@@ -2,6 +2,7 @@
namespace Tests\Browser\Plugins\Markasjunk;
use PHPUnit\Framework\Attributes\Depends;
use Roundcube\Tests\Browser\Bootstrap;
use Roundcube\Tests\Browser\TestCase;
@@ -93,6 +94,7 @@ class MailTest extends TestCase
*
* @depends testMailUI
*/
#[Depends('testMailUI')]
public function testMailView()
{
$this->browse(static function ($browser) {

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Actions\Contacts;
use PHPUnit\Framework\Attributes\Depends;
use Roundcube\Tests\ActionTestCase;
use Roundcube\Tests\OutputHtmlMock;
use Roundcube\Tests\StderrMock;
@@ -56,6 +57,7 @@ class ExportTest extends ActionTestCase
*
* @depends test_export_all
*/
#[Depends('test_export_all')]
public function test_export_selected()
{
$action = new \rcmail_action_contacts_export();
@@ -99,6 +101,7 @@ class ExportTest extends ActionTestCase
*
* @depends test_export_all
*/
#[Depends('test_export_all')]
public function test_export_search()
{
$this->markTestIncomplete();

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Actions\Mail;
use PHPUnit\Framework\Attributes\Group;
use Roundcube\Tests\ActionTestCase;
use function Roundcube\Tests\setProperty;
@@ -433,6 +434,7 @@ class IndexTest extends ActionTestCase
*
* @group mbstring
*/
#[Group('mbstring')]
public function test_washtml_utf8()
{
$this->initOutput(\rcmail_action::MODE_HTTP, 'mail', '');

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Actions\Mail;
use PHPUnit\Framework\Attributes\DataProvider;
use Roundcube\Tests\ActionTestCase;
use Roundcube\Tests\OutputJsonMock;
@@ -290,6 +291,7 @@ class SearchTest extends ActionTestCase
*
* @dataProvider provide_search_input_cases
*/
#[DataProvider('provide_search_input_cases')]
public function test_search_input($input, $output)
{
if (is_array($input)) {
@@ -328,6 +330,7 @@ class SearchTest extends ActionTestCase
*
* @dataProvider provide_search_interval_criteria_cases
*/
#[DataProvider('provide_search_interval_criteria_cases')]
public function test_search_interval_criteria($input, $output)
{
$result = \rcmail_action_mail_search::search_interval_criteria($input);

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Browser\Contacts;
use PHPUnit\Framework\Attributes\Depends;
use Roundcube\Tests\Browser\Bootstrap;
use Roundcube\Tests\Browser\TestCase;
@@ -41,6 +42,7 @@ class ExportTest extends TestCase
*
* @depends testExportAll
*/
#[Depends('testExportAll')]
public function testExportSelected()
{
$this->browse(function ($browser) {

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Browser\Contacts;
use PHPUnit\Framework\Attributes\Depends;
use Roundcube\Tests\Browser\Bootstrap;
use Roundcube\Tests\Browser\Components\Dialog;
use Roundcube\Tests\Browser\Components\Popupmenu;
@@ -94,6 +95,7 @@ class GroupsTest extends TestCase
*
* @depends testGroupCreate
*/
#[Depends('testGroupCreate')]
public function testGroupRename()
{
$this->browse(static function ($browser) {
@@ -146,6 +148,7 @@ class GroupsTest extends TestCase
*
* @depends testGroupRename
*/
#[Depends('testGroupRename')]
public function testGroupDelete()
{
$this->browse(static function ($browser) {

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Browser\Contacts;
use PHPUnit\Framework\Attributes\Depends;
use Roundcube\Tests\Browser\Bootstrap;
use Roundcube\Tests\Browser\Components\App;
use Roundcube\Tests\Browser\Components\Dialog;
@@ -61,6 +62,7 @@ class ImportTest extends TestCase
*
* @depends testImportUI
*/
#[Depends('testImportUI')]
public function testImportProcess()
{
$this->browse(static function ($browser) {
@@ -103,6 +105,7 @@ class ImportTest extends TestCase
*
* @depends testImportProcess
*/
#[Depends('testImportProcess')]
public function testImportResult()
{
$this->browse(static function ($browser) {

View File

@@ -3,6 +3,7 @@
namespace Roundcube\Tests\Browser\Mail;
use Facebook\WebDriver\WebDriverKeys;
use PHPUnit\Framework\Attributes\Depends;
use Roundcube\Tests\Browser\Bootstrap;
use Roundcube\Tests\Browser\Components\App;
use Roundcube\Tests\Browser\Components\HtmlEditor;
@@ -83,6 +84,7 @@ class ComposeTest extends TestCase
/**
* @depends testCompose
*/
#[Depends('testCompose')]
public function testPlainEditor()
{
// Test for #7230: Shift+PageUp text selection
@@ -114,6 +116,7 @@ class ComposeTest extends TestCase
/**
* @depends testCompose
*/
#[Depends('testCompose')]
public function testRecipientInput()
{
// Test for #7231: Recipient input bug when using click

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Browser\Mail;
use PHPUnit\Framework\Attributes\Depends;
use Roundcube\Tests\Browser\Bootstrap;
use Roundcube\Tests\Browser\Components\Toolbarmenu;
use Roundcube\Tests\Browser\TestCase;
@@ -94,6 +95,7 @@ class ListTest extends TestCase
/**
* @depends testList
*/
#[Depends('testList')]
public function testListSelection()
{
$this->browse(static function ($browser) {

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Browser\Mail;
use PHPUnit\Framework\Attributes\Group;
use Roundcube\Tests\Browser\Bootstrap;
use Roundcube\Tests\Browser\Components\Dialog;
use Roundcube\Tests\Browser\TestCase;
@@ -135,6 +136,7 @@ class PreviewTest extends TestCase
*
* @group failsonga-phone
*/
#[Group('failsonga-phone')]
public function testPreviewMorelink()
{
$this->browse(static function ($browser) {

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Browser\Settings;
use PHPUnit\Framework\Attributes\Group;
use Roundcube\Tests\Browser\Bootstrap;
use Roundcube\Tests\Browser\Components\App;
use Roundcube\Tests\Browser\TestCase;
@@ -73,6 +74,8 @@ class FoldersTest extends TestCase
* @group failsontravis-phone
* @group failsonga-phone
*/
#[Group('failsontravis-phone')]
#[Group('failsonga-phone')]
public function testFolderCreate()
{
$this->browse(static function ($browser) {

View File

@@ -2,6 +2,8 @@
namespace Roundcube\Tests\Browser\Settings;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\Attributes\Group;
use Roundcube\Tests\Browser\Bootstrap;
use Roundcube\Tests\Browser\Components\App;
use Roundcube\Tests\Browser\Components\Dialog;
@@ -48,6 +50,8 @@ class IdentitiesTest extends TestCase
* @group failsontravis-phone
* @group failsonga-phone
*/
#[Group('failsontravis-phone')]
#[Group('failsonga-phone')]
public function testIdentityCreate()
{
$this->browse(static function ($browser) {
@@ -148,6 +152,9 @@ class IdentitiesTest extends TestCase
* @group failsontravis-phone
* @group failsonga-phone
*/
#[Depends('testIdentityCreate')]
#[Group('failsontravis-phone')]
#[Group('failsonga-phone')]
public function testIdentityDelete()
{
$this->browse(static function ($browser) {
@@ -187,6 +194,9 @@ class IdentitiesTest extends TestCase
* @group failsontravis-phone
* @group failsonga-phone
*/
#[Depends('testIdentityDelete')]
#[Group('failsontravis-phone')]
#[Group('failsonga-phone')]
public function testIdentityUpdate()
{
$this->browse(static function ($browser) {
@@ -235,6 +245,9 @@ class IdentitiesTest extends TestCase
* @group failsontravis-phone
* @group failsonga-phone
*/
#[Depends('testIdentityUpdate')]
#[Group('failsontravis-phone')]
#[Group('failsonga-phone')]
public function testIdentitiesInComposer()
{
// Add one more identity

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Browser\Settings\Preferences;
use PHPUnit\Framework\Attributes\Depends;
use Roundcube\Tests\Browser\Bootstrap;
use Roundcube\Tests\Browser\Components\App;
use Roundcube\Tests\Browser\TestCase;
@@ -102,6 +103,7 @@ class GeneralTest extends TestCase
*
* @depends testGeneral
*/
#[Depends('testGeneral')]
public function testPreferencesChange()
{
// Values we're changing to

View File

@@ -2,6 +2,8 @@
namespace Roundcube\Tests\Browser\Settings;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\Attributes\Group;
use Roundcube\Tests\Browser\Bootstrap;
use Roundcube\Tests\Browser\Components\App;
use Roundcube\Tests\Browser\Components\Dialog;
@@ -49,6 +51,8 @@ class ResponsesTest extends TestCase
* @group failsontravis-phone
* @group failsonga-phone
*/
#[Group('failsontravis-phone')]
#[Group('failsonga-phone')]
public function testResponseCreate()
{
\rcmail::get_instance()->get_dbh()->exec_script("
@@ -133,6 +137,9 @@ class ResponsesTest extends TestCase
* @group failsontravis-phone
* @group failsonga-phone
*/
#[Depends('testResponseCreate')]
#[Group('failsontravis-phone')]
#[Group('failsonga-phone')]
public function testResponseDelete()
{
$this->browse(static function ($browser) {
@@ -170,6 +177,9 @@ class ResponsesTest extends TestCase
* @group failsontravis-phone
* @group failsonga-phone
*/
#[Depends('testResponseDelete')]
#[Group('failsontravis-phone')]
#[Group('failsonga-phone')]
public function testResponsesInComposer()
{
$this->browse(static function ($browser) {
@@ -216,6 +226,9 @@ class ResponsesTest extends TestCase
* @group failsontravis-phone
* @group failsonga-phone
*/
#[Depends('testResponsesInComposer')]
#[Group('failsontravis-phone')]
#[Group('failsonga-phone')]
public function testResponseUpdate()
{
$this->browse(static function ($browser) {

View File

@@ -7,6 +7,7 @@ use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Laravel\Dusk\Chrome\SupportsChrome;
use Laravel\Dusk\Concerns\ProvidesBrowser;
use PHPUnit\Framework\Attributes\BeforeClass;
use PHPUnit\Framework\TestCase as PHPUnitTestCase;
use Symfony\Component\Finder\Exception\DirectoryNotFoundException;
use Symfony\Component\Finder\Finder;
@@ -33,6 +34,7 @@ abstract class TestCase extends PHPUnitTestCase
*
* @beforeClass
*/
#[BeforeClass]
public static function prepare(): void
{
static::startWebServer();
@@ -118,7 +120,7 @@ abstract class TestCase extends PHPUnitTestCase
// Purge screenshots from the last test run
$pattern = sprintf('failure-%s_%s-*',
str_replace('\\', '_', static::class),
$this->getName(false)
method_exists($this, 'getName') ? $this->getName(false) : $this->name()
);
try {
@@ -133,7 +135,7 @@ abstract class TestCase extends PHPUnitTestCase
// Purge console logs from the last test run
$pattern = sprintf('%s_%s-*',
str_replace('\\', '_', static::class),
$this->getName(false)
method_exists($this, 'getName') ? $this->getName(false) : $this->name()
);
try {

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
@@ -54,6 +55,7 @@ class BaseReplacerTest extends TestCase
*
* @dataProvider provide_absolute_url_cases
*/
#[DataProvider('provide_absolute_url_cases')]
public function test_absolute_url($path, $base, $expected)
{
$replacer = new \rcube_base_replacer('test');

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
@@ -12,6 +13,7 @@ class BrowserTest extends TestCase
/**
* @dataProvider provide_browser_cases
*/
#[DataProvider('provide_browser_cases')]
public function test_browser($useragent, $opera, $chrome, $ie, $edge, $safari, $mz)
{
$object = $this->getBrowser($useragent);
@@ -27,6 +29,7 @@ class BrowserTest extends TestCase
/**
* @dataProvider provide_os_cases
*/
#[DataProvider('provide_os_cases')]
public function test_os($useragent, $windows, $linux, $unix, $mac)
{
$object = $this->getBrowser($useragent);
@@ -40,6 +43,7 @@ class BrowserTest extends TestCase
/**
* @dataProvider provide_version_cases
*/
#[DataProvider('provide_version_cases')]
public function test_version($useragent, $version)
{
$object = $this->getBrowser($useragent);

View File

@@ -2,6 +2,8 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
/**
@@ -9,6 +11,7 @@ use PHPUnit\Framework\TestCase;
*
* @group mbstring
*/
#[Group('mbstring')]
class CharsetTest extends TestCase
{
/**
@@ -30,6 +33,7 @@ class CharsetTest extends TestCase
/**
* @dataProvider provide_clean_cases
*/
#[DataProvider('provide_clean_cases')]
public function test_clean($input, $output)
{
$this->assertSame($output, \rcube_charset::clean($input));
@@ -59,6 +63,7 @@ class CharsetTest extends TestCase
/**
* @dataProvider provide_is_valid_cases
*/
#[DataProvider('provide_is_valid_cases')]
public function test_is_valid($input, $result)
{
$this->assertSame($result, \rcube_charset::is_valid($input));
@@ -78,6 +83,7 @@ class CharsetTest extends TestCase
/**
* @dataProvider provide_parse_charset_cases
*/
#[DataProvider('provide_parse_charset_cases')]
public function test_parse_charset($input, $output)
{
$this->assertSame($output, \rcube_charset::parse_charset($input));
@@ -114,6 +120,7 @@ class CharsetTest extends TestCase
/**
* @dataProvider provide_convert_cases
*/
#[DataProvider('provide_convert_cases')]
public function test_convert($input, $output, $from, $to)
{
$this->assertSame($output, \rcube_charset::convert($input, $from, $to));
@@ -132,6 +139,7 @@ class CharsetTest extends TestCase
/**
* @dataProvider provide_utf7_to_utf8_cases
*/
#[DataProvider('provide_utf7_to_utf8_cases')]
public function test_utf7_to_utf8($input, $output)
{
// @phpstan-ignore-next-line
@@ -151,6 +159,7 @@ class CharsetTest extends TestCase
/**
* @dataProvider provide_utf7imap_to_utf8_cases
*/
#[DataProvider('provide_utf7imap_to_utf8_cases')]
public function test_utf7imap_to_utf8($input, $output)
{
// @phpstan-ignore-next-line
@@ -170,6 +179,7 @@ class CharsetTest extends TestCase
/**
* @dataProvider provide_utf8_to_utf7imap_cases
*/
#[DataProvider('provide_utf8_to_utf7imap_cases')]
public function test_utf8_to_utf7imap($input, $output)
{
// @phpstan-ignore-next-line
@@ -189,6 +199,7 @@ class CharsetTest extends TestCase
/**
* @dataProvider provide_utf16_to_utf8_cases
*/
#[DataProvider('provide_utf16_to_utf8_cases')]
public function test_utf16_to_utf8($input, $output)
{
// @phpstan-ignore-next-line
@@ -209,6 +220,7 @@ class CharsetTest extends TestCase
/**
* @dataProvider provide_detect_cases
*/
#[DataProvider('provide_detect_cases')]
public function test_detect($input, $fallback, $output)
{
// @phpstan-ignore-next-line
@@ -228,6 +240,7 @@ class CharsetTest extends TestCase
/**
* @dataProvider provide_detect_with_lang_cases
*/
#[DataProvider('provide_detect_with_lang_cases')]
public function test_detect_with_lang($input, $lang, $output)
{
// @phpstan-ignore-next-line

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
/**
@@ -10,6 +11,8 @@ use PHPUnit\Framework\TestCase;
* @group database
* @group mysql
*/
#[Group('database')]
#[Group('mysql')]
class DBMysqlTest extends TestCase
{
/**

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use function Roundcube\Tests\invokeMethod;
@@ -12,6 +13,8 @@ use function Roundcube\Tests\invokeMethod;
* @group database
* @group postgres
*/
#[Group('database')]
#[Group('postgres')]
class DBPgsqlTest extends TestCase
{
/**

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
/**
@@ -10,6 +11,8 @@ use PHPUnit\Framework\TestCase;
* @group database
* @group sqlite
*/
#[Group('database')]
#[Group('sqlite')]
class DBSqliteTest extends TestCase
{
/**

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
/**
@@ -9,6 +10,7 @@ use PHPUnit\Framework\TestCase;
*
* @group database
*/
#[Group('database')]
class DBTest extends TestCase
{
/**

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
@@ -67,6 +68,7 @@ class EnrichedTest extends TestCase
*
* @dataProvider provide_formatting_cases
*/
#[DataProvider('provide_formatting_cases')]
public function test_formatting($enriched, $expected)
{
$result = \rcube_enriched::to_html($enriched);

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
@@ -97,6 +98,7 @@ class Html2textTest extends TestCase
/**
* @dataProvider provide_html2text_cases
*/
#[DataProvider('provide_html2text_cases')]
public function test_html2text($title, $in, $out)
{
$ht = new \rcube_html2text(null, false, \rcube_html2text::LINKS_NONE);
@@ -252,6 +254,7 @@ Links:
*
* @dataProvider provide_links_no_list_cases
*/
#[DataProvider('provide_links_no_list_cases')]
public function test_links_no_list($input, $output)
{
$h2t = new \rcube_html2text($input, false, \rcube_html2text::LINKS_NONE);
@@ -265,6 +268,7 @@ Links:
*
* @dataProvider provide_links_no_list_cases
*/
#[DataProvider('provide_links_no_list_cases')]
public function test_links_no_list_bc_with_boolean($input, $output)
{
$h2t = new \rcube_html2text($input, false, false);

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
@@ -63,6 +64,7 @@ class HtmlTest extends TestCase
*
* @dataProvider provide_attrib_string_cases
*/
#[DataProvider('provide_attrib_string_cases')]
public function test_attrib_string($arg1, $arg2, $expected)
{
$this->assertSame($expected, \html::attrib_string($arg1, $arg2));
@@ -89,6 +91,7 @@ class HtmlTest extends TestCase
*
* @dataProvider provide_quote_cases
*/
#[DataProvider('provide_quote_cases')]
public function test_quote($str, $expected)
{
$this->assertSame($expected, \html::quote($str));
@@ -132,6 +135,7 @@ class HtmlTest extends TestCase
*
* @dataProvider provide_parse_attrib_string_cases
*/
#[DataProvider('provide_parse_attrib_string_cases')]
public function test_parse_attrib_string($arg1, $expected)
{
$this->assertSame($expected, \html::parse_attrib_string($arg1));

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\RequiresFunction;
use PHPUnit\Framework\TestCase;
/**
@@ -67,6 +68,7 @@ class RcubeTest extends TestCase
*
* @requires function shell_exec
*/
#[RequiresFunction('shell_exec')]
public function test_exec()
{
if (\PHP_OS_FAMILY === 'Windows') {

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
@@ -36,6 +37,7 @@ class SpoofcheckerTest extends TestCase
/**
* @dataProvider provide_check_cases
*/
#[DataProvider('provide_check_cases')]
public function test_check($email, $expected)
{
$this->assertSame($expected, \rcube_spoofchecker::check($email));

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
@@ -56,6 +57,7 @@ class StringReplacerTest extends TestCase
/**
* @dataProvider provide_replace_cases
*/
#[DataProvider('provide_replace_cases')]
public function test_replace($input, $output)
{
$replacer = new \rcube_string_replacer();

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
@@ -114,6 +115,7 @@ class Text2HtmlTest extends TestCase
*
* @dataProvider provide_text2html_cases
*/
#[DataProvider('provide_text2html_cases')]
public function test_text2html($input, $output, $options)
{
$t2h = new \rcube_text2html($input, false, $options);

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Roundcube\Tests\StderrMock;
@@ -99,6 +100,7 @@ class UtilsTest extends TestCase
/**
* @dataProvider provide_valid_email_cases
*/
#[DataProvider('provide_valid_email_cases')]
public function test_valid_email($email, $title)
{
$this->assertTrue(\rcube_utils::check_email($email, false), $title);
@@ -107,6 +109,7 @@ class UtilsTest extends TestCase
/**
* @dataProvider provide_invalid_email_cases
*/
#[DataProvider('provide_invalid_email_cases')]
public function test_invalid_email($email, $title)
{
$this->assertFalse(\rcube_utils::check_email($email, false), $title);
@@ -151,6 +154,7 @@ class UtilsTest extends TestCase
/**
* @dataProvider provide_valid_ip_cases
*/
#[DataProvider('provide_valid_ip_cases')]
public function test_valid_ip($ip)
{
$this->assertTrue(\rcube_utils::check_ip($ip));
@@ -159,6 +163,7 @@ class UtilsTest extends TestCase
/**
* @dataProvider provide_invalid_ip_cases
*/
#[DataProvider('provide_invalid_ip_cases')]
public function test_invalid_ip($ip)
{
$this->assertFalse(\rcube_utils::check_ip($ip));
@@ -187,6 +192,7 @@ class UtilsTest extends TestCase
*
* @dataProvider provide_rep_specialchars_output_cases
*/
#[DataProvider('provide_rep_specialchars_output_cases')]
public function test_rep_specialchars_output($type, $mode, $str, $res)
{
$result = \rcube_utils::rep_specialchars_output(
@@ -413,6 +419,7 @@ class UtilsTest extends TestCase
*
* @dataProvider provide_explode_style_cases
*/
#[DataProvider('provide_explode_style_cases')]
public function test_explode_style($input, $output)
{
$this->assertSame($output, \rcube_utils::parse_css_block($input));
@@ -786,6 +793,7 @@ class UtilsTest extends TestCase
*
* @dataProvider provide_idn_convert_cases
*/
#[DataProvider('provide_idn_convert_cases')]
public function test_idn_to_ascii($decoded, $encoded)
{
$this->assertSame(\rcube_utils::idn_to_ascii($decoded), $encoded);
@@ -799,6 +807,7 @@ class UtilsTest extends TestCase
*
* @dataProvider provide_idn_convert_cases
*/
#[DataProvider('provide_idn_convert_cases')]
public function test_idn_to_utf8($decoded, $encoded)
{
$this->assertSame(\rcube_utils::idn_to_utf8($encoded), $decoded);
@@ -831,6 +840,7 @@ class UtilsTest extends TestCase
*
* @dataProvider provide_parse_host_cases
*/
#[DataProvider('provide_parse_host_cases')]
public function test_parse_host($name, $host, $result)
{
$this->assertSame(\rcube_utils::parse_host($name, $host), $result);
@@ -861,6 +871,7 @@ class UtilsTest extends TestCase
*
* @dataProvider provide_parse_host_uri_cases
*/
#[DataProvider('provide_parse_host_uri_cases')]
public function test_parse_host_uri($args, $result)
{
$this->assertSame($result, call_user_func_array('rcube_utils::parse_host_uri', $args));
@@ -888,6 +899,7 @@ class UtilsTest extends TestCase
*
* @dataProvider provide_remove_subject_prefix_cases
*/
#[DataProvider('provide_remove_subject_prefix_cases')]
public function test_remove_subject_prefix($mode, $subject, $result)
{
$this->assertSame(\rcube_utils::remove_subject_prefix($subject, $mode), $result);

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
@@ -487,6 +488,7 @@ class WashtmlTest extends TestCase
*
* @dataProvider provide_wash_svg_tests_cases
*/
#[DataProvider('provide_wash_svg_tests_cases')]
public function test_wash_svg_tests($input, $expected)
{
$washer = new \rcube_washtml();
@@ -553,6 +555,7 @@ class WashtmlTest extends TestCase
*
* @dataProvider provide_wash_xss_tests_cases
*/
#[DataProvider('provide_wash_xss_tests_cases')]
public function test_wash_xss_tests($input, $expected)
{
$washer = new \rcube_washtml(['allow_remote' => true, 'html_elements' => ['body']]);

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Rcmail;
use PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily;
use Roundcube\Tests\ActionTestCase;
/**
@@ -81,6 +82,7 @@ class InstallTest extends ActionTestCase
*
* @requires OSFAMILY Linux
*/
#[RequiresOperatingSystemFamily('Linux')]
public function test_check_mime_extensions()
{
$rcmail = \rcmail::get_instance();

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Rcmail;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
@@ -319,6 +320,7 @@ class OutputHtmlTest extends TestCase
*
* @dataProvider provide_conditions_cases
*/
#[DataProvider('provide_conditions_cases')]
public function test_conditions($input, $output)
{
$object = new \rcmail_output_html();

View File

@@ -2,6 +2,7 @@
namespace Roundcube\Tests\Rcmail;
use PHPUnit\Framework\Attributes\DataProvider;
use Roundcube\Tests\ActionTestCase;
/**
@@ -153,6 +154,7 @@ class SendmailTest extends ActionTestCase
/**
* @dataProvider provide_email_input_format_cases
*/
#[DataProvider('provide_email_input_format_cases')]
public function test_email_input_format($input, $output, $charset)
{
$sendmail = new \rcmail_sendmail();