xref: /webtrees/tests/app/Census/CensusTest.php (revision 234e0863a607ff8e5f8e78a7fefe5366f39f8ebf)
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
26#[CoversClass(Census::class)]
27class CensusTest extends TestCase
28{
29    public function testCensusPlacesCzech(): void
30    {
31        $censuses = Census::censusPlaces('cs');
32
33        self::assertCount(11, $censuses);
34        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[0]);
35        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[1]);
36        self::assertInstanceOf(CensusOfDenmark::class, $censuses[2]);
37        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[3]);
38        self::assertInstanceOf(CensusOfEngland::class, $censuses[4]);
39        self::assertInstanceOf(CensusOfFrance::class, $censuses[5]);
40        self::assertInstanceOf(CensusOfScotland::class, $censuses[6]);
41        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[7]);
42        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[8]);
43        self::assertInstanceOf(CensusOfWales::class, $censuses[9]);
44        self::assertInstanceOf(CensusOfCanada::class, $censuses[10]);
45    }
46
47    public function testCensusPlacesDanish(): void
48    {
49        $censuses = Census::censusPlaces('da');
50
51        self::assertCount(11, $censuses);
52        self::assertInstanceOf(CensusOfDenmark::class, $censuses[0]);
53        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[1]);
54        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[2]);
55        self::assertInstanceOf(CensusOfEngland::class, $censuses[3]);
56        self::assertInstanceOf(CensusOfFrance::class, $censuses[4]);
57        self::assertInstanceOf(CensusOfScotland::class, $censuses[5]);
58        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[6]);
59        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[7]);
60        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[8]);
61        self::assertInstanceOf(CensusOfWales::class, $censuses[9]);
62        self::assertInstanceOf(CensusOfCanada::class, $censuses[10]);
63    }
64
65    public function testCensusPlacesGerman(): void
66    {
67        $censuses = Census::censusPlaces('de');
68
69        self::assertCount(11, $censuses);
70        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[0]);
71        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[1]);
72        self::assertInstanceOf(CensusOfDenmark::class, $censuses[2]);
73        self::assertInstanceOf(CensusOfEngland::class, $censuses[3]);
74        self::assertInstanceOf(CensusOfFrance::class, $censuses[4]);
75        self::assertInstanceOf(CensusOfScotland::class, $censuses[5]);
76        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[6]);
77        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[7]);
78        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[8]);
79        self::assertInstanceOf(CensusOfWales::class, $censuses[9]);
80        self::assertInstanceOf(CensusOfCanada::class, $censuses[10]);
81    }
82
83    public function testCensusPlacesAustralianEnglish(): void
84    {
85        $censuses = Census::censusPlaces('en-AU');
86
87        self::assertCount(11, $censuses);
88        self::assertInstanceOf(CensusOfEngland::class, $censuses[0]);
89        self::assertInstanceOf(CensusOfScotland::class, $censuses[1]);
90        self::assertInstanceOf(CensusOfWales::class, $censuses[2]);
91        self::assertInstanceOf(CensusOfCanada::class, $censuses[3]);
92        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[4]);
93        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[5]);
94        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[6]);
95        self::assertInstanceOf(CensusOfDenmark::class, $censuses[7]);
96        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[8]);
97        self::assertInstanceOf(CensusOfFrance::class, $censuses[9]);
98        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[10]);
99    }
100
101    public function testCensusPlacesBritishEnglish(): void
102    {
103        $censuses = Census::censusPlaces('en-GB');
104
105        self::assertCount(11, $censuses);
106        self::assertInstanceOf(CensusOfEngland::class, $censuses[0]);
107        self::assertInstanceOf(CensusOfScotland::class, $censuses[1]);
108        self::assertInstanceOf(CensusOfWales::class, $censuses[2]);
109        self::assertInstanceOf(CensusOfCanada::class, $censuses[3]);
110        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[4]);
111        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[5]);
112        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[6]);
113        self::assertInstanceOf(CensusOfDenmark::class, $censuses[7]);
114        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[8]);
115        self::assertInstanceOf(CensusOfFrance::class, $censuses[9]);
116        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[10]);
117    }
118
119    public function testCensusPlacesUSEnglish(): void
120    {
121        $censuses = Census::censusPlaces('en-US');
122
123        self::assertCount(11, $censuses);
124        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[0]);
125        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[1]);
126        self::assertInstanceOf(CensusOfCanada::class, $censuses[2]);
127        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[3]);
128        self::assertInstanceOf(CensusOfDenmark::class, $censuses[4]);
129        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[5]);
130        self::assertInstanceOf(CensusOfEngland::class, $censuses[6]);
131        self::assertInstanceOf(CensusOfFrance::class, $censuses[7]);
132        self::assertInstanceOf(CensusOfScotland::class, $censuses[8]);
133        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[9]);
134        self::assertInstanceOf(CensusOfWales::class, $censuses[10]);
135    }
136
137    public function testCensusPlacesFrench(): void
138    {
139        $censuses = Census::censusPlaces('fr');
140
141        self::assertCount(11, $censuses);
142        self::assertInstanceOf(CensusOfFrance::class, $censuses[0]);
143        self::assertInstanceOf(CensusOfCanada::class, $censuses[1]);
144        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[2]);
145        self::assertInstanceOf(CensusOfDenmark::class, $censuses[3]);
146        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[4]);
147        self::assertInstanceOf(CensusOfEngland::class, $censuses[5]);
148        self::assertInstanceOf(CensusOfScotland::class, $censuses[6]);
149        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[7]);
150        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[8]);
151        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[9]);
152        self::assertInstanceOf(CensusOfWales::class, $censuses[10]);
153    }
154
155    public function testCensusPlacesCanadianFrench(): void
156    {
157        $censuses = Census::censusPlaces('fr-CA');
158
159        self::assertCount(11, $censuses);
160        self::assertInstanceOf(CensusOfCanada::class, $censuses[0]);
161        self::assertInstanceOf(CensusOfFrance::class, $censuses[1]);
162        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[2]);
163        self::assertInstanceOf(CensusOfDenmark::class, $censuses[3]);
164        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[4]);
165        self::assertInstanceOf(CensusOfEngland::class, $censuses[5]);
166        self::assertInstanceOf(CensusOfScotland::class, $censuses[6]);
167        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[7]);
168        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[8]);
169        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[9]);
170        self::assertInstanceOf(CensusOfWales::class, $censuses[10]);
171    }
172
173    public function testCensusPlacesSlovak(): void
174    {
175        $censuses = Census::censusPlaces('sk');
176
177        self::assertCount(11, $censuses);
178        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[0]);
179        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[1]);
180        self::assertInstanceOf(CensusOfDenmark::class, $censuses[2]);
181        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[3]);
182        self::assertInstanceOf(CensusOfEngland::class, $censuses[4]);
183        self::assertInstanceOf(CensusOfFrance::class, $censuses[5]);
184        self::assertInstanceOf(CensusOfScotland::class, $censuses[6]);
185        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[7]);
186        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[8]);
187        self::assertInstanceOf(CensusOfWales::class, $censuses[9]);
188        self::assertInstanceOf(CensusOfCanada::class, $censuses[10]);
189    }
190
191    public function testCensusPlacesDefault(): void
192    {
193        $censuses = Census::censusPlaces('XX');
194
195        self::assertCount(11, $censuses);
196        self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[0]);
197        self::assertInstanceOf(CensusOfRhodeIsland::class, $censuses[1]);
198        self::assertInstanceOf(CensusOfEngland::class, $censuses[2]);
199        self::assertInstanceOf(CensusOfScotland::class, $censuses[3]);
200        self::assertInstanceOf(CensusOfWales::class, $censuses[4]);
201        self::assertInstanceOf(CensusOfDeutschland::class, $censuses[5]);
202        self::assertInstanceOf(CensusOfFrance::class, $censuses[6]);
203        self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[7]);
204        self::assertInstanceOf(CensusOfSlovakia::class, $censuses[8]);
205        self::assertInstanceOf(CensusOfDenmark::class, $censuses[9]);
206        self::assertInstanceOf(CensusOfCanada::class, $censuses[10]);
207    }
208}
209