aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/app/Models/CategoryTest.php16
-rw-r--r--tests/app/Models/SearchTest.php116
-rw-r--r--tests/cli/i18n/I18nDataTest.php16
-rw-r--r--tests/lib/Minz/MigratorTest.php68
-rw-r--r--tests/lib/PHPMailer/PHPMailerTest.php4
5 files changed, 90 insertions, 130 deletions
diff --git a/tests/app/Models/CategoryTest.php b/tests/app/Models/CategoryTest.php
index 842ebe200..c9e88a32d 100644
--- a/tests/app/Models/CategoryTest.php
+++ b/tests/app/Models/CategoryTest.php
@@ -19,14 +19,14 @@ class CategoryTest extends PHPUnit\Framework\TestCase {
/** @return array<array{string,string}> */
public function provideValidNames(): array {
- return array(
- array('', ''),
- array('this string does not need trimming', 'this string does not need trimming'),
- array(' this string needs trimming on left', 'this string needs trimming on left'),
- array('this string needs trimming on right ', 'this string needs trimming on right'),
- array(' this string needs trimming on both ends ', 'this string needs trimming on both ends'),
- array(str_repeat('X', 512), str_repeat('X', FreshRSS_DatabaseDAO::LENGTH_INDEX_UNICODE)), // max length
- );
+ return [
+ ['', ''],
+ ['this string does not need trimming', 'this string does not need trimming'],
+ [' this string needs trimming on left', 'this string needs trimming on left'],
+ ['this string needs trimming on right ', 'this string needs trimming on right'],
+ [' this string needs trimming on both ends ', 'this string needs trimming on both ends'],
+ [str_repeat('X', 512), str_repeat('X', FreshRSS_DatabaseDAO::LENGTH_INDEX_UNICODE)], // max length
+ ];
}
public function test_feedOrdering(): void {
diff --git a/tests/app/Models/SearchTest.php b/tests/app/Models/SearchTest.php
index 12159caeb..e2dba31a1 100644
--- a/tests/app/Models/SearchTest.php
+++ b/tests/app/Models/SearchTest.php
@@ -47,26 +47,26 @@ class SearchTest extends PHPUnit\Framework\TestCase {
* @return array<array<mixed>>
*/
public function provideIntitleSearch(): array {
- return array(
- array('intitle:word1', array('word1'), null),
- array('intitle:word1-word2', array('word1-word2'), null),
- array('intitle:word1 word2', array('word1'), array('word2')),
- array('intitle:"word1 word2"', array('word1 word2'), null),
- array("intitle:'word1 word2'", array('word1 word2'), null),
- array('word1 intitle:word2', array('word2'), array('word1')),
- array('word1 intitle:word2 word3', array('word2'), array('word1', 'word3')),
- array('word1 intitle:"word2 word3"', array('word2 word3'), array('word1')),
- array("word1 intitle:'word2 word3'", array('word2 word3'), array('word1')),
- array('intitle:word1 intitle:word2', array('word1', 'word2'), null),
- array('intitle: word1 word2', null, array('word1', 'word2')),
- array('intitle:123', array('123'), null),
- array('intitle:"word1 word2" word3"', array('word1 word2'), array('word3"')),
- array("intitle:'word1 word2' word3'", array('word1 word2'), array("word3'")),
- array('intitle:"word1 word2\' word3"', array("word1 word2' word3"), null),
- array("intitle:'word1 word2\" word3'", array('word1 word2" word3'), null),
- array("intitle:word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')),
+ return [
+ ['intitle:word1', ['word1'], null],
+ ['intitle:word1-word2', ['word1-word2'], null],
+ ['intitle:word1 word2', ['word1'], ['word2']],
+ ['intitle:"word1 word2"', ['word1 word2'], null],
+ ["intitle:'word1 word2'", ['word1 word2'], null],
+ ['word1 intitle:word2', ['word2'], ['word1']],
+ ['word1 intitle:word2 word3', ['word2'], ['word1', 'word3']],
+ ['word1 intitle:"word2 word3"', ['word2 word3'], ['word1']],
+ ["word1 intitle:'word2 word3'", ['word2 word3'], ['word1']],
+ ['intitle:word1 intitle:word2', ['word1', 'word2'], null],
+ ['intitle: word1 word2', null, ['word1', 'word2']],
+ ['intitle:123', ['123'], null],
+ ['intitle:"word1 word2" word3"', ['word1 word2'], ['word3"']],
+ ["intitle:'word1 word2' word3'", ['word1 word2'], ["word3'"]],
+ ['intitle:"word1 word2\' word3"', ["word1 word2' word3"], null],
+ ["intitle:'word1 word2\" word3'", ['word1 word2" word3'], null],
+ ["intitle:word1 'word2 word3' word4", ['word1'], ['word2 word3', 'word4']],
['intitle:word1+word2', ['word1+word2'], null],
- );
+ ];
}
/**
@@ -84,26 +84,26 @@ class SearchTest extends PHPUnit\Framework\TestCase {
* @return array<array<mixed>>
*/
public function provideAuthorSearch(): array {
- return array(
- array('author:word1', array('word1'), null),
- array('author:word1-word2', array('word1-word2'), null),
- array('author:word1 word2', array('word1'), array('word2')),
- array('author:"word1 word2"', array('word1 word2'), null),
- array("author:'word1 word2'", array('word1 word2'), null),
- array('word1 author:word2', array('word2'), array('word1')),
- array('word1 author:word2 word3', array('word2'), array('word1', 'word3')),
- array('word1 author:"word2 word3"', array('word2 word3'), array('word1')),
- array("word1 author:'word2 word3'", array('word2 word3'), array('word1')),
- array('author:word1 author:word2', array('word1', 'word2'), null),
- array('author: word1 word2', null, array('word1', 'word2')),
- array('author:123', array('123'), null),
- array('author:"word1 word2" word3"', array('word1 word2'), array('word3"')),
- array("author:'word1 word2' word3'", array('word1 word2'), array("word3'")),
- array('author:"word1 word2\' word3"', array("word1 word2' word3"), null),
- array("author:'word1 word2\" word3'", array('word1 word2" word3'), null),
- array("author:word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')),
+ return [
+ ['author:word1', ['word1'], null],
+ ['author:word1-word2', ['word1-word2'], null],
+ ['author:word1 word2', ['word1'], ['word2']],
+ ['author:"word1 word2"', ['word1 word2'], null],
+ ["author:'word1 word2'", ['word1 word2'], null],
+ ['word1 author:word2', ['word2'], ['word1']],
+ ['word1 author:word2 word3', ['word2'], ['word1', 'word3']],
+ ['word1 author:"word2 word3"', ['word2 word3'], ['word1']],
+ ["word1 author:'word2 word3'", ['word2 word3'], ['word1']],
+ ['author:word1 author:word2', ['word1', 'word2'], null],
+ ['author: word1 word2', null, ['word1', 'word2']],
+ ['author:123', ['123'], null],
+ ['author:"word1 word2" word3"', ['word1 word2'], ['word3"']],
+ ["author:'word1 word2' word3'", ['word1 word2'], ["word3'"]],
+ ['author:"word1 word2\' word3"', ["word1 word2' word3"], null],
+ ["author:'word1 word2\" word3'", ['word1 word2" word3'], null],
+ ["author:word1 'word2 word3' word4", ['word1'], ['word2 word3', 'word4']],
['author:word1+word2', ['word1+word2'], null],
- );
+ ];
}
/**
@@ -121,16 +121,16 @@ class SearchTest extends PHPUnit\Framework\TestCase {
* @return array<array<mixed>>
*/
public function provideInurlSearch(): array {
- return array(
- array('inurl:word1', array('word1'), null),
- array('inurl: word1', array(), array('word1')),
- array('inurl:123', array('123'), null),
- array('inurl:word1 word2', array('word1'), array('word2')),
- array('inurl:"word1 word2"', array('"word1'), array('word2"')),
- array('inurl:word1 word2 inurl:word3', array('word1', 'word3'), array('word2')),
- array("inurl:word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')),
+ return [
+ ['inurl:word1', ['word1'], null],
+ ['inurl: word1', [], ['word1']],
+ ['inurl:123', ['123'], null],
+ ['inurl:word1 word2', ['word1'], ['word2']],
+ ['inurl:"word1 word2"', ['"word1'], ['word2"']],
+ ['inurl:word1 word2 inurl:word3', ['word1', 'word3'], ['word2']],
+ ["inurl:word1 'word2 word3' word4", ['word1'], ['word2 word3', 'word4']],
['inurl:word1+word2', ['word1+word2'], null],
- );
+ ];
}
/**
@@ -194,16 +194,16 @@ class SearchTest extends PHPUnit\Framework\TestCase {
* @return array<array<string|array<string>|null>>
*/
public function provideTagsSearch(): array {
- return array(
- array('#word1', array('word1'), null),
- array('# word1', null, array('#', 'word1')),
- array('#123', array('123'), null),
- array('#word1 word2', array('word1'), array('word2')),
- array('#"word1 word2"', array('"word1'), array('word2"')),
- array('#word1 #word2', array('word1', 'word2'), null),
- array("#word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')),
- ['#word1+word2', ['word1 word2'], null],
- );
+ return [
+ ['#word1', ['word1'], null],
+ ['# word1', null, ['#', 'word1']],
+ ['#123', ['123'], null],
+ ['#word1 word2', ['word1'], ['word2']],
+ ['#"word1 word2"', ['"word1'], ['word2"'],],
+ ['#word1 #word2', ['word1', 'word2'], null],
+ ["#word1 'word2 word3' word4", ['word1'], ['word2 word3', 'word4']],
+ ['#word1+word2', ['word1 word2'], null]
+ ];
}
/**
@@ -289,7 +289,7 @@ class SearchTest extends PHPUnit\Framework\TestCase {
* @param array<string> $values
*/
public function test__construct_parentheses(string $input, string $sql, array $values): void {
- list($filterValues, $filterSearch) = FreshRSS_EntryDAOPGSQL::sqlBooleanSearch('e.', new FreshRSS_BooleanSearch($input));
+ [$filterValues, $filterSearch] = FreshRSS_EntryDAOPGSQL::sqlBooleanSearch('e.', new FreshRSS_BooleanSearch($input));
self::assertEquals($sql, $filterSearch);
self::assertEquals($values, $filterValues);
}
diff --git a/tests/cli/i18n/I18nDataTest.php b/tests/cli/i18n/I18nDataTest.php
index bbfc92872..29ee14802 100644
--- a/tests/cli/i18n/I18nDataTest.php
+++ b/tests/cli/i18n/I18nDataTest.php
@@ -466,9 +466,7 @@ class I18nDataTest extends PHPUnit\Framework\TestCase {
}
public function testAddKey(): void {
- $getTargetedValue = static function (I18nData $data, string $language) {
- return $data->getData()[$language]['file2.php']['file2.l1.l2.k3'];
- };
+ $getTargetedValue = static fn(I18nData $data, string $language) => $data->getData()[$language]['file2.php']['file2.l1.l2.k3'];
$rawData = array_merge($this->referenceData, [
'fr' => [],
@@ -502,9 +500,7 @@ class I18nDataTest extends PHPUnit\Framework\TestCase {
}
public function testAddValueWhenLanguageIsReferenceAndValueInOtherLanguageHasNotChange(): void {
- $getTargetedValue = static function (I18nData $data, string $language) {
- return $data->getData()[$language]['file2.php']['file2.l1.l2.k2'];
- };
+ $getTargetedValue = static fn(I18nData $data, string $language) => $data->getData()[$language]['file2.php']['file2.l1.l2.k2'];
$this->value->expects(self::atLeast(2))
->method('equal')
@@ -530,9 +526,7 @@ class I18nDataTest extends PHPUnit\Framework\TestCase {
}
public function testAddValueWhenLanguageIsReferenceAndValueInOtherLanguageHasChange(): void {
- $getTargetedValue = static function (I18nData $data, string $language) {
- return $data->getData()[$language]['file2.php']['file2.l1.l2.k2'];
- };
+ $getTargetedValue = static fn(I18nData $data, string $language) => $data->getData()[$language]['file2.php']['file2.l1.l2.k2'];
$this->value->expects(self::any())
->method('equal')
@@ -565,9 +559,7 @@ class I18nDataTest extends PHPUnit\Framework\TestCase {
}
public function testAddValueWhenLanguageIsNotReference(): void {
- $getTargetedValue = static function (I18nData $data, string $language) {
- return $data->getData()[$language]['file2.php']['file2.l1.l2.k2'];
- };
+ $getTargetedValue = static fn(I18nData $data, string $language) => $data->getData()[$language]['file2.php']['file2.l1.l2.k2'];
$rawData = array_merge($this->referenceData, [
'fr' => [],
diff --git a/tests/lib/Minz/MigratorTest.php b/tests/lib/Minz/MigratorTest.php
index 5d090b2fa..6560715da 100644
--- a/tests/lib/Minz/MigratorTest.php
+++ b/tests/lib/Minz/MigratorTest.php
@@ -7,9 +7,7 @@ class MigratorTest extends TestCase
public function testAddMigration(): void {
$migrator = new Minz_Migrator();
- $migrator->addMigration('foo', function () {
- return true;
- });
+ $migrator->addMigration('foo', fn() => true);
$migrations = $migrator->migrations();
self::assertArrayHasKey('foo', $migrations);
@@ -19,15 +17,9 @@ class MigratorTest extends TestCase
public function testMigrationsIsSorted(): void {
$migrator = new Minz_Migrator();
- $migrator->addMigration('2_foo', function () {
- return true;
- });
- $migrator->addMigration('10_foo', function () {
- return true;
- });
- $migrator->addMigration('1_foo', function () {
- return true;
- });
+ $migrator->addMigration('2_foo', fn() => true);
+ $migrator->addMigration('10_foo', fn() => true);
+ $migrator->addMigration('1_foo', fn() => true);
$expected_versions = ['1_foo', '2_foo', '10_foo'];
$migrations = $migrator->migrations();
@@ -37,9 +29,7 @@ class MigratorTest extends TestCase
public function testSetAppliedVersions(): void {
$migrator = new Minz_Migrator();
- $migrator->addMigration('foo', function () {
- return true;
- });
+ $migrator->addMigration('foo', fn() => true);
$migrator->setAppliedVersions(['foo']);
@@ -48,9 +38,7 @@ class MigratorTest extends TestCase
public function testSetAppliedVersionsTrimArgument(): void {
$migrator = new Minz_Migrator();
- $migrator->addMigration('foo', function () {
- return true;
- });
+ $migrator->addMigration('foo', fn() => true);
$migrator->setAppliedVersions(["foo\n"]);
@@ -68,12 +56,8 @@ class MigratorTest extends TestCase
public function testVersions(): void {
$migrator = new Minz_Migrator();
- $migrator->addMigration('foo', function () {
- return true;
- });
- $migrator->addMigration('bar', function () {
- return true;
- });
+ $migrator->addMigration('foo', fn() => true);
+ $migrator->addMigration('bar', fn() => true);
$versions = $migrator->versions();
@@ -135,15 +119,9 @@ class MigratorTest extends TestCase
public function testMigrateCallNonAppliedBetweenTwoApplied(): void {
$migrator = new Minz_Migrator();
- $migrator->addMigration('1_foo', function () {
- return true;
- });
- $migrator->addMigration('2_foo', function () {
- return true;
- });
- $migrator->addMigration('3_foo', function () {
- return true;
- });
+ $migrator->addMigration('1_foo', fn() => true);
+ $migrator->addMigration('2_foo', fn() => true);
+ $migrator->addMigration('3_foo', fn() => true);
$migrator->setAppliedVersions(['1_foo', '3_foo']);
$result = $migrator->migrate();
@@ -156,12 +134,8 @@ class MigratorTest extends TestCase
public function testMigrateWithMigrationReturningFalseDoesNotApplyVersion(): void {
$migrator = new Minz_Migrator();
- $migrator->addMigration('1_foo', function () {
- return true;
- });
- $migrator->addMigration('2_foo', function () {
- return false;
- });
+ $migrator->addMigration('1_foo', fn() => true);
+ $migrator->addMigration('2_foo', fn() => false);
$result = $migrator->migrate();
@@ -174,9 +148,7 @@ class MigratorTest extends TestCase
public function testMigrateWithMigrationReturningFalseDoesNotExecuteNextMigrations(): void {
$migrator = new Minz_Migrator();
- $migrator->addMigration('1_foo', function () {
- return false;
- });
+ $migrator->addMigration('1_foo', fn() => false);
$spy = false;
$migrator->addMigration('2_foo', function () use (&$spy) {
$spy = true;
@@ -208,9 +180,7 @@ class MigratorTest extends TestCase
public function testUpToDate(): void {
$migrator = new Minz_Migrator();
- $migrator->addMigration('foo', function () {
- return true;
- });
+ $migrator->addMigration('foo', fn() => true);
$migrator->setAppliedVersions(['foo']);
$upToDate = $migrator->upToDate();
@@ -220,12 +190,8 @@ class MigratorTest extends TestCase
public function testUpToDateIfRemainingMigration(): void {
$migrator = new Minz_Migrator();
- $migrator->addMigration('1_foo', function () {
- return true;
- });
- $migrator->addMigration('2_foo', function () {
- return true;
- });
+ $migrator->addMigration('1_foo', fn() => true);
+ $migrator->addMigration('2_foo', fn() => true);
$migrator->setAppliedVersions(['2_foo']);
$upToDate = $migrator->upToDate();
diff --git a/tests/lib/PHPMailer/PHPMailerTest.php b/tests/lib/PHPMailer/PHPMailerTest.php
index 021337a3b..bb08deaa8 100644
--- a/tests/lib/PHPMailer/PHPMailerTest.php
+++ b/tests/lib/PHPMailer/PHPMailerTest.php
@@ -1,9 +1,11 @@
<?php
declare(strict_types=1);
+use PHPMailer\PHPMailer\PHPMailer;
+
class PHPMailerTest extends PHPUnit\Framework\TestCase
{
public function testPHPMailerClassExists(): void {
- self::assertTrue(class_exists('PHPMailer\\PHPMailer\\PHPMailer'));
+ self::assertTrue(class_exists(PHPMailer::class));
}
}