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