Skip to content

Commit 21a5712

Browse files
committed
[TASK] Add first test for AddressRepository
Related: #73
1 parent 9b3c892 commit 21a5712

File tree

5 files changed

+292
-0
lines changed

5 files changed

+292
-0
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ lint:php74:
9696
if [[ "$COVERAGE" == "1" ]]; then
9797
.build/bin/phpunit --coverage-clover=phpunit.coverage.xml --log-junit=phpunit.report.xml -c Build/UnitTests.xml
9898
fi
99+
- typo3DatabaseDriver=pdo_sqlite .build/bin/phpunit -c Build/FunctionalTests.xml
99100
artifacts:
100101
paths:
101102
- phpunit.coverage.xml

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,7 @@ script:
5151
echo;
5252
echo "Running php-cs-fixer";
5353
.build/bin/php-cs-fixer fix --config=.build/.php_cs.dist -v --dry-run --using-cache=no --path-mode=intersection ./;
54+
55+
- >
56+
echo;
57+
typo3DatabaseDriver=pdo_sqlite .build/bin/phpunit -c Build/FunctionalTests.xml
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<dataset>
3+
<tx_contacts_domain_model_address>
4+
<uid>1</uid>
5+
<pid>0</pid>
6+
<title>Landtag von Baden-Württemberg</title>
7+
<type>POSTAL</type>
8+
<street>Konrad-Adenauer-Straße</street>
9+
<street_number>3</street_number>
10+
<zip>70173</zip>
11+
<city>Stuttgart</city>
12+
<region>Baden-Württemberg</region>
13+
<country>1</country>
14+
</tx_contacts_domain_model_address>
15+
<tx_contacts_domain_model_address>
16+
<uid>2</uid>
17+
<pid>0</pid>
18+
<title>Bayerischer Landtag</title>
19+
<addition1>Maximilianeum</addition1>
20+
<type>POSTAL</type>
21+
<street>Max-Planck-Straße</street>
22+
<street_number>1</street_number>
23+
<zip>81675</zip>
24+
<city>München</city>
25+
<region>Bayern</region>
26+
<country>1</country>
27+
</tx_contacts_domain_model_address>
28+
<tx_contacts_domain_model_address>
29+
<uid>3</uid>
30+
<pid>0</pid>
31+
<title>Abgeordnetenhaus von Berlin</title>
32+
<type>POSTAL</type>
33+
<street>Niederkirchnerstraße</street>
34+
<street_number>5</street_number>
35+
<zip>10117</zip>
36+
<city>Berlin</city>
37+
<region>Berlin</region>
38+
<country>1</country>
39+
</tx_contacts_domain_model_address>
40+
<tx_contacts_domain_model_address>
41+
<uid>4</uid>
42+
<pid>0</pid>
43+
<title>Landtag Brandenburg</title>
44+
<type>POSTAL</type>
45+
<street>Alter Markt</street>
46+
<street_number>1</street_number>
47+
<zip>14467</zip>
48+
<city>Potsdam</city>
49+
<region>Brandenburg</region>
50+
<country>1</country>
51+
</tx_contacts_domain_model_address>
52+
<tx_contacts_domain_model_address>
53+
<uid>5</uid>
54+
<pid>0</pid>
55+
<title>Bremische Bürgerschaft</title>
56+
<type>POSTAL</type>
57+
<street>Am Markt</street>
58+
<street_number>20</street_number>
59+
<zip>28195</zip>
60+
<city>Bremen</city>
61+
<region>Bremen</region>
62+
<country>1</country>
63+
</tx_contacts_domain_model_address>
64+
<tx_contacts_domain_model_address>
65+
<uid>6</uid>
66+
<pid>0</pid>
67+
<title>Bürgerschaft der Freien und Hansestadt Hamburg</title>
68+
<addition1>Bürgerschaftskanzlei</addition1>
69+
<type>POSTAL</type>
70+
<street>Rathausmarkt</street>
71+
<street_number>1</street_number>
72+
<zip>20095</zip>
73+
<city>Hamburg</city>
74+
<region>Hamburg</region>
75+
<country>1</country>
76+
</tx_contacts_domain_model_address>
77+
<tx_contacts_domain_model_address>
78+
<uid>7</uid>
79+
<pid>0</pid>
80+
<title>Hessischer Landtag</title>
81+
<type>POSTAL</type>
82+
<street>Schlossplatz</street>
83+
<street_number>1–3</street_number>
84+
<zip>65183</zip>
85+
<city>Wiesbaden</city>
86+
<region>Hessen</region>
87+
<country>1</country>
88+
</tx_contacts_domain_model_address>
89+
<tx_contacts_domain_model_address>
90+
<uid>8</uid>
91+
<pid>0</pid>
92+
<title>Landtag Mecklenburg-Vorpommern</title>
93+
<type>POSTAL</type>
94+
<street>Lennéstraße</street>
95+
<street_number>1</street_number>
96+
<zip>19053</zip>
97+
<city>Schwerin</city>
98+
<region>Mecklenburg-Vorpommern</region>
99+
<country>1</country>
100+
</tx_contacts_domain_model_address>
101+
<tx_contacts_domain_model_address>
102+
<uid>9</uid>
103+
<pid>0</pid>
104+
<title>Niedersächsischer Landtag</title>
105+
<type>POSTAL</type>
106+
<street>Hannah-Arendt-Platz</street>
107+
<street_number>1</street_number>
108+
<zip>30159</zip>
109+
<city>Hannover</city>
110+
<region>Niedersachsen</region>
111+
<country>1</country>
112+
</tx_contacts_domain_model_address>
113+
<tx_contacts_domain_model_address>
114+
<uid>10</uid>
115+
<pid>0</pid>
116+
<title>Landtag NRW</title>
117+
<type>POSTAL</type>
118+
<street>Platz des Landtags</street>
119+
<street_number>1</street_number>
120+
<zip>40221</zip>
121+
<city>Düsseldorf</city>
122+
<region>Nordrhein-Westfalen</region>
123+
<country>1</country>
124+
</tx_contacts_domain_model_address>
125+
<tx_contacts_domain_model_address>
126+
<uid>11</uid>
127+
<pid>0</pid>
128+
<title>Landtag Rheinland-Pfalz</title>
129+
<type>POSTAL</type>
130+
<street>Platz der Mainzer Republik</street>
131+
<street_number>1</street_number>
132+
<zip>55116</zip>
133+
<city>Mainz</city>
134+
<region>Rheinland-Pfalz</region>
135+
<country>1</country>
136+
</tx_contacts_domain_model_address>
137+
<tx_contacts_domain_model_address>
138+
<uid>12</uid>
139+
<pid>0</pid>
140+
<title>Landtag des Saarlandes</title>
141+
<type>POSTAL</type>
142+
<street>Franz-Josef-Röder Straße</street>
143+
<street_number>7</street_number>
144+
<zip>66119</zip>
145+
<city>Saarbrücken</city>
146+
<region>Saarland</region>
147+
<country>1</country>
148+
</tx_contacts_domain_model_address>
149+
<tx_contacts_domain_model_address>
150+
<uid>13</uid>
151+
<pid>0</pid>
152+
<title>Sächsischer Landtag</title>
153+
<type>POSTAL</type>
154+
<street>Bernhard-von-Lindenau-Platz</street>
155+
<street_number>1</street_number>
156+
<zip>01067</zip>
157+
<city>Dresden</city>
158+
<region>Sachsen</region>
159+
<country>1</country>
160+
</tx_contacts_domain_model_address>
161+
<tx_contacts_domain_model_address>
162+
<uid>14</uid>
163+
<pid>0</pid>
164+
<title>Landtag von Sachsen-Anhalt</title>
165+
<type>POSTAL</type>
166+
<street>Domplatz</street>
167+
<street_number>6-9</street_number>
168+
<zip>39104</zip>
169+
<city>Magdeburg</city>
170+
<region>Sachsen-Anhalt</region>
171+
<country>1</country>
172+
</tx_contacts_domain_model_address>
173+
<tx_contacts_domain_model_address>
174+
<uid>15</uid>
175+
<pid>0</pid>
176+
<title>Schleswig-Holsteinischer Landtag</title>
177+
<type>POSTAL</type>
178+
<street>Düsternbrooker Weg</street>
179+
<street_number>70</street_number>
180+
<zip>24171</zip>
181+
<city>Kiel</city>
182+
<region>Schleswig-Holstein</region>
183+
<country>1</country>
184+
</tx_contacts_domain_model_address>
185+
<tx_contacts_domain_model_address>
186+
<uid>16</uid>
187+
<pid>0</pid>
188+
<title>Thüringer Landtag </title>
189+
<type>POSTAL</type>
190+
<street>Jürgen-Fuchs-Straße</street>
191+
<street_number>1</street_number>
192+
<zip>99096</zip>
193+
<city>Erfurt</city>
194+
<region>Thüringen</region>
195+
<country>1</country>
196+
</tx_contacts_domain_model_address>
197+
</dataset>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<dataset>
3+
<tx_contacts_domain_model_country>
4+
<uid>1</uid>
5+
<pid>0</pid>
6+
<name>Deutschland</name>
7+
<iso2>DE</iso2>
8+
<iso3>DEU</iso3>
9+
<tld>de</tld>
10+
<phone_country_code>+49</phone_country_code>
11+
</tx_contacts_domain_model_country>
12+
</dataset>
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
namespace Extcode\Contacts\Tests\Functional\Repository;
4+
5+
/*
6+
* This file is part of the package extcode/cart.
7+
*
8+
* For the full copyright and license information, please read the
9+
* LICENSE file that was distributed with this source code.
10+
*/
11+
12+
use Extcode\Contacts\Domain\Repository\AddressRepository;
13+
use TYPO3\CMS\Core\Utility\GeneralUtility;
14+
use TYPO3\CMS\Extbase\Object\ObjectManager;
15+
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
16+
17+
/**
18+
* Functional test for the \GeorgRinger\News\Domain\Repository\NewsRepository
19+
*/
20+
class NewsRepositoryTest extends FunctionalTestCase
21+
{
22+
23+
/**
24+
* @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
25+
*/
26+
protected $objectManager;
27+
28+
/**
29+
* @var AddressRepository
30+
*/
31+
protected $addressRepository;
32+
33+
protected $testExtensionsToLoad = [
34+
'typo3conf/ext/contacts'
35+
];
36+
37+
public function setUp(): void
38+
{
39+
parent::setUp();
40+
$this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
41+
$this->addressRepository = $this->objectManager->get(AddressRepository::class);
42+
43+
$this->importDataSet(__DIR__ . '/../Fixtures/tx_contacts_domain_model_country.xml');
44+
$this->importDataSet(__DIR__ . '/../Fixtures/tx_contacts_domain_model_address.xml');
45+
}
46+
47+
public function tearDown(): void
48+
{
49+
unset($this->addressRepository);
50+
unset($this->objectManager);
51+
}
52+
53+
/**
54+
* @test
55+
*/
56+
public function findRecordsByUid(): void
57+
{
58+
$address = $this->addressRepository->findByUid(1);
59+
60+
$this->assertSame(
61+
'Landtag von Baden-Württemberg',
62+
$address->getTitle()
63+
);
64+
}
65+
66+
/**
67+
* @test
68+
*/
69+
public function findAllRecords(): void
70+
{
71+
$addresses = $this->addressRepository->findAll();
72+
73+
$this->assertSame(
74+
16,
75+
$addresses->count()
76+
);
77+
}
78+
}

0 commit comments

Comments
 (0)