Skip to content

Commit 409c4f8

Browse files
committed
style: Use $this for static PHPUnit method calls
See recommencation here: sebastianbergmann/phpunit#2104 (comment) Also see the related changes in PHP CS Fixer: PHP-CS-Fixer/PHP-CS-Fixer#9328 PHP-CS-Fixer/PHP-CS-Fixer#9341
1 parent fc602bd commit 409c4f8

25 files changed

+169
-169
lines changed

Tests/Functional/Controller/EidControllerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ public function testEidControllerRedirectsToExistingUrl(): void
2424
$this->getTinyUrlGenerator()->generateTinyUrl($tinyUrl);
2525

2626
$tinyUrl = $this->getTinyUrlRepository()->findTinyUrlByTargetUrl($targetUrl);
27-
self::assertSame(0, $tinyUrl->getPid());
27+
$this->assertSame(0, $tinyUrl->getPid());
2828

2929
$request = (new InternalRequest())->withQueryParameter('eID', 'tx_tinyurls')
3030
->withQueryParameter('tx_tinyurls[key]', 'b-1234567');
3131

3232
$response = $this->executeFrontendSubRequest($request);
3333

34-
self::assertSame(301, $response->getStatusCode());
35-
self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
34+
$this->assertSame(301, $response->getStatusCode());
35+
$this->assertSame('https://www.example.com', $response->getHeaderLine('Location'));
3636
}
3737

3838
public function testEidControllerUsesSiteConfiguration(): void
@@ -51,16 +51,16 @@ public function testEidControllerUsesSiteConfiguration(): void
5151
$tinyUrl = $this->getTinyUrlRepository()->findTinyUrlByTargetUrl($targetUrl);
5252
$this->getExtensionConfiguration()->reset();
5353

54-
self::assertSame(1, $tinyUrl->getPid());
54+
$this->assertSame(1, $tinyUrl->getPid());
5555

5656
$request = (new InternalRequest())
5757
->withQueryParameter('eID', 'tx_tinyurls')
5858
->withQueryParameter('tx_tinyurls[key]', 'b-1234567');
5959

6060
$response = $this->executeFrontendSubRequest($request);
6161

62-
self::assertSame(301, $response->getStatusCode());
63-
self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
62+
$this->assertSame(301, $response->getStatusCode());
63+
$this->assertSame('https://www.example.com', $response->getHeaderLine('Location'));
6464
}
6565

6666
private function getExtensionConfiguration(): ExtensionConfiguration

Tests/Functional/Domain/Repository/TinyUrlRepositoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ public function testCountTinyUrlHitRaisesCounter(): void
2424
$this->importCSVDataSet(__DIR__ . '/../../Fixtures/Database/tinyurl.csv');
2525

2626
$tinyUrl = $this->tinyUrlRepository->findTinyUrlByKey('9499fjf');
27-
self::assertSame(0, $tinyUrl->getCounter());
27+
$this->assertSame(0, $tinyUrl->getCounter());
2828

2929
$tinyUrl = $this->tinyUrlRepository->countTinyUrlHit($tinyUrl);
3030
$tinyUrl = $this->tinyUrlRepository->countTinyUrlHit($tinyUrl);
3131

32-
self::assertSame(2, $tinyUrl->getCounter());
32+
$this->assertSame(2, $tinyUrl->getCounter());
3333
}
3434
}

Tests/Functional/TinyUrl/ApiTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@ public function testApiDoesNotSetDeleteOnUseByDefault(): void
3939
{
4040
$this->tinyUrlsApi->getTinyUrl('http://mydomain.tld');
4141
$tinyUrlRow = $this->getTinyUrlRow();
42-
self::assertEmpty($tinyUrlRow['delete_on_use']);
42+
$this->assertEmpty($tinyUrlRow['delete_on_use']);
4343
}
4444

4545
public function testApiDoesNotSetValidationDateByDefault(): void
4646
{
4747
$this->tinyUrlsApi->getTinyUrl('http://mydomain.tld');
4848
$tinyUrlRow = $this->getTinyUrlRow();
49-
self::assertEmpty($tinyUrlRow['valid_until']);
49+
$this->assertEmpty($tinyUrlRow['valid_until']);
5050
}
5151

5252
public function testApiRespectsCustomUrlKey(): void
5353
{
5454
$this->tinyUrlsApi->setUrlKey('mydomain');
5555
$tinyUrl = $this->tinyUrlsApi->getTinyUrl('http://mydomain.tld');
56-
self::assertMatchesRegularExpression(
56+
$this->assertMatchesRegularExpression(
5757
'/http:\\/\\/.+\\/\\?eID=tx_tinyurls&tx_tinyurls\\[key\\]=mydomain/',
5858
$tinyUrl,
5959
);
@@ -64,7 +64,7 @@ public function testApiSetsComment(): void
6464
$this->tinyUrlsApi->setComment('My test comment');
6565
$this->tinyUrlsApi->getTinyUrl('http://mydomain.tld');
6666
$tinyUrlRow = $this->getTinyUrlRow();
67-
self::assertSame('My test comment', $tinyUrlRow['comment']);
67+
$this->assertSame('My test comment', $tinyUrlRow['comment']);
6868
}
6969

7070
public function testApiSetsDeleteOnUseIfConfiguredInTypoScript(): void
@@ -76,15 +76,15 @@ public function testApiSetsDeleteOnUseIfConfiguredInTypoScript(): void
7676
$this->tinyUrlsApi->initializeConfigFromTyposcript($typoScript, $contentObject);
7777
$this->tinyUrlsApi->getTinyUrl('http://mydomain.tld');
7878
$tinyUrlRow = $this->getTinyUrlRow();
79-
self::assertNotEmpty($tinyUrlRow['delete_on_use']);
79+
$this->assertNotEmpty($tinyUrlRow['delete_on_use']);
8080
}
8181

8282
public function testApiSetsDeleteOnUseIfRequested(): void
8383
{
8484
$this->tinyUrlsApi->setDeleteOnUse(true);
8585
$this->tinyUrlsApi->getTinyUrl('http://mydomain.tld');
8686
$tinyUrlRow = $this->getTinyUrlRow();
87-
self::assertNotEmpty($tinyUrlRow['delete_on_use']);
87+
$this->assertNotEmpty($tinyUrlRow['delete_on_use']);
8888
}
8989

9090
public function testApiSetsValidationDateIfRequested(): void
@@ -93,7 +93,7 @@ public function testApiSetsValidationDateIfRequested(): void
9393
$this->tinyUrlsApi->setValidUntil($validUntilTimestamp);
9494
$this->tinyUrlsApi->getTinyUrl('http://mydomain.tld');
9595
$tinyUrlRow = $this->getTinyUrlRow();
96-
self::assertSame($validUntilTimestamp, (int)$tinyUrlRow['valid_until']);
96+
$this->assertSame($validUntilTimestamp, (int)$tinyUrlRow['valid_until']);
9797
}
9898

9999
public function testApiSetsValidUntilIfConfiguredInTypoScript(): void
@@ -106,6 +106,6 @@ public function testApiSetsValidUntilIfConfiguredInTypoScript(): void
106106
$this->tinyUrlsApi->initializeConfigFromTyposcript($typoScript, $contentObject);
107107
$this->tinyUrlsApi->getTinyUrl('http://mydomain.tld');
108108
$tinyUrlRow = $this->getTinyUrlRow();
109-
self::assertSame($validUntilTimestamp, (int)$tinyUrlRow['valid_until']);
109+
$this->assertSame($validUntilTimestamp, (int)$tinyUrlRow['valid_until']);
110110
}
111111
}

Tests/Functional/TinyUrl/TinyUrlGeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ public function testGetTinyUrlSetsTstampOfNewTinyUrl(): void
4040
{
4141
$this->tinyUrlGenerator->generateTinyUrl(TinyUrl::createForUrl('http://mydomain.tld'));
4242
$tinyUrlRow = $this->getTinyUrlRow();
43-
self::assertGreaterThanOrEqual($GLOBALS['EXEC_TIME'], $tinyUrlRow['tstamp']);
43+
$this->assertGreaterThanOrEqual($GLOBALS['EXEC_TIME'], $tinyUrlRow['tstamp']);
4444
}
4545
}

Tests/Functional/TypoScriptTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testTypolinkIsConvertedToTinyurlIfConfigured(): void
4444
$request = (new InternalRequest())->withPageId(1);
4545
$response = $this->executeFrontendSubRequest($request);
4646
$urlPrefix = 'https://my-custom-base.tld/?eID=tx_tinyurls&tx_tinyurls[key]=b-';
47-
self::assertMatchesRegularExpression(
47+
$this->assertMatchesRegularExpression(
4848
'/' . preg_quote($urlPrefix, '/') . '[a-zA-Z0-9]{7}/',
4949
(string)$response->getBody(),
5050
);

Tests/Functional/Utils/UrlUtilsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ public function testCreateSpeakingTinyUrlReplacesGeneralUtilityMarkers(): void
2929
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
3030
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['tinyurls'][ConfigKeys::SPEAKING_URL_TEMPLATE] = '###REMOTE_ADDR###';
3131
$urlUtils = GeneralUtility::makeInstance(UrlUtils::class);
32-
self::assertSame('127.0.0.1', $urlUtils->createSpeakingTinyUrl('test'));
32+
$this->assertSame('127.0.0.1', $urlUtils->createSpeakingTinyUrl('test'));
3333
}
3434
}

Tests/Functional/ViewHelpers/TinyurlViewHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testTinyurlViewHelperGeneratesUrl(): void
4040
$this->setUpFrontendSite(1);
4141
$request = (new InternalRequest())->withPageId(1);
4242
$response = $this->executeFrontendSubRequest($request);
43-
self::assertMatchesRegularExpression(
43+
$this->assertMatchesRegularExpression(
4444
'/http:\\/\\/localhost\\/\\?eID=tx_tinyurls&tx_tinyurls\\[key\\]=b-[a-zA-Z0-9]{7}/',
4545
(string)$response->getBody(),
4646
);

Tests/Unit/Configuration/ExtensionConfigurationTest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,50 +47,50 @@ protected function setUp(): void
4747
public function testAppendPidQueryAppendsAndStatementForNonEmptyQuery(): void
4848
{
4949
$this->initConfig([ConfigKeys::URL_RECORD_STORAGE_PID => 0]);
50-
self::assertSame('a=1 AND pid=0', $this->extensionConfiguration->appendPidQuery('a=1'));
50+
$this->assertSame('a=1 AND pid=0', $this->extensionConfiguration->appendPidQuery('a=1'));
5151
}
5252

5353
public function testAppendPidQueryAppendsConfiguredPid(): void
5454
{
5555
$this->initConfig([]);
56-
self::assertSame('pid=0', $this->extensionConfiguration->appendPidQuery(''));
56+
$this->assertSame('pid=0', $this->extensionConfiguration->appendPidQuery(''));
5757
}
5858

5959
public function testAppendPidQueryAppendsDefaultPid(): void
6060
{
6161
$this->initConfig([ConfigKeys::URL_RECORD_STORAGE_PID => 999]);
62-
self::assertSame('pid=999', $this->extensionConfiguration->appendPidQuery(''));
62+
$this->assertSame('pid=999', $this->extensionConfiguration->appendPidQuery(''));
6363
}
6464

6565
public function testAreSpeakingUrlsEnabledReturnsFalseByDefault(): void
6666
{
6767
$this->initConfig([]);
68-
self::assertFalse($this->extensionConfiguration->areSpeakingUrlsEnabled());
68+
$this->assertFalse($this->extensionConfiguration->areSpeakingUrlsEnabled());
6969
}
7070

7171
public function testAreSpeakingUrlsEnabledReturnsFalseIfConfigured(): void
7272
{
7373
$this->initConfig([ConfigKeys::CREATE_SPEAKING_URLS => 0]);
74-
self::assertFalse($this->extensionConfiguration->areSpeakingUrlsEnabled());
74+
$this->assertFalse($this->extensionConfiguration->areSpeakingUrlsEnabled());
7575
}
7676

7777
public function testAreSpeakingUrlsEnabledReturnsTrueIfConfigured(): void
7878
{
7979
$this->initConfig([ConfigKeys::CREATE_SPEAKING_URLS => 1]);
80-
self::assertTrue($this->extensionConfiguration->areSpeakingUrlsEnabled());
80+
$this->assertTrue($this->extensionConfiguration->areSpeakingUrlsEnabled());
8181
}
8282

8383
public function testGetBase62DictionaryReturnsConfiguredValue(): void
8484
{
8585
$this->initConfig([ConfigKeys::BASE62_DICTIONARY => 'asfduew']);
86-
self::assertSame('asfduew', $this->extensionConfiguration->getBase62Dictionary());
86+
$this->assertSame('asfduew', $this->extensionConfiguration->getBase62Dictionary());
8787
}
8888

8989
public function testGetBase62DictionaryReturnsDefault(): void
9090
{
9191
$this->initConfig([]);
9292

93-
self::assertSame(
93+
$this->assertSame(
9494
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
9595
$this->extensionConfiguration->getBase62Dictionary(),
9696
);
@@ -108,52 +108,52 @@ public function testGetBaseUrlResturnsSiteBaseIfConfigured(): void
108108
$this->extensionConfiguration->setSite($siteMock);
109109

110110
// @extensionScannerIgnoreLine
111-
self::assertSame('https://base.url.from.site', (string)$this->extensionConfiguration->getBaseUrl());
111+
$this->assertSame('https://base.url.from.site', (string)$this->extensionConfiguration->getBaseUrl());
112112
}
113113

114114
public function testGetBaseUrlReturnsNullByDefault(): void
115115
{
116116
$this->initConfig([]);
117117

118118
// @extensionScannerIgnoreLine
119-
self::assertNull($this->extensionConfiguration->getBaseUrl());
119+
$this->assertNull($this->extensionConfiguration->getBaseUrl());
120120
}
121121

122122
public function testGetMinimalRandomKeyLengthReturnsConfiguredValue(): void
123123
{
124124
$this->initConfig([ConfigKeys::MINIMAL_RANDOM_KEY_LENGTH => 56]);
125-
self::assertSame(56, $this->extensionConfiguration->getMinimalRandomKeyLength());
125+
$this->assertSame(56, $this->extensionConfiguration->getMinimalRandomKeyLength());
126126
}
127127

128128
public function testGetMinimalRandomKeyLengthReturnsDefault(): void
129129
{
130130
$this->initConfig([]);
131-
self::assertSame(2, $this->extensionConfiguration->getMinimalRandomKeyLength());
131+
$this->assertSame(2, $this->extensionConfiguration->getMinimalRandomKeyLength());
132132
}
133133

134134
public function testGetMinimalTinyurlKeyLengthReturnsConfiguredValue(): void
135135
{
136136
$this->initConfig([ConfigKeys::MINIMAL_TINYURL_KEY_LENGTH => 75]);
137-
self::assertSame(75, $this->extensionConfiguration->getMinimalTinyurlKeyLength());
137+
$this->assertSame(75, $this->extensionConfiguration->getMinimalTinyurlKeyLength());
138138
}
139139

140140
public function testGetMinimalTinyurlKeyLengthReturnsDefault(): void
141141
{
142142
$this->initConfig([]);
143-
self::assertSame(2, $this->extensionConfiguration->getMinimalRandomKeyLength());
143+
$this->assertSame(2, $this->extensionConfiguration->getMinimalRandomKeyLength());
144144
}
145145

146146
public function testGetSpeakingUrlTemplateReturnsConfiguredValue(): void
147147
{
148148
$this->initConfig([ConfigKeys::SPEAKING_URL_TEMPLATE => 'koaidp']);
149-
self::assertSame('koaidp', $this->extensionConfiguration->getSpeakingUrlTemplate());
149+
$this->assertSame('koaidp', $this->extensionConfiguration->getSpeakingUrlTemplate());
150150
}
151151

152152
public function testGetSpeakingUrlTemplateReturnsDefault(): void
153153
{
154154
$this->initConfig([]);
155155

156-
self::assertSame(
156+
$this->assertSame(
157157
'###TYPO3_SITE_URL###tinyurl/###TINY_URL_KEY###',
158158
$this->extensionConfiguration->getSpeakingUrlTemplate(),
159159
);
@@ -167,7 +167,7 @@ public function testSiteConfigurationIsMergedIntoExtensionConfiguration(): void
167167
->willReturn([ConfigKeys::BASE_URL => 'https://base.url.from.site']);
168168

169169
// @extensionScannerIgnoreLine
170-
self::assertSame('https://base.url.from.site', (string)$this->extensionConfiguration->getBaseUrl());
170+
$this->assertSame('https://base.url.from.site', (string)$this->extensionConfiguration->getBaseUrl());
171171
}
172172

173173
private function initConfig(array $array): void

Tests/Unit/Configuration/SiteConfigurationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testLoadSiteConfigurationDoesNotValidateStoragePidIfZero(): void
4242
$this->siteFinderMock->expects($this->never())
4343
->method('getSiteByPageId');
4444

45-
self::assertSame(
45+
$this->assertSame(
4646
[ConfigKeys::URL_RECORD_STORAGE_PID => 0],
4747
$this->siteConfiguration->loadSiteConfiguration($siteMock),
4848
);
@@ -54,7 +54,7 @@ public function testLoadSiteConfigurationReturnsValidStoragePid(): void
5454

5555
$this->initializeSiteFinderMock('site-identifier');
5656

57-
self::assertSame(
57+
$this->assertSame(
5858
[ConfigKeys::URL_RECORD_STORAGE_PID => 123],
5959
$this->siteConfiguration->loadSiteConfiguration($siteMock),
6060
);

Tests/Unit/Configuration/TypoScriptConfiguratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function testSetsOptionValidUntilWithValueFromConfig(): void
132132
->method('resetValidUntil');
133133
$this->tinyUrlMock->expects($this->once())
134134
->method('setValidUntil')
135-
->with(self::callback(static fn(DateTimeImmutable $dateTime) => $dateTime->getTimestamp() === 2389));
135+
->with($this->callback(static fn(DateTimeImmutable $dateTime) => $dateTime->getTimestamp() === 2389));
136136

137137
$this->initializeConfigFromTyposcript(
138138
['tinyurl.' => ['validUntil' => 2389]],

0 commit comments

Comments
 (0)