summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGreg Roach <greg@subaqua.co.uk>2025-02-11 02:24:07 +0000
committerGreg Roach <greg@subaqua.co.uk>2025-02-11 02:27:14 +0000
commit83c3c273a1fa285786be41e48d6d66946a1b453c (patch)
tree9af58902150f2e82cb60d5b50935a5fbb2d3585a /tests
parentfce0ec8f8cea33d44c9beb5e7bb7596d7c3b7942 (diff)
downloadwebtrees-83c3c273a1fa285786be41e48d6d66946a1b453c.tar.gz
webtrees-83c3c273a1fa285786be41e48d6d66946a1b453c.tar.bz2
webtrees-83c3c273a1fa285786be41e48d6d66946a1b453c.zip
Code cleanup
Diffstat (limited to 'tests')
-rw-r--r--tests/TestCase.php8
-rw-r--r--tests/app/DefaultUserTest.php1
-rw-r--r--tests/app/Factories/EncodingFactoryTest.php8
-rw-r--r--tests/app/GuestUserTest.php2
-rw-r--r--tests/app/Http/Middleware/DoHousekeepingTest.php2
-rw-r--r--tests/app/Module/FixDuplicateLinksTest.php1
-rw-r--r--tests/app/Module/StatisticsChartModuleTest.php187
-rw-r--r--tests/app/Module/UpcomingAnniversariesModuleTest.php1
-rw-r--r--tests/app/NoReplyUserTest.php1
-rw-r--r--tests/app/Services/PhpServiceTest.php1
-rw-r--r--tests/app/Services/SearchServiceTest.php50
-rw-r--r--tests/app/SiteUserTest.php1
-rw-r--r--tests/app/TreeUserTest.php1
-rw-r--r--tests/app/UserTest.php1
-rw-r--r--tests/feature/EmbeddedVariablesTest.php493
15 files changed, 627 insertions, 131 deletions
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 60add42acf..43e79efc79 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -194,9 +194,7 @@ class TestCase extends \PHPUnit\Framework\TestCase
do {
$controller->handle($request);
-
- $imported = $tree->getPreference('imported');
- } while (!$imported);
+ } while ($tree->getPreference('imported') !== '1');
return $tree;
}
@@ -244,12 +242,12 @@ class TestCase extends \PHPUnit\Framework\TestCase
}
if (str_starts_with($html, '<')) {
- if (preg_match('~^</([a-z]+)>~', $html, $match)) {
+ if (preg_match('~^</([a-z]+)>~', $html, $match) === 1) {
if ($match[1] !== array_pop($stack)) {
static::fail('Closing tag matches nothing: ' . $match[0] . ' at ' . implode(':', $stack));
}
$html = substr($html, strlen($match[0]));
- } elseif (preg_match('~^<([a-z]+)(?:\s+[a-z_\-]+="[^">]*")*\s*(/?)>~', $html, $match)) {
+ } elseif (preg_match('~^<([a-z]+)(?:\s+[a-z_\-]+="[^">]*")*\s*(/?)>~', $html, $match) === 1) {
$tag = $match[1];
$self_closing = $match[2] === '/';
diff --git a/tests/app/DefaultUserTest.php b/tests/app/DefaultUserTest.php
index 2205bccf54..d12844e9fe 100644
--- a/tests/app/DefaultUserTest.php
+++ b/tests/app/DefaultUserTest.php
@@ -45,7 +45,6 @@ class DefaultUserTest extends TestCase
{
$user = new DefaultUser();
- self::assertInstanceOf(UserInterface::class, $user);
self::assertSame(-1, $user->id());
self::assertSame('DEFAULT_USER', $user->email());
self::assertSame('DEFAULT_USER', $user->realName());
diff --git a/tests/app/Factories/EncodingFactoryTest.php b/tests/app/Factories/EncodingFactoryTest.php
index 99ef8acf49..5924405a88 100644
--- a/tests/app/Factories/EncodingFactoryTest.php
+++ b/tests/app/Factories/EncodingFactoryTest.php
@@ -113,16 +113,16 @@ class EncodingFactoryTest extends TestCase
$factory->make('Not the name of a valid encoding');
}
- public function testList(): void
+ public function testListedEncodingNamesCanBeCreated(): void
{
$factory = new EncodingFactory();
$encodings = $factory->list();
- self::assertCount(13, $encodings);
-
foreach ($encodings as $key => $value) {
- self::assertInstanceOf(EncodingInterface::class, $factory->make($key));
+ $factory->make($key);
}
+
+ self::assertCount(13, $encodings);
}
}
diff --git a/tests/app/GuestUserTest.php b/tests/app/GuestUserTest.php
index beb7214b45..6b5543ec8f 100644
--- a/tests/app/GuestUserTest.php
+++ b/tests/app/GuestUserTest.php
@@ -29,7 +29,6 @@ class GuestUserTest extends TestCase
{
$user = new GuestUser();
- self::assertInstanceOf(UserInterface::class, $user);
self::assertSame(0, $user->id());
self::assertSame('GUEST_USER', $user->email());
self::assertSame('GUEST_USER', $user->realName());
@@ -40,7 +39,6 @@ class GuestUserTest extends TestCase
{
$user = new GuestUser('guest@example.com', 'guest user');
- self::assertInstanceOf(UserInterface::class, $user);
self::assertSame(0, $user->id());
self::assertSame('guest@example.com', $user->email());
self::assertSame('guest user', $user->realName());
diff --git a/tests/app/Http/Middleware/DoHousekeepingTest.php b/tests/app/Http/Middleware/DoHousekeepingTest.php
index 308a4049d2..dbfd060ba2 100644
--- a/tests/app/Http/Middleware/DoHousekeepingTest.php
+++ b/tests/app/Http/Middleware/DoHousekeepingTest.php
@@ -30,6 +30,8 @@ use function response;
#[CoversClass(DoHousekeeping::class)]
class DoHousekeepingTest extends TestCase
{
+ protected static bool $uses_database = true;
+
public function testMiddleware(): void
{
$handler = $this->createMock(RequestHandlerInterface::class);
diff --git a/tests/app/Module/FixDuplicateLinksTest.php b/tests/app/Module/FixDuplicateLinksTest.php
index 1f35761dd4..2893a6670f 100644
--- a/tests/app/Module/FixDuplicateLinksTest.php
+++ b/tests/app/Module/FixDuplicateLinksTest.php
@@ -87,7 +87,6 @@ class FixDuplicateLinksTest extends TestCase
public function testRecordsToFix(): void
{
$records = $this->fixDuplicateLinks->recordsToFix($this->tree, []);
- self::assertInstanceOf(Collection::class, $records);
self::assertCount(1, $records);
$records = $this->fixDuplicateLinks->recordsToFix($this->tree, ['start' => 'X1', 'end' => 'X9']);
diff --git a/tests/app/Module/StatisticsChartModuleTest.php b/tests/app/Module/StatisticsChartModuleTest.php
index 1e1e3feae5..626055ed95 100644
--- a/tests/app/Module/StatisticsChartModuleTest.php
+++ b/tests/app/Module/StatisticsChartModuleTest.php
@@ -19,17 +19,198 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Statistics;
+use Fisharebest\Webtrees\StatisticsData;
use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DataProvider;
#[CoversClass(StatisticsChartModule::class)]
+#[CoversClass(Statistics::class)]
class StatisticsChartModuleTest extends TestCase
{
+ protected static bool $uses_database = true;
+
+ /**
+ * @return array<int,array{x_as:int,y_as:int,z_as:int}>
+ */
+ public static function customChartFamilyAndIndividualOptions(): array
+ {
+ return [
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_DEATH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_DEATH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_SEX],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_DEATH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_DEATH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_DEATH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_SEX],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_DEATH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_FIRST_MARRIAGE, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_FIRST_MARRIAGE, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_SEX],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_FIRST_MARRIAGE, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_FIRST_MARRIAGE, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_FIRST_MARRIAGE, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_SEX],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_FIRST_MARRIAGE, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_MARRIAGE, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_MARRIAGE, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_SEX],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_MARRIAGE, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_MARRIAGE, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_MARRIAGE, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_SEX],
+ ['x_as' => StatisticsChartModule::X_AXIS_AGE_AT_MARRIAGE, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_BIRTH_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_BIRTH_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_SEX],
+ ['x_as' => StatisticsChartModule::X_AXIS_BIRTH_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_BIRTH_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_BIRTH_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_SEX],
+ ['x_as' => StatisticsChartModule::X_AXIS_BIRTH_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_DEATH_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_DEATH_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_SEX],
+ ['x_as' => StatisticsChartModule::X_AXIS_DEATH_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_DEATH_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_DEATH_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_SEX],
+ ['x_as' => StatisticsChartModule::X_AXIS_DEATH_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_FIRST_CHILD_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_FIRST_CHILD_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_SEX],
+ ['x_as' => StatisticsChartModule::X_AXIS_FIRST_CHILD_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_FIRST_CHILD_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_FIRST_CHILD_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_SEX],
+ ['x_as' => StatisticsChartModule::X_AXIS_FIRST_CHILD_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_FIRST_MARRIAGE_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_FIRST_MARRIAGE_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_FIRST_MARRIAGE_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_FIRST_MARRIAGE_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_MARRIAGE_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_MARRIAGE_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_MARRIAGE_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_MARRIAGE_MONTH, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_NUMBER_OF_CHILDREN, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_NUMBER_OF_CHILDREN, 'y_as' => StatisticsChartModule::Y_AXIS_NUMBERS, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ['x_as' => StatisticsChartModule::X_AXIS_NUMBER_OF_CHILDREN, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_ALL],
+ ['x_as' => StatisticsChartModule::X_AXIS_NUMBER_OF_CHILDREN, 'y_as' => StatisticsChartModule::Y_AXIS_PERCENT, 'z_as' => StatisticsChartModule::Z_AXIS_TIME],
+ ];
+ }
+
/**
- * Test that the class exists
+ * @return array<int,array{x_as:int,chart_shows:string,chart_type:string,surn:string}>
*/
- public function testClassExists(): void
+ public static function customChartMapOptions(): array
+ {
+ return [
+ ['x_as' => StatisticsChartModule::X_AXIS_INDIVIDUAL_MAP, 'chart_shows' => 'world', 'chart_type' => 'indi_distribution_chart', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_INDIVIDUAL_MAP, 'chart_shows' => '150', 'chart_type' => 'indi_distribution_chart', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_INDIVIDUAL_MAP, 'chart_shows' => '021', 'chart_type' => 'indi_distribution_chart', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_INDIVIDUAL_MAP, 'chart_shows' => '005', 'chart_type' => 'indi_distribution_chart', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_INDIVIDUAL_MAP, 'chart_shows' => '142', 'chart_type' => 'indi_distribution_chart', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_INDIVIDUAL_MAP, 'chart_shows' => '145', 'chart_type' => 'indi_distribution_chart', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_INDIVIDUAL_MAP, 'chart_shows' => '002', 'chart_type' => 'indi_distribution_chart', 'surn' => ''],
+
+ ['x_as' => StatisticsChartModule::X_AXIS_INDIVIDUAL_MAP, 'chart_shows' => 'world', 'chart_type' => 'surname_distribution_chart', 'surn' => 'smith'],
+ ['x_as' => StatisticsChartModule::X_AXIS_INDIVIDUAL_MAP, 'chart_shows' => '150', 'chart_type' => 'surname_distribution_chart', 'surn' => 'smith'],
+ ['x_as' => StatisticsChartModule::X_AXIS_INDIVIDUAL_MAP, 'chart_shows' => '021', 'chart_type' => 'surname_distribution_chart', 'surn' => 'smith'],
+ ['x_as' => StatisticsChartModule::X_AXIS_INDIVIDUAL_MAP, 'chart_shows' => '005', 'chart_type' => 'surname_distribution_chart', 'surn' => 'smith'],
+ ['x_as' => StatisticsChartModule::X_AXIS_INDIVIDUAL_MAP, 'chart_shows' => '142', 'chart_type' => 'surname_distribution_chart', 'surn' => 'smith'],
+ ['x_as' => StatisticsChartModule::X_AXIS_INDIVIDUAL_MAP, 'chart_shows' => '145', 'chart_type' => 'surname_distribution_chart', 'surn' => 'smith'],
+ ['x_as' => StatisticsChartModule::X_AXIS_INDIVIDUAL_MAP, 'chart_shows' => '002', 'chart_type' => 'surname_distribution_chart', 'surn' => 'smith'],
+
+ ['x_as' => StatisticsChartModule::X_AXIS_BIRTH_MAP, 'chart_shows' => 'world', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_BIRTH_MAP, 'chart_shows' => '150', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_BIRTH_MAP, 'chart_shows' => '021', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_BIRTH_MAP, 'chart_shows' => '005', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_BIRTH_MAP, 'chart_shows' => '142', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_BIRTH_MAP, 'chart_shows' => '145', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_BIRTH_MAP, 'chart_shows' => '002', 'chart_type' => '', 'surn' => ''],
+
+ ['x_as' => StatisticsChartModule::X_AXIS_DEATH_MAP, 'chart_shows' => 'world', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_DEATH_MAP, 'chart_shows' => '150', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_DEATH_MAP, 'chart_shows' => '021', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_DEATH_MAP, 'chart_shows' => '005', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_DEATH_MAP, 'chart_shows' => '142', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_DEATH_MAP, 'chart_shows' => '145', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_DEATH_MAP, 'chart_shows' => '002', 'chart_type' => '', 'surn' => ''],
+
+ ['x_as' => StatisticsChartModule::X_AXIS_MARRIAGE_MAP, 'chart_shows' => 'world', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_MARRIAGE_MAP, 'chart_shows' => '150', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_MARRIAGE_MAP, 'chart_shows' => '021', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_MARRIAGE_MAP, 'chart_shows' => '005', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_MARRIAGE_MAP, 'chart_shows' => '142', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_MARRIAGE_MAP, 'chart_shows' => '145', 'chart_type' => '', 'surn' => ''],
+ ['x_as' => StatisticsChartModule::X_AXIS_MARRIAGE_MAP, 'chart_shows' => '002', 'chart_type' => '', 'surn' => ''],
+ ];
+ }
+
+ public function testTabContent(): void
+ {
+ $tree = $this->importTree('demo.ged');
+ Registry::container()->set(Tree::class, $tree);
+
+ $module = new StatisticsChartModule();
+ $request = self::createRequest(RequestMethodInterface::METHOD_POST)
+ ->withAttribute('tree', $tree);
+
+ $response = $module->getChartAction($request);
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ self::assertNotEmpty($response->getBody()->getContents());
+
+ //$response = $module->getFamiliesAction($request);
+ //self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ //self::assertNotEmpty($response->getBody()->getContents());
+
+ $response = $module->getIndividualsAction($request);
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ self::assertNotEmpty($response->getBody()->getContents());
+
+ $response = $module->getOtherAction($request);
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ self::assertNotEmpty($response->getBody()->getContents());
+ }
+
+ #[DataProvider('customChartFamilyAndIndividualOptions')]
+ public function testCustomFamilyAndIndividualCharts(int $x_as, int $y_as, int $z_as): void
{
- self::assertTrue(class_exists(StatisticsChartModule::class));
+ $tree = $this->importTree('demo.ged');
+ Registry::container()->set(Tree::class, $tree);
+
+ $module = new StatisticsChartModule();
+ $request = self::createRequest(RequestMethodInterface::METHOD_POST)
+ ->withAttribute('tree', $tree)
+ ->withParsedBody([
+ 'x-as' => $x_as,
+ 'y-as' => $y_as,
+ 'z-as' => $z_as,
+ 'x-axis-boundaries-ages' => '1,5,10,20,30,40,50,60,70,80,90,100',
+ 'x-axis-boundaries-ages_m' => '16,18,20,22,24,26,28,30,32,35,40,50',
+ 'z-axis-boundaries-periods' => '1700,1750,1800,1850,1900,1950,2000',
+ ]);
+
+ $response = $module->postCustomChartAction($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ self::assertNotEmpty($response->getBody()->getContents());
+ }
+
+ #[DataProvider('customChartMapOptions')]
+ public function testCustomMapCharts(int $x_as, string $chart_shows, string $chart_type, string $surn): void
+ {
+ $tree = $this->importTree('demo.ged');
+ Registry::container()->set(Tree::class, $tree);
+
+ $module = new StatisticsChartModule();
+ $request = self::createRequest(RequestMethodInterface::METHOD_POST)
+ ->withAttribute('tree', $tree)
+ ->withParsedBody([
+ 'x-as' => $x_as,
+ 'y-as' => '0',
+ 'z-as' => '0',
+ 'chart_shows' => $chart_shows,
+ 'chart_type' => $chart_type,
+ 'SURN' => $surn,
+ ]);
+
+ $response = $module->postCustomChartAction($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ self::assertNotEmpty($response->getBody()->getContents());
}
}
diff --git a/tests/app/Module/UpcomingAnniversariesModuleTest.php b/tests/app/Module/UpcomingAnniversariesModuleTest.php
index 049f4e0d7a..ec15e76991 100644
--- a/tests/app/Module/UpcomingAnniversariesModuleTest.php
+++ b/tests/app/Module/UpcomingAnniversariesModuleTest.php
@@ -32,7 +32,6 @@ class UpcomingAnniversariesModuleTest extends TestCase
$module = new UpcomingAnniversariesModule($calendar_service);
- self::assertInstanceOf(ModuleBlockInterface::class, $module);
self::assertTrue($module->loadAjax());
self::assertTrue($module->isTreeBlock());
self::assertTrue($module->isUserBlock());
diff --git a/tests/app/NoReplyUserTest.php b/tests/app/NoReplyUserTest.php
index badad92193..f6249fb77e 100644
--- a/tests/app/NoReplyUserTest.php
+++ b/tests/app/NoReplyUserTest.php
@@ -31,7 +31,6 @@ class NoReplyUserTest extends TestCase
{
$user = new NoReplyUser();
- self::assertInstanceOf(UserInterface::class, $user);
self::assertSame(0, $user->id());
self::assertSame('no-reply@localhost', $user->email());
self::assertSame(Webtrees::NAME, $user->realName());
diff --git a/tests/app/Services/PhpServiceTest.php b/tests/app/Services/PhpServiceTest.php
index 4a4c992408..7a9c7747ca 100644
--- a/tests/app/Services/PhpServiceTest.php
+++ b/tests/app/Services/PhpServiceTest.php
@@ -23,6 +23,7 @@ use Fisharebest\Webtrees\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use function extension_loaded;
+use function ini_get;
use function ini_parse_quantity;
use function sys_get_temp_dir;
diff --git a/tests/app/Services/SearchServiceTest.php b/tests/app/Services/SearchServiceTest.php
index 72172f7b0f..155fa92c31 100644
--- a/tests/app/Services/SearchServiceTest.php
+++ b/tests/app/Services/SearchServiceTest.php
@@ -19,6 +19,8 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Services;
+use Fisharebest\Webtrees\Auth;
+use Fisharebest\Webtrees\Contracts\UserInterface;
use Fisharebest\Webtrees\TestCase;
use Illuminate\Support\Collection;
use PHPUnit\Framework\Attributes\CoversClass;
@@ -34,37 +36,41 @@ class SearchServiceTest extends TestCase
$search_service = new SearchService($tree_service);
$tree = $this->importTree('demo.ged');
- $result = $search_service->searchFamilies([$tree], ['windsor']);
- self::assertInstanceOf(Collection::class, $result);
+ $user = (new UserService())->create('user', 'User', 'user@example.com', 'secret');
+ $user->setPreference(UserInterface::PREF_IS_ADMINISTRATOR, '1');
+ Auth::login($user);
- $result = $search_service->searchFamilyNames([$tree], ['charles', 'diana']);
- self::assertInstanceOf(Collection::class, $result);
+ $result = $search_service->searchFamilies([$tree], ['windsor'])->all();
+ self::assertNotEmpty($result);
- $result = $search_service->searchIndividuals([$tree], ['windsor']);
- self::assertInstanceOf(Collection::class, $result);
+ $result = $search_service->searchFamilyNames([$tree], ['charles', 'diana'])->all();
+ //self::assertNotEmpty($result);
- $result = $search_service->searchIndividualNames([$tree], ['windsor']);
- self::assertInstanceOf(Collection::class, $result);
+ $result = $search_service->searchIndividuals([$tree], ['windsor'])->all();
+ self::assertNotEmpty($result);
- $result = $search_service->searchMedia([$tree], ['windsor']);
- self::assertInstanceOf(Collection::class, $result);
+ $result = $search_service->searchIndividualNames([$tree], ['windsor'])->all();
+ //self::assertNotEmpty($result);
- $result = $search_service->searchNotes([$tree], ['windsor']);
- self::assertInstanceOf(Collection::class, $result);
+ $result = $search_service->searchMedia([$tree], ['windsor'])->all();
+ self::assertNotEmpty($result);
- $result = $search_service->searchRepositories([$tree], ['national']);
- self::assertInstanceOf(Collection::class, $result);
+ $result = $search_service->searchNotes([$tree], ['windsor'])->all();
+ //self::assertNotEmpty($result);
- $result = $search_service->searchSources([$tree], ['england']);
- self::assertInstanceOf(Collection::class, $result);
+ $result = $search_service->searchRepositories([$tree], ['national'])->all();
+ self::assertNotEmpty($result);
- $result = $search_service->searchSourcesByName([$tree], ['england']);
- self::assertInstanceOf(Collection::class, $result);
+ $result = $search_service->searchSources([$tree], ['england'])->all();
+ self::assertNotEmpty($result);
- $result = $search_service->searchSubmitters([$tree], ['greg']);
- self::assertInstanceOf(Collection::class, $result);
+ $result = $search_service->searchSourcesByName([$tree], ['england'])->all();
+ self::assertNotEmpty($result);
- $result = $search_service->searchPlaces($tree, 'England');
- self::assertInstanceOf(Collection::class, $result);
+ $result = $search_service->searchSubmitters([$tree], ['greg'])->all();
+ self::assertNotEmpty($result);
+
+ $result = $search_service->searchPlaces($tree, 'England')->all();
+ //self::assertNotEmpty($result);
}
}
diff --git a/tests/app/SiteUserTest.php b/tests/app/SiteUserTest.php
index 01c4a5df24..b4de3bfa86 100644
--- a/tests/app/SiteUserTest.php
+++ b/tests/app/SiteUserTest.php
@@ -33,7 +33,6 @@ class SiteUserTest extends TestCase
Site::setPreference('SMTP_FROM_NAME', 'email@example.com');
Site::setPreference('SMTP_DISP_NAME', 'My site');
- self::assertInstanceOf(UserInterface::class, $user);
self::assertSame(0, $user->id());
self::assertSame('email@example.com', $user->email());
self::assertSame('My site', $user->realName());
diff --git a/tests/app/TreeUserTest.php b/tests/app/TreeUserTest.php
index 5e0ff91e34..c372362684 100644
--- a/tests/app/TreeUserTest.php
+++ b/tests/app/TreeUserTest.php
@@ -36,7 +36,6 @@ class TreeUserTest extends TestCase
$tree = $tree_service->create('name', 'title');
$user = new TreeUser($tree);
- self::assertInstanceOf(UserInterface::class, $user);
self::assertSame(0, $user->id());
self::assertSame('', $user->email());
self::assertSame('title', $user->realName());
diff --git a/tests/app/UserTest.php b/tests/app/UserTest.php
index ddc0f35aed..e4abc6d505 100644
--- a/tests/app/UserTest.php
+++ b/tests/app/UserTest.php
@@ -46,7 +46,6 @@ class UserTest extends TestCase
{
$user = new User(123, 'username', 'real name', 'email');
- self::assertInstanceOf(UserInterface::class, $user);
self::assertSame(123, $user->id());
self::assertSame('email', $user->email());
self::assertSame('real name', $user->realName());
diff --git a/tests/feature/EmbeddedVariablesTest.php b/tests/feature/EmbeddedVariablesTest.php
index 28ab6b919b..4544317ec0 100644
--- a/tests/feature/EmbeddedVariablesTest.php
+++ b/tests/feature/EmbeddedVariablesTest.php
@@ -20,99 +20,397 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees;
use Fisharebest\Webtrees\Contracts\UserInterface;
+use Fisharebest\Webtrees\Factories\CacheFactory;
use Fisharebest\Webtrees\Services\GedcomImportService;
use Fisharebest\Webtrees\Services\ModuleService;
use Fisharebest\Webtrees\Services\TreeService;
use Fisharebest\Webtrees\Services\UserService;
-use Fisharebest\Webtrees\Statistics\Google\ChartAge;
-use Fisharebest\Webtrees\Statistics\Google\ChartBirth;
-use Fisharebest\Webtrees\Statistics\Google\ChartChildren;
-use Fisharebest\Webtrees\Statistics\Google\ChartCommonGiven;
-use Fisharebest\Webtrees\Statistics\Google\ChartCommonSurname;
-use Fisharebest\Webtrees\Statistics\Google\ChartDeath;
-use Fisharebest\Webtrees\Statistics\Google\ChartDistribution;
-use Fisharebest\Webtrees\Statistics\Google\ChartDivorce;
-use Fisharebest\Webtrees\Statistics\Google\ChartFamilyLargest;
-use Fisharebest\Webtrees\Statistics\Google\ChartFamilyWithSources;
-use Fisharebest\Webtrees\Statistics\Google\ChartIndividualWithSources;
-use Fisharebest\Webtrees\Statistics\Google\ChartMarriage;
-use Fisharebest\Webtrees\Statistics\Google\ChartMarriageAge;
-use Fisharebest\Webtrees\Statistics\Google\ChartMedia;
-use Fisharebest\Webtrees\Statistics\Google\ChartMortality;
-use Fisharebest\Webtrees\Statistics\Google\ChartNoChildrenFamilies;
-use Fisharebest\Webtrees\Statistics\Google\ChartSex;
-use Fisharebest\Webtrees\Statistics\Repository\BrowserRepository;
-use Fisharebest\Webtrees\Statistics\Repository\ContactRepository;
-use Fisharebest\Webtrees\Statistics\Repository\EventRepository;
-use Fisharebest\Webtrees\Statistics\Repository\FamilyDatesRepository;
-use Fisharebest\Webtrees\Statistics\Repository\FamilyRepository;
-use Fisharebest\Webtrees\Statistics\Repository\FavoritesRepository;
-use Fisharebest\Webtrees\Statistics\Repository\GedcomRepository;
-use Fisharebest\Webtrees\Statistics\Repository\HitCountRepository;
-use Fisharebest\Webtrees\Statistics\Repository\IndividualRepository;
-use Fisharebest\Webtrees\Statistics\Repository\LatestUserRepository;
-use Fisharebest\Webtrees\Statistics\Repository\MediaRepository;
-use Fisharebest\Webtrees\Statistics\Repository\MessageRepository;
-use Fisharebest\Webtrees\Statistics\Repository\NewsRepository;
-use Fisharebest\Webtrees\Statistics\Repository\PlaceRepository;
-use Fisharebest\Webtrees\Statistics\Repository\ServerRepository;
-use Fisharebest\Webtrees\Statistics\Repository\UserRepository;
use Fisharebest\Webtrees\Statistics\Service\CenturyService;
use Fisharebest\Webtrees\Statistics\Service\ColorService;
use Fisharebest\Webtrees\Statistics\Service\CountryService;
use PHPUnit\Framework\Attributes\CoversClass;
use Psr\Http\Message\ServerRequestInterface;
-#[CoversClass(Statistics::class)]
-#[CoversClass(BrowserRepository::class)]
-#[CoversClass(ServerRepository::class)]
-#[CoversClass(LatestUserRepository::class)]
-#[CoversClass(FamilyDatesRepository::class)]
-#[CoversClass(HitCountRepository::class)]
-#[CoversClass(NewsRepository::class)]
-#[CoversClass(FavoritesRepository::class)]
-#[CoversClass(IndividualRepository::class)]
-#[CoversClass(MediaRepository::class)]
-#[CoversClass(MessageRepository::class)]
-#[CoversClass(ContactRepository::class)]
-#[CoversClass(GedcomRepository::class)]
-#[CoversClass(FamilyRepository::class)]
-#[CoversClass(EventRepository::class)]
-#[CoversClass(PlaceRepository::class)]
-#[CoversClass(UserRepository::class)]
-#[CoversClass(ChartChildren::class)]
-#[CoversClass(ChartAge::class)]
-#[CoversClass(ChartCommonGiven::class)]
-#[CoversClass(ChartMarriageAge::class)]
-#[CoversClass(ChartCommonSurname::class)]
-#[CoversClass(ChartDistribution::class)]
-#[CoversClass(ChartFamilyLargest::class)]
-#[CoversClass(ChartNoChildrenFamilies::class)]
-#[CoversClass(ChartSex::class)]
-#[CoversClass(ChartMedia::class)]
-#[CoversClass(ChartMarriage::class)]
-#[CoversClass(ChartFamilyWithSources::class)]
-#[CoversClass(ChartMortality::class)]
-#[CoversClass(ChartDeath::class)]
-#[CoversClass(ChartIndividualWithSources::class)]
-#[CoversClass(ChartBirth::class)]
-#[CoversClass(ChartDivorce::class)]
-#[CoversClass(CountryService::class)]
#[CoversClass(CenturyService::class)]
+#[CoversClass(ColorService::class)]
+#[CoversClass(Statistics::class)]
class EmbeddedVariablesTest extends TestCase
{
+ private const PLACEHOLDERS = [
+ '#getAllTagsTable#',
+ '#ageBetweenSpousesFM#',
+ '#ageBetweenSpousesFM:5#',
+ '#ageBetweenSpousesFMList#',
+ '#ageBetweenSpousesFMList:5#',
+ '#ageBetweenSpousesMF#',
+ '#ageBetweenSpousesMF:5#',
+ '#ageBetweenSpousesMFList#',
+ '#ageBetweenSpousesMFList:5#',
+ '#averageChildren#',
+ '#averageLifespan#',
+ '#averageLifespan:1#',
+ '#averageLifespanFemale#',
+ '#averageLifespanFemale:1#',
+ '#averageLifespanMale#',
+ '#averageLifespanMale:1#',
+ '#browserDate#',
+ '#browserTime#',
+ '#browserTimezone#',
+ '#callBlock#',
+ '#callBlock:gedcom_block#',
+ '#callBlock:review_changes:sendmail=0:days=2#',
+ '#chartCommonGiven#',
+ '#chartCommonGiven:ffffff:000000:5#',
+ '#chartDistribution#',
+ '#chartDistribution:150#',
+ '#chartDistribution:world:surname_distribution_chart#',
+ '#chartDistribution:world:surname_distribution_chart:windsor#',
+ '#chartDistribution:world:birth_distribution_chart#',
+ '#chartDistribution:world:death_distribution_chart#',
+ '#chartDistribution:world:marriage_distribution_chart#',
+ '#chartDistribution:world:indi_distribution_chart#',
+ '#chartFamsWithSources#',
+ '#chartIndisWithSources#',
+ '#chartLargestFamilies#',
+ '#chartLargestFamilies:ffffff:000000:5#',
+ '#chartMedia#',
+ '#chartMortality#',
+ '#chartNoChildrenFamilies#',
+ '#chartSex#',
+ '#commonBirthPlacesList#',
+ '#commonBirthPlacesList:5#',
+ '#commonCountriesList#',
+ '#commonCountriesList:5#',
+ '#commonDeathPlacesList#',
+ '#commonDeathPlacesList:5#',
+ '#commonGiven#',
+ '#commonGiven:5:5#',
+ '#commonGivenFemale:5:5#',
+ '#commonGivenFemale#',
+ '#commonGivenFemale:5:5#',
+ '#commonGivenFemaleList#',
+ '#commonGivenFemaleList:5:5#',
+ '#commonGivenFemaleListTotals#',
+ '#commonGivenFemaleListTotals:5:5#',
+ '#commonGivenFemaleTable#',
+ '#commonGivenFemaleTable:5:5#',
+ '#commonGivenFemaleTotals#',
+ '#commonGivenFemaleTotals:5:5#',
+ '#commonGivenList#',
+ '#commonGivenList:5:5#',
+ '#commonGivenListTotals#',
+ '#commonGivenListTotals:5:5#',
+ '#commonGivenMale#',
+ '#commonGivenMale:5:5#',
+ '#commonGivenMaleList#',
+ '#commonGivenMaleList:5:5#',
+ '#commonGivenMaleListTotals#',
+ '#commonGivenMaleListTotals:5:5#',
+ '#commonGivenMaleTable#',
+ '#commonGivenMaleTable:5:5#',
+ '#commonGivenMaleTotals#',
+ '#commonGivenMaleTotals:5:5#',
+ '#commonGivenTable#',
+ '#commonGivenTable:5:5#',
+ '#commonGivenTotals#',
+ '#commonGivenTotals:5:5#',
+ '#commonGivenUnknown#',
+ '#commonGivenUnknown:5:5#',
+ '#commonGivenUnknownList#',
+ '#commonGivenUnknownList:5:5#',
+ '#commonGivenUnknownListTotals#',
+ '#commonGivenUnknownListTotals:5:5#',
+ '#commonGivenUnknownTable#',
+ '#commonGivenUnknownTable:5:5#',
+ '#commonGivenUnknownTotals#',
+ '#commonGivenUnknownTotals:5:5#',
+ '#commonMarriagePlacesList#',
+ '#commonMarriagePlacesList:5:5#',
+ '#commonSurnames#',
+ '#commonSurnames:5:5:alpha#',
+ '#commonSurnames:5:5:count#',
+ '#commonSurnames:5:5:rcount#',
+ '#commonSurnamesList#',
+ '#commonSurnamesList:5:5:alpha#',
+ '#commonSurnamesList:5:5:count##',
+ '#commonSurnamesList:5:5:rcount#',
+ '#commonSurnamesListTotals#',
+ '#commonSurnamesListTotals:5:5:alpha#',
+ '#commonSurnamesListTotals:5:5:count##',
+ '#commonSurnamesListTotals:5:5:rcount#',
+ '#commonSurnamesTotals#',
+ '#commonSurnamesTotals:5:5:alpha#',
+ '#commonSurnamesTotals:5:5:count##',
+ '#commonSurnamesTotals:5:5:rcount#',
+ '#contactGedcom#',
+ '#contactWebmaster#',
+ '#firstBirth#',
+ '#firstBirthName#',
+ '#firstBirthPlace#',
+ '#firstBirthYear#',
+ '#firstDeath#',
+ '#firstDeathName#',
+ '#firstDeathPlace#',
+ '#firstDeathYear#',
+ '#firstDivorce#',
+ '#firstDivorceName#',
+ '#firstDivorcePlace#',
+ '#firstDivorceYear#',
+ '#firstEvent#',
+ '#firstEventName#',
+ '#firstEventPlace#',
+ '#firstEventType#',
+ '#firstEventYear#',
+ '#firstMarriage#',
+ '#firstMarriageName#',
+ '#firstMarriagePlace#',
+ '#firstMarriageYear#',
+ '#gedcomCreatedSoftware#',
+ '#gedcomCreatedVersion#',
+ '#gedcomDate#',
+ '#gedcomFavorites#',
+ '#gedcomFilename#',
+ '#gedcomRootId#',
+ '#gedcomTitle#',
+ '#gedcomUpdated#',
+ '#getCommonSurname#',
+ '#hitCount#',
+ '#hitCountFam#',
+ '#hitCountFam:X1#',
+ '#hitCountIndi#',
+ '#hitCountIndi:X1#',
+ '#hitCountNote#',
+ '#hitCountNote:X1#',
+ '#hitCountObje#',
+ '#hitCountObje:X1#',
+ '#hitCountRepo#',
+ '#hitCountRepo:X1#',
+ '#hitCountSour#',
+ '#hitCountSour:X1#',
+ '#hitCountUser#',
+ '#largestFamily#',
+ '#largestFamilyName#',
+ '#largestFamilySize#',
+ '#lastBirth#',
+ '#lastBirthName#',
+ '#lastBirthPlace#',
+ '#lastBirthYear#',
+ '#lastDeath#',
+ '#lastDeathName#',
+ '#lastDeathPlace#',
+ '#lastDeathYear#',
+ '#lastDivorce#',
+ '#lastDivorceName#',
+ '#lastDivorcePlace#',
+ '#lastDivorceYear#',
+ '#lastEvent#',
+ '#lastEventName#',
+ '#lastEventPlace#',
+ '#lastEventType#',
+ '#lastEventYear#',
+ '#lastMarriage#',
+ '#lastMarriageName#',
+ '#lastMarriagePlace#',
+ '#lastMarriageYear#',
+ '#latestUserFullName#',
+ '#latestUserId#',
+ '#latestUserLoggedin#',
+ '#latestUserLoggedin:Oui:Non#',
+ '#latestUserName#',
+ '#latestUserRegDate#',
+ '#latestUserRegDate:%j %F %Y#',
+ '#latestUserRegTime#',
+ '#latestUserRegTime:%H:%i:%s#',
+ '#longestLife#',
+ '#longestLifeAge#',
+ '#longestLifeFemale#',
+ '#longestLifeFemaleAge#',
+ '#longestLifeFemaleName#',
+ '#longestLifeMale#',
+ '#longestLifeMaleAge#',
+ '#longestLifeMaleName#',
+ '#longestLifeName#',
+ '#minAgeOfMarriage#',
+ '#minAgeOfMarriageFamilies#',
+ '#minAgeOfMarriageFamilies:5#',
+ '#minAgeOfMarriageFamiliesList#',
+ '#minAgeOfMarriageFamiliesList:5#',
+ '#minAgeOfMarriageFamily#',
+ '#noChildrenFamilies#',
+ '#noChildrenFamiliesList#',
+ '#noChildrenFamiliesList:nolist#',
+ '#oldestFather#',
+ '#oldestFatherAge#',
+ '#oldestFatherName#',
+ '#oldestMarriageFemale#',
+ '#oldestMarriageFemaleAge#',
+ '#oldestMarriageFemaleAge:1#',
+ '#oldestMarriageFemaleName#',
+ '#oldestMarriageMale#',
+ '#oldestMarriageMaleAge#',
+ '#oldestMarriageMaleAge:1#',
+ '#oldestMarriageMaleName#',
+ '#oldestMother#',
+ '#oldestMotherAge#',
+ '#oldestMotherAge:1#',
+ '#oldestMotherName#',
+ '#serverDate#',
+ '#serverTime#',
+ '#serverTime24#',
+ '#serverTimezone#',
+ '#statsAge#',
+ '#statsBirth#',
+ '#statsChildren#',
+ '#statsDeath#',
+ '#statsDiv#',
+ '#statsMarr#',
+ '#statsMarrAge#',
+ '#topAgeBetweenSiblings#',
+ '#topAgeBetweenSiblingsFullName#',
+ '#topAgeBetweenSiblingsList#',
+ '#topAgeBetweenSiblingsList:5:1#',
+ '#topAgeBetweenSiblingsName#',
+ '#topAgeOfMarriage#',
+ '#topAgeOfMarriageFamilies#',
+ '#topAgeOfMarriageFamilies:5#',
+ '#topAgeOfMarriageFamiliesList#',
+ '#topAgeOfMarriageFamiliesList:5#',
+ '#topAgeOfMarriageFamily#',
+ '#topTenLargestFamily#',
+ '#topTenLargestFamily:5#',
+ '#topTenLargestFamilyList#',
+ '#topTenLargestFamilyList:5#',
+ '#topTenLargestGrandFamily#',
+ '#topTenLargestGrandFamily:5#',
+ '#topTenLargestGrandFamilyList#',
+ '#topTenLargestGrandFamilyList:5#',
+ '#topTenOldest#',
+ '#topTenOldest:5#',
+ '#topTenOldestAlive#',
+ '#topTenOldestAlive:5#',
+ '#topTenOldestFemale#',
+ '#topTenOldestFemale:5#',
+ '#topTenOldestFemaleAlive#',
+ '#topTenOldestFemaleAlive:5#',
+ '#topTenOldestFemaleList#',
+ '#topTenOldestFemaleList:5#',
+ '#topTenOldestFemaleListAlive#',
+ '#topTenOldestFemaleListAlive:5#',
+ '#topTenOldestList#',
+ '#topTenOldestList:5#',
+ '#topTenOldestListAlive#',
+ '#topTenOldestListAlive:5#',
+ '#topTenOldestMale#',
+ '#topTenOldestMale:5#',
+ '#topTenOldestMaleAlive#',
+ '#topTenOldestMaleAlive:5#',
+ '#topTenOldestMaleList#',
+ '#topTenOldestMaleList:5#',
+ '#topTenOldestMaleListAlive#',
+ '#topTenOldestMaleListAlive:5#',
+ '#totalAdmins#',
+ '#totalBirths#',
+ '#totalChildren#',
+ '#totalDeaths#',
+ '#totalDeceased#',
+ '#totalDeceasedPercentage#',
+ '#totalDivorces#',
+ '#totalEvents#',
+ '#totalEventsBirth#',
+ '#totalEventsDeath#',
+ '#totalEventsDivorce#',
+ '#totalEventsMarriage#',
+ '#totalEventsOther#',
+ '#totalFamilies#',
+ '#totalFamiliesPercentage#',
+ '#totalFamsWithSources#',
+ '#totalFamsWithSourcesPercentage#',
+ '#totalGedcomFavorites#',
+ '#totalGivennames#',
+ '#totalGivennames:Charles#',
+ '#totalIndisWithSources#',
+ '#totalIndisWithSourcesPercentage#',
+ '#totalIndividuals#',
+ '#totalIndividualsPercentage#',
+ '#totalLiving#',
+ '#totalLivingPercentage#',
+ '#totalMarriages#',
+ '#totalMarriedFemales#',
+ '#totalMarriedMales#',
+ '#totalMedia#',
+ '#totalMediaAudio#',
+ '#totalMediaBook#',
+ '#totalMediaCard#',
+ '#totalMediaCertificate#',
+ '#totalMediaCoatOfArms#',
+ '#totalMediaDocument#',
+ '#totalMediaElectronic#',
+ '#totalMediaFiche#',
+ '#totalMediaFilm#',
+ '#totalMediaMagazine#',
+ '#totalMediaManuscript#',
+ '#totalMediaMap#',
+ '#totalMediaNewspaper#',
+ '#totalMediaOther#',
+ '#totalMediaPainting#',
+ '#totalMediaPhoto#',
+ '#totalMediaTombstone#',
+ '#totalMediaUnknown#',
+ '#totalMediaVideo#',
+ '#totalNonAdmins#',
+ '#totalNotes#',
+ '#totalNotesPercentage#',
+ '#totalPlaces#',
+ '#totalRecords#',
+ '#totalRepositories#',
+ '#totalRepositoriesPercentage#',
+ '#totalSexFemales#',
+ '#totalSexFemalesPercentage#',
+ '#totalSexMales#',
+ '#totalSexMalesPercentage#',
+ '#totalSexUnknown#',
+ '#totalSexUnknownPercentage#',
+ '#totalSources#',
+ '#totalSourcesPercentage#',
+ '#totalSurnames#',
+ '#totalSurnames:Spencer#',
+ '#totalUserFavorites#',
+ '#totalUserJournal#',
+ '#totalUserMessages#',
+ '#totalUsers#',
+ '#userFavorites#',
+ '#userFullName#',
+ '#userId#',
+ '#userName#',
+ '#userName:Foo Bar#',
+ '#usersLoggedIn#',
+ '#usersLoggedInList#',
+ '#webtreesVersion#',
+ '#youngestFather#',
+ '#youngestFatherAge#',
+ '#youngestFatherAge:1#',
+ '#youngestFatherName#',
+ '#youngestMarriageFemale#',
+ '#youngestMarriageFemaleAge#',
+ '#youngestMarriageFemaleAge:1#',
+ '#youngestMarriageFemaleName#',
+ '#youngestMarriageMale#',
+ '#youngestMarriageMaleAge#',
+ '#youngestMarriageMaleAge:1#',
+ '#youngestMarriageMaleName#',
+ '#youngestMother#',
+ '#youngestMotherAge#',
+ '#youngestMotherAge:1#',
+ '#youngestMotherName#',
+ ];
+
protected static bool $uses_database = true;
public function testAllEmbeddedVariables(): void
{
$user_service = new UserService();
-
- $user = $user_service->create('user', 'User', 'user@example.com', 'secret');
- $user->setPreference(UserInterface::PREF_IS_ADMINISTRATOR, '1');
- Auth::login($user);
-
- $tree = $this->importTree('demo.ged');
- $request = self::createRequest()->withAttribute('tree', $tree);
+ $tree = $this->importTree('demo.ged');
+ $request = self::createRequest()->withAttribute('tree', $tree);
Registry::container()->set(ServerRequestInterface::class, $request);
$statistics = new Statistics(
@@ -124,39 +422,58 @@ class EmbeddedVariablesTest extends TestCase
$user_service
);
- // As member
- $text = $statistics->embedTags('#getAllTagsTable#');
- self::assertNotEquals('#getAllTagsTable#', $text);
-
// As visitor
- $text = $statistics->embedTags('#getAllTagsTable#');
- self::assertNotEquals('#getAllTagsTable#', $text);
+ Registry::cache(new CacheFactory());
+ foreach (self::PLACEHOLDERS as $placeholder) {
+ $text = $statistics->embedTags($placeholder);
+ self::assertNotEquals($placeholder, $text);
+ }
+
+ // As member
+ $user = $user_service->create('user', 'User', 'user@example.com', 'secret');
+ $user->setPreference(UserInterface::PREF_IS_ADMINISTRATOR, '1');
+ Auth::login($user);
+ Registry::cache(new CacheFactory());
+ foreach (self::PLACEHOLDERS as $placeholder) {
+ $text = $statistics->embedTags($placeholder);
+ self::assertNotEquals($placeholder, $text);
+ }
}
public function testAllEmbeddedVariablesWithEmptyTree(): void
{
+ $user_service = new UserService();
$gedcom_import_service = new GedcomImportService();
$tree_service = new TreeService($gedcom_import_service);
$tree = $tree_service->create('name', 'title');
- $statistics = new Statistics(
+ $request = self::createRequest()->withAttribute('tree', $tree);
+ Registry::container()->set(ServerRequestInterface::class, $request);
+
+ $statistics = new Statistics(
new CenturyService(),
new ColorService(),
new CountryService(),
new ModuleService(),
$tree,
- new UserService()
+ $user_service
);
// As visitor
- $text = $statistics->embedTags('#getAllTagsTable#');
- self::assertNotEquals('#getAllTagsTable#', $text);
+ Registry::cache(new CacheFactory());
+ foreach (self::PLACEHOLDERS as $placeholder) {
+ $text = $statistics->embedTags($placeholder);
+ self::assertNotEquals($placeholder, $text);
+ }
// As member
- $user = (new UserService())->create('user', 'User', 'user@example.com', 'secret');
+ $user = $user_service->create('user', 'User', 'user@example.com', 'secret');
$user->setPreference(UserInterface::PREF_IS_ADMINISTRATOR, '1');
Auth::login($user);
+ Registry::cache(new CacheFactory());
- $text = $statistics->embedTags('#getAllTagsTable#');
- self::assertNotEquals('#getAllTagsTable#', $text);
+ foreach (self::PLACEHOLDERS as $placeholder) {
+ $text = $statistics->embedTags($placeholder);
+ self::assertNotEquals($placeholder, $text);
+ }
}
}