summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGreg Roach <greg@subaqua.co.uk>2024-10-23 16:40:38 +0100
committerGreg Roach <greg@subaqua.co.uk>2024-10-23 16:44:30 +0100
commit3ee4c7ef16663dd8419c69876f7c40ed549d5490 (patch)
tree524f4b3cd7b7ed458ef31662f58c4fc8ecb4dd24 /tests
parentd7c2f5cc56f17801156c069987440ca1da2c5057 (diff)
downloadwebtrees-3ee4c7ef16663dd8419c69876f7c40ed549d5490.tar.gz
webtrees-3ee4c7ef16663dd8419c69876f7c40ed549d5490.tar.bz2
webtrees-3ee4c7ef16663dd8419c69876f7c40ed549d5490.zip
Refactor HistoricEventsInterface to allow testing
Diffstat (limited to 'tests')
-rw-r--r--tests/app/Module/AustrianHistoricEventsTest.php13
-rw-r--r--tests/app/Module/AustrianPresidentsTest.php13
-rw-r--r--tests/app/Module/BritishMonarchsTest.php13
-rw-r--r--tests/app/Module/BritishPrimeMinistersTest.php13
-rw-r--r--tests/app/Module/BritishSocialHistoryTest.php13
-rw-r--r--tests/app/Module/CzechMonarchsAndPresidentsTest.php13
-rw-r--r--tests/app/Module/DutchMonarchsTest.php13
-rw-r--r--tests/app/Module/DutchPrimeMinistersTest.php13
-rw-r--r--tests/app/Module/FrenchHistoryTest.php13
-rw-r--r--tests/app/Module/LowCountriesRulersTest.php13
-rw-r--r--tests/app/Module/NewZealandPrimeMinistersTest.php41
-rw-r--r--tests/app/Module/USPresidentsTest.php13
12 files changed, 162 insertions, 22 deletions
diff --git a/tests/app/Module/AustrianHistoricEventsTest.php b/tests/app/Module/AustrianHistoricEventsTest.php
index 56fe149be8..ee8d9a333c 100644
--- a/tests/app/Module/AustrianHistoricEventsTest.php
+++ b/tests/app/Module/AustrianHistoricEventsTest.php
@@ -19,14 +19,23 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(AustrianHistoricEvents::class)]
class AustrianHistoricEventsTest extends TestCase
{
- public function testClass(): void
+ public function testEventsHaveValidDate(): void
{
- self::assertTrue(class_exists(AustrianHistoricEvents::class));
+ $module = new AustrianHistoricEvents();
+
+ $individual = $this->createMock(Individual::class);
+
+ foreach ($module->historicEventsAll(language_tag: 'de') as $gedcom) {
+ $fact = new Fact(gedcom: $gedcom, parent: $individual, id: 'test');
+ self::assertTrue(condition: $fact->date()->isOK(), message: 'No date found in: ' . $gedcom);
+ }
}
}
diff --git a/tests/app/Module/AustrianPresidentsTest.php b/tests/app/Module/AustrianPresidentsTest.php
index d6f44ec107..4c1b96e894 100644
--- a/tests/app/Module/AustrianPresidentsTest.php
+++ b/tests/app/Module/AustrianPresidentsTest.php
@@ -19,14 +19,23 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(AustrianPresidents::class)]
class AustrianPresidentsTest extends TestCase
{
- public function testClass(): void
+ public function testEventsHaveValidDate(): void
{
- self::assertTrue(class_exists(AustrianPresidents::class));
+ $module = new AustrianPresidents();
+
+ $individual = $this->createMock(Individual::class);
+
+ foreach ($module->historicEventsAll(language_tag: 'de') as $gedcom) {
+ $fact = new Fact(gedcom: $gedcom, parent: $individual, id: 'test');
+ self::assertTrue(condition: $fact->date()->isOK(), message: 'No date found in: ' . $gedcom);
+ }
}
}
diff --git a/tests/app/Module/BritishMonarchsTest.php b/tests/app/Module/BritishMonarchsTest.php
index 582c05eaf7..99aec5e635 100644
--- a/tests/app/Module/BritishMonarchsTest.php
+++ b/tests/app/Module/BritishMonarchsTest.php
@@ -19,14 +19,23 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(BritishMonarchs::class)]
class BritishMonarchsTest extends TestCase
{
- public function testClass(): void
+ public function testEventsHaveValidDate(): void
{
- self::assertTrue(class_exists(BritishMonarchs::class));
+ $module = new BritishMonarchs();
+
+ $individual = $this->createMock(Individual::class);
+
+ foreach ($module->historicEventsAll(language_tag: 'en-GB') as $gedcom) {
+ $fact = new Fact(gedcom: $gedcom, parent: $individual, id: 'test');
+ self::assertTrue(condition: $fact->date()->isOK(), message: 'No date found in: ' . $gedcom);
+ }
}
}
diff --git a/tests/app/Module/BritishPrimeMinistersTest.php b/tests/app/Module/BritishPrimeMinistersTest.php
index f62629ae0d..d7adce8fe9 100644
--- a/tests/app/Module/BritishPrimeMinistersTest.php
+++ b/tests/app/Module/BritishPrimeMinistersTest.php
@@ -19,14 +19,23 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(BritishPrimeMinisters::class)]
class BritishPrimeMinistersTest extends TestCase
{
- public function testClass(): void
+ public function testEventsHaveValidDate(): void
{
- self::assertTrue(class_exists(BritishPrimeMinisters::class));
+ $module = new BritishPrimeMinisters();
+
+ $individual = $this->createMock(Individual::class);
+
+ foreach ($module->historicEventsAll(language_tag: 'en-GB') as $gedcom) {
+ $fact = new Fact(gedcom: $gedcom, parent: $individual, id: 'test');
+ self::assertTrue(condition: $fact->date()->isOK(), message: 'No date found in: ' . $gedcom);
+ }
}
}
diff --git a/tests/app/Module/BritishSocialHistoryTest.php b/tests/app/Module/BritishSocialHistoryTest.php
index 5ef7b8b41a..f3b14bcfac 100644
--- a/tests/app/Module/BritishSocialHistoryTest.php
+++ b/tests/app/Module/BritishSocialHistoryTest.php
@@ -19,14 +19,23 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(BritishSocialHistory::class)]
class BritishSocialHistoryTest extends TestCase
{
- public function testClass(): void
+ public function testEventsHaveValidDate(): void
{
- self::assertTrue(class_exists(BritishSocialHistory::class));
+ $module = new BritishSocialHistory();
+
+ $individual = $this->createMock(Individual::class);
+
+ foreach ($module->historicEventsAll(language_tag: 'en-GB') as $gedcom) {
+ $fact = new Fact(gedcom: $gedcom, parent: $individual, id: 'test');
+ self::assertTrue(condition: $fact->date()->isOK(), message: 'No date found in: ' . $gedcom);
+ }
}
}
diff --git a/tests/app/Module/CzechMonarchsAndPresidentsTest.php b/tests/app/Module/CzechMonarchsAndPresidentsTest.php
index 62c918e881..eb4d6b8145 100644
--- a/tests/app/Module/CzechMonarchsAndPresidentsTest.php
+++ b/tests/app/Module/CzechMonarchsAndPresidentsTest.php
@@ -19,14 +19,23 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(CzechMonarchsAndPresidents::class)]
class CzechMonarchsAndPresidentsTest extends TestCase
{
- public function testClass(): void
+ public function testEventsHaveValidDate(): void
{
- self::assertTrue(class_exists(CzechMonarchsAndPresidents::class));
+ $module = new CzechMonarchsAndPresidents();
+
+ $individual = $this->createMock(Individual::class);
+
+ foreach ($module->historicEventsAll(language_tag: 'cs') as $gedcom) {
+ $fact = new Fact(gedcom: $gedcom, parent: $individual, id: 'test');
+ self::assertTrue(condition: $fact->date()->isOK(), message: 'No date found in: ' . $gedcom);
+ }
}
}
diff --git a/tests/app/Module/DutchMonarchsTest.php b/tests/app/Module/DutchMonarchsTest.php
index 3123a83105..dec9e8a226 100644
--- a/tests/app/Module/DutchMonarchsTest.php
+++ b/tests/app/Module/DutchMonarchsTest.php
@@ -19,14 +19,23 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(DutchMonarchs::class)]
class DutchMonarchsTest extends TestCase
{
- public function testClass(): void
+ public function testEventsHaveValidDate(): void
{
- self::assertTrue(class_exists(DutchMonarchs::class));
+ $module = new DutchMonarchs();
+
+ $individual = $this->createMock(Individual::class);
+
+ foreach ($module->historicEventsAll(language_tag: 'nl') as $gedcom) {
+ $fact = new Fact(gedcom: $gedcom, parent: $individual, id: 'test');
+ self::assertTrue(condition: $fact->date()->isOK(), message: 'No date found in: ' . $gedcom);
+ }
}
}
diff --git a/tests/app/Module/DutchPrimeMinistersTest.php b/tests/app/Module/DutchPrimeMinistersTest.php
index 86a5879cfc..c32aa5af4f 100644
--- a/tests/app/Module/DutchPrimeMinistersTest.php
+++ b/tests/app/Module/DutchPrimeMinistersTest.php
@@ -19,14 +19,23 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(DutchPrimeMinisters::class)]
class DutchPrimeMinistersTest extends TestCase
{
- public function testClass(): void
+ public function testEventsHaveValidDate(): void
{
- self::assertTrue(class_exists(DutchPrimeMinisters::class));
+ $module = new DutchPrimeMinisters();
+
+ $individual = $this->createMock(Individual::class);
+
+ foreach ($module->historicEventsAll(language_tag: 'nl') as $gedcom) {
+ $fact = new Fact(gedcom: $gedcom, parent: $individual, id: 'test');
+ self::assertTrue(condition: $fact->date()->isOK(), message: 'No date found in: ' . $gedcom);
+ }
}
}
diff --git a/tests/app/Module/FrenchHistoryTest.php b/tests/app/Module/FrenchHistoryTest.php
index bca273d97a..376c19e900 100644
--- a/tests/app/Module/FrenchHistoryTest.php
+++ b/tests/app/Module/FrenchHistoryTest.php
@@ -19,14 +19,23 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(FrenchHistory::class)]
class FrenchHistoryTest extends TestCase
{
- public function testClass(): void
+ public function testEventsHaveValidDate(): void
{
- self::assertTrue(class_exists(FrenchHistory::class));
+ $module = new FrenchHistory();
+
+ $individual = $this->createMock(Individual::class);
+
+ foreach ($module->historicEventsAll(language_tag: 'fr') as $gedcom) {
+ $fact = new Fact(gedcom: $gedcom, parent: $individual, id: 'test');
+ self::assertTrue(condition: $fact->date()->isOK(), message: 'No date found in: ' . $gedcom);
+ }
}
}
diff --git a/tests/app/Module/LowCountriesRulersTest.php b/tests/app/Module/LowCountriesRulersTest.php
index 5c3b7c0559..bedc584194 100644
--- a/tests/app/Module/LowCountriesRulersTest.php
+++ b/tests/app/Module/LowCountriesRulersTest.php
@@ -19,14 +19,23 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(LowCountriesRulers::class)]
class LowCountriesRulersTest extends TestCase
{
- public function testClass(): void
+ public function testEventsHaveValidDate(): void
{
- self::assertTrue(class_exists(LowCountriesRulers::class));
+ $module = new LowCountriesRulers();
+
+ $individual = $this->createMock(Individual::class);
+
+ foreach ($module->historicEventsAll(language_tag: 'nl') as $gedcom) {
+ $fact = new Fact(gedcom: $gedcom, parent: $individual, id: 'test');
+ self::assertTrue(condition: $fact->date()->isOK(), message: 'No date found in: ' . $gedcom);
+ }
}
}
diff --git a/tests/app/Module/NewZealandPrimeMinistersTest.php b/tests/app/Module/NewZealandPrimeMinistersTest.php
new file mode 100644
index 0000000000..dc8d0c2474
--- /dev/null
+++ b/tests/app/Module/NewZealandPrimeMinistersTest.php
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * webtrees: online genealogy
+ * Copyright (C) 2023 webtrees development team
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+declare(strict_types=1);
+
+namespace Fisharebest\Webtrees\Module;
+
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
+
+#[CoversClass(NewZealandPrimeMinisters::class)]
+class NewZealandPrimeMinistersTest extends TestCase
+{
+ public function testEventsHaveValidDate(): void
+ {
+ $module = new NewZealandPrimeMinisters();
+
+ $individual = $this->createMock(Individual::class);
+
+ foreach ($module->historicEventsAll(language_tag: 'en-AU') as $gedcom) {
+ $fact = new Fact(gedcom: $gedcom, parent: $individual, id: 'test');
+ self::assertTrue(condition: $fact->date()->isOK(), message: 'No date found in: ' . $gedcom);
+ }
+ }
+}
diff --git a/tests/app/Module/USPresidentsTest.php b/tests/app/Module/USPresidentsTest.php
index ab993ed0d6..e00b5cc6ba 100644
--- a/tests/app/Module/USPresidentsTest.php
+++ b/tests/app/Module/USPresidentsTest.php
@@ -19,14 +19,23 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Module;
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(USPresidents::class)]
class USPresidentsTest extends TestCase
{
- public function testClass(): void
+ public function testEventsHaveValidDate(): void
{
- self::assertTrue(class_exists(USPresidents::class));
+ $module = new USPresidents();
+
+ $individual = $this->createMock(Individual::class);
+
+ foreach ($module->historicEventsAll(language_tag: 'en-US') as $gedcom) {
+ $fact = new Fact(gedcom: $gedcom, parent: $individual, id: 'test');
+ self::assertTrue(condition: $fact->date()->isOK(), message: 'No date found in: ' . $gedcom);
+ }
}
}