xref: /webtrees/tests/app/Census/CensusTest.php (revision 5a8afed46297e8105e3e5a33ce37e6a8e88bc79d)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2023 webtrees development team
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\Census;
21
22use Fisharebest\Webtrees\TestCase;
23use PHPUnit\Framework\Attributes\CoversClass;
24
25#[CoversClass(Census::class)]
26class CensusTest extends TestCase
27{
28    public function testCensusPlacesCzech(): void
29    {
30        $censuses = Census::censusPlaces('cs');
31
32        self::assertCount(11, $censuses);
33        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[0]);
34        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[1]);
35        self::assertInstanceOf(CensusOfDenmark::class, $censuses[2]);
36        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[3]);
37        self::assertInstanceOf(CensusOfEngland::class, $censuses[4]);
38        self::assertInstanceOf(CensusOfFrance::class, $censuses[5]);
39        self::assertInstanceOf(CensusOfScotland::class, $censuses[6]);
40        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[7]);
41        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[8]);
42        self::assertInstanceOf(CensusOfWales::class, $censuses[9]);
43        self::assertInstanceOf(CensusOfCanada::class, $censuses[10]);
44    }
45
46    public function testCensusPlacesDanish(): void
47    {
48        $censuses = Census::censusPlaces('da');
49
50        self::assertCount(11, $censuses);
51        self::assertInstanceOf(CensusOfDenmark::class, $censuses[0]);
52        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[1]);
53        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[2]);
54        self::assertInstanceOf(CensusOfEngland::class, $censuses[3]);
55        self::assertInstanceOf(CensusOfFrance::class, $censuses[4]);
56        self::assertInstanceOf(CensusOfScotland::class, $censuses[5]);
57        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[6]);
58        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[7]);
59        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[8]);
60        self::assertInstanceOf(CensusOfWales::class, $censuses[9]);
61        self::assertInstanceOf(CensusOfCanada::class, $censuses[10]);
62    }
63
64    public function testCensusPlacesGerman(): void
65    {
66        $censuses = Census::censusPlaces('de');
67
68        self::assertCount(11, $censuses);
69        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[0]);
70        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[1]);
71        self::assertInstanceOf(CensusOfDenmark::class, $censuses[2]);
72        self::assertInstanceOf(CensusOfEngland::class, $censuses[3]);
73        self::assertInstanceOf(CensusOfFrance::class, $censuses[4]);
74        self::assertInstanceOf(CensusOfScotland::class, $censuses[5]);
75        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[6]);
76        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[7]);
77        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[8]);
78        self::assertInstanceOf(CensusOfWales::class, $censuses[9]);
79        self::assertInstanceOf(CensusOfCanada::class, $censuses[10]);
80    }
81
82    public function testCensusPlacesAustralianEnglish(): void
83    {
84        $censuses = Census::censusPlaces('en-AU');
85
86        self::assertCount(11, $censuses);
87        self::assertInstanceOf(CensusOfEngland::class, $censuses[0]);
88        self::assertInstanceOf(CensusOfScotland::class, $censuses[1]);
89        self::assertInstanceOf(CensusOfWales::class, $censuses[2]);
90        self::assertInstanceOf(CensusOfCanada::class, $censuses[3]);
91        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[4]);
92        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[5]);
93        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[6]);
94        self::assertInstanceOf(CensusOfDenmark::class, $censuses[7]);
95        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[8]);
96        self::assertInstanceOf(CensusOfFrance::class, $censuses[9]);
97        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[10]);
98    }
99
100    public function testCensusPlacesBritishEnglish(): void
101    {
102        $censuses = Census::censusPlaces('en-GB');
103
104        self::assertCount(11, $censuses);
105        self::assertInstanceOf(CensusOfEngland::class, $censuses[0]);
106        self::assertInstanceOf(CensusOfScotland::class, $censuses[1]);
107        self::assertInstanceOf(CensusOfWales::class, $censuses[2]);
108        self::assertInstanceOf(CensusOfCanada::class, $censuses[3]);
109        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[4]);
110        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[5]);
111        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[6]);
112        self::assertInstanceOf(CensusOfDenmark::class, $censuses[7]);
113        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[8]);
114        self::assertInstanceOf(CensusOfFrance::class, $censuses[9]);
115        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[10]);
116    }
117
118    public function testCensusPlacesUSEnglish(): void
119    {
120        $censuses = Census::censusPlaces('en-US');
121
122        self::assertCount(11, $censuses);
123        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[0]);
124        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[1]);
125        self::assertInstanceOf(CensusOfCanada::class, $censuses[2]);
126        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[3]);
127        self::assertInstanceOf(CensusOfDenmark::class, $censuses[4]);
128        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[5]);
129        self::assertInstanceOf(CensusOfEngland::class, $censuses[6]);
130        self::assertInstanceOf(CensusOfFrance::class, $censuses[7]);
131        self::assertInstanceOf(CensusOfScotland::class, $censuses[8]);
132        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[9]);
133        self::assertInstanceOf(CensusOfWales::class, $censuses[10]);
134    }
135
136    public function testCensusPlacesFrench(): void
137    {
138        $censuses = Census::censusPlaces('fr');
139
140        self::assertCount(11, $censuses);
141        self::assertInstanceOf(CensusOfFrance::class, $censuses[0]);
142        self::assertInstanceOf(CensusOfCanada::class, $censuses[1]);
143        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[2]);
144        self::assertInstanceOf(CensusOfDenmark::class, $censuses[3]);
145        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[4]);
146        self::assertInstanceOf(CensusOfEngland::class, $censuses[5]);
147        self::assertInstanceOf(CensusOfScotland::class, $censuses[6]);
148        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[7]);
149        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[8]);
150        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[9]);
151        self::assertInstanceOf(CensusOfWales::class, $censuses[10]);
152    }
153
154    public function testCensusPlacesCanadianFrench(): void
155    {
156        $censuses = Census::censusPlaces('fr-CA');
157
158        self::assertCount(11, $censuses);
159        self::assertInstanceOf(CensusOfCanada::class, $censuses[0]);
160        self::assertInstanceOf(CensusOfFrance::class, $censuses[1]);
161        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[2]);
162        self::assertInstanceOf(CensusOfDenmark::class, $censuses[3]);
163        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[4]);
164        self::assertInstanceOf(CensusOfEngland::class, $censuses[5]);
165        self::assertInstanceOf(CensusOfScotland::class, $censuses[6]);
166        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[7]);
167        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[8]);
168        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[9]);
169        self::assertInstanceOf(CensusOfWales::class, $censuses[10]);
170    }
171
172    public function testCensusPlacesSlovak(): void
173    {
174        $censuses = Census::censusPlaces('sk');
175
176        self::assertCount(11, $censuses);
177        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[0]);
178        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[1]);
179        self::assertInstanceOf(CensusOfDenmark::class, $censuses[2]);
180        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[3]);
181        self::assertInstanceOf(CensusOfEngland::class, $censuses[4]);
182        self::assertInstanceOf(CensusOfFrance::class, $censuses[5]);
183        self::assertInstanceOf(CensusOfScotland::class, $censuses[6]);
184        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[7]);
185        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[8]);
186        self::assertInstanceOf(CensusOfWales::class, $censuses[9]);
187        self::assertInstanceOf(CensusOfCanada::class, $censuses[10]);
188    }
189
190    public function testCensusPlacesDefault(): void
191    {
192        $censuses = Census::censusPlaces('XX');
193
194        self::assertCount(11, $censuses);
195        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[0]);
196        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[1]);
197        self::assertInstanceOf(CensusOfEngland::class, $censuses[2]);
198        self::assertInstanceOf(CensusOfScotland::class, $censuses[3]);
199        self::assertInstanceOf(CensusOfWales::class, $censuses[4]);
200        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[5]);
201        self::assertInstanceOf(CensusOfFrance::class, $censuses[6]);
202        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[7]);
203        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[8]);
204        self::assertInstanceOf(CensusOfDenmark::class, $censuses[9]);
205        self::assertInstanceOf(CensusOfCanada::class, $censuses[10]);
206    }
207}
208