Skip to content

Commit 094ec95

Browse files
Update PHPUnit to 8
1 parent cb30f79 commit 094ec95

19 files changed

+61
-73
lines changed

phpunit.xml.dist

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
colors="true"
55
convertErrorsToExceptions="true"
66
convertNoticesToExceptions="true"
7-
convertWarningsToExceptions="true"
8-
syntaxCheck="true">
7+
convertWarningsToExceptions="true">
98
<testsuites>
109
<testsuite name="unit">
1110
<directory suffix="Test.php">./tests/Unit</directory>
@@ -32,6 +31,6 @@
3231
<env name="KERNEL_DIR" value="./tests/Functional/Fixtures/app" />
3332
<env name="KERNEL_CLASS" value="AppKernel" />
3433
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
35-
<server name="SYMFONY_PHPUNIT_VERSION" value="6.5" />
34+
<server name="SYMFONY_PHPUNIT_VERSION" value="8.5" />
3635
</php>
3736
</phpunit>

tests/Functional/DependencyInjection/ServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testCanBeLoaded()
5858
if ('fos_http_cache.user_context.logout_handler' === $id) {
5959
continue;
6060
}
61-
$this->assertInternalType('object', $container->get($id));
61+
$this->assertIsObject($container->get($id));
6262
}
6363
}
6464
}

tests/Functional/EventListener/CacheControlListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ public function testNotCached()
3434
$client->request('GET', '/noncached');
3535
$response = $client->getResponse();
3636
// using contains because Symfony 3.2 add `private` when the cache is not public
37-
$this->assertContains('no-cache', $response->headers->get('Cache-Control'));
37+
$this->assertStringContainsString('no-cache', $response->headers->get('Cache-Control'));
3838
}
3939
}

tests/Unit/CacheManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CacheManagerTest extends TestCase
2525

2626
protected $proxyClient;
2727

28-
public function setUp()
28+
public function setUp(): void
2929
{
3030
$this->proxyClient = \Mockery::mock(ProxyClient::class);
3131
}

tests/Unit/Command/InvalidatePathCommandTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ class InvalidatePathCommandTest extends TestCase
2222
{
2323
use MockeryPHPUnitIntegration;
2424

25-
/**
26-
* @expectedException \RuntimeException
27-
*/
2825
public function testExecuteMissingParameters()
2926
{
27+
$this->expectException(\RuntimeException::class);
28+
3029
$invalidator = \Mockery::mock(CacheManager::class);
3130

3231
$application = new Application();

tests/Unit/Command/InvalidateRegexCommandTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ class InvalidateRegexCommandTest extends TestCase
2222
{
2323
use MockeryPHPUnitIntegration;
2424

25-
/**
26-
* @expectedException \RuntimeException
27-
*/
2825
public function testExecuteNoParameters()
2926
{
27+
$this->expectException(\RuntimeException::class);
28+
3029
$invalidator = \Mockery::mock(CacheManager::class);
3130

3231
$application = new Application();

tests/Unit/Command/InvalidateTagCommandTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ class InvalidateTagCommandTest extends TestCase
2222
{
2323
use MockeryPHPUnitIntegration;
2424

25-
/**
26-
* @expectedException \RuntimeException
27-
*/
2825
public function testExecuteMissingParameters()
2926
{
27+
$this->expectException(\RuntimeException::class);
28+
3029
$invalidator = \Mockery::mock(CacheManager::class);
3130

3231
$application = new Application();

tests/Unit/Command/RefreshPathCommandTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ class RefreshPathCommandTest extends TestCase
2222
{
2323
use MockeryPHPUnitIntegration;
2424

25-
/**
26-
* @expectedException \RuntimeException
27-
*/
2825
public function testExecuteMissingParameters()
2926
{
27+
$this->expectException(\RuntimeException::class);
28+
3029
$invalidator = \Mockery::mock(CacheManager::class);
3130

3231
$application = new Application();

tests/Unit/Configuration/InvalidateRouteTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,22 @@ class InvalidateRouteTest extends TestCase
2222
{
2323
use MockeryPHPUnitIntegration;
2424

25-
/**
26-
* @expectedException \RuntimeException
27-
* @expectedExceptionMessage InvalidateRoute params must be an array
28-
*/
2925
public function testExecuteInvalidParams()
3026
{
27+
$this->expectException(\RuntimeException::class);
28+
$this->expectExceptionMessage('InvalidateRoute params must be an array');
29+
3130
new InvalidateRoute([
3231
'name' => 'test',
3332
'params' => 'foo',
3433
]);
3534
}
3635

37-
/**
38-
* @expectedException \RuntimeException
39-
* @expectedExceptionMessage InvalidateRoute param id must be string
40-
*/
4136
public function testExecuteNoExpression()
4237
{
38+
$this->expectException(\RuntimeException::class);
39+
$this->expectExceptionMessage('InvalidateRoute param id must be string');
40+
4341
new InvalidateRoute([
4442
'name' => 'test',
4543
'params' => [

tests/Unit/Configuration/TagTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace FOS\HttpCacheBundle\Tests\Unit\Configuration;
1313

1414
use FOS\HttpCacheBundle\Configuration\Tag;
15+
use FOS\HttpCacheBundle\Exception\InvalidTagException;
1516
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
1617
use PHPUnit\Framework\TestCase;
1718

@@ -22,12 +23,11 @@ class TagTest extends TestCase
2223
{
2324
use MockeryPHPUnitIntegration;
2425

25-
/**
26-
* @expectedException \FOS\HttpCacheBundle\Exception\InvalidTagException
27-
* @expectedExceptionMessage is invalid because it contains ,
28-
*/
2926
public function testExecuteInvalidParams()
3027
{
28+
$this->expectException(InvalidTagException::class);
29+
$this->expectExceptionMessage('is invalid because it contains ,');
30+
3131
new Tag([
3232
'tags' => ['foo, bar'],
3333
]);

tests/Unit/DependencyInjection/Compiler/HashGeneratorPassTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use FOS\HttpCacheBundle\DependencyInjection\FOSHttpCacheExtension;
1616
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
1717
use PHPUnit\Framework\TestCase;
18+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1819
use Symfony\Component\DependencyInjection\ContainerBuilder;
1920
use Symfony\Component\DependencyInjection\Definition;
2021
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@@ -33,7 +34,7 @@ class HashGeneratorPassTest extends TestCase
3334
*/
3435
private $userContextListenerPass;
3536

36-
protected function setUp()
37+
protected function setUp(): void
3738
{
3839
$this->extension = new FOSHttpCacheExtension();
3940
$this->userContextListenerPass = new HashGeneratorPass();
@@ -56,12 +57,11 @@ public function testConfigNoContext()
5657
}
5758
}
5859

59-
/**
60-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
61-
* @expectedExceptionMessage No user context providers found
62-
*/
6360
public function testConfigNoProviders()
6461
{
62+
$this->expectException(InvalidConfigurationException::class);
63+
$this->expectExceptionMessage('No user context providers found');
64+
6565
$container = $this->createContainer();
6666
$config = $this->getBaseConfig();
6767
$config['user_context']['enabled'] = true;

tests/Unit/DependencyInjection/Compiler/TagListenerPassTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ class TagListenerPassTest extends TestCase
2222
{
2323
use MockeryPHPUnitIntegration;
2424

25-
/**
26-
* @expectedException \RuntimeException
27-
* @expectedExceptionMessage require the SensioFrameworkExtraBundle
28-
*/
2925
public function testNoFrameworkBundle()
3026
{
27+
$this->expectException(\RuntimeException::class);
28+
$this->expectExceptionMessage('require the SensioFrameworkExtraBundle');
29+
3130
$extension = new FOSHttpCacheExtension();
3231
$tagListenerPass = new TagListenerPass();
3332
$container = $this->createContainer();

tests/Unit/DependencyInjection/ConfigurationTest.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,11 @@ public function testSupportsSymfony()
298298
}
299299
}
300300

301-
/**
302-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
303-
* @expectedExceptionMessage Either configure the "http.servers" section or enable "proxy_client.symfony.use_kernel_dispatcher
304-
*/
305301
public function testEmptyServerConfigurationIsNotAllowed()
306302
{
303+
$this->expectException(InvalidConfigurationException::class);
304+
$this->expectExceptionMessage('Either configure the "http.servers" section or enable "proxy_client.symfony.use_kernel_dispatcher');
305+
307306
$params = $this->getEmptyConfig();
308307
$params['proxy_client'] = [
309308
'symfony' => [
@@ -457,7 +456,7 @@ public function testCacheManagerNoClient()
457456
$this->assertProcessedConfigurationEquals([], [$format]);
458457
$this->fail('No exception thrown on invalid configuration');
459458
} catch (InvalidConfigurationException $e) {
460-
$this->assertContains('need to configure a proxy_client', $e->getMessage());
459+
$this->assertStringContainsString('need to configure a proxy_client', $e->getMessage());
461460
}
462461
}
463462
}
@@ -477,7 +476,7 @@ public function testTagsNoCacheManager()
477476
$this->assertProcessedConfigurationEquals([], [$format]);
478477
$this->fail('No exception thrown on invalid configuration');
479478
} catch (InvalidConfigurationException $e) {
480-
$this->assertContains('cache_manager needed for tag handling', $e->getMessage());
479+
$this->assertStringContainsString('cache_manager needed for tag handling', $e->getMessage());
481480
}
482481
}
483482
}
@@ -599,7 +598,7 @@ public function testInvalidationNoCacheManager()
599598
$this->assertProcessedConfigurationEquals([], [$format]);
600599
$this->fail('No exception thrown on invalid configuration');
601600
} catch (InvalidConfigurationException $e) {
602-
$this->assertContains('cache_manager needed for invalidation handling', $e->getMessage());
601+
$this->assertStringContainsString('cache_manager needed for invalidation handling', $e->getMessage());
603602
}
604603
}
605604
}
@@ -627,7 +626,7 @@ public function testUserContextLogoutHandler(string $configFile, $expected, $cac
627626
$this->assertProcessedConfigurationEquals([], [$configFile]);
628627
$this->fail('No exception thrown on invalid configuration');
629628
} catch (InvalidConfigurationException $e) {
630-
$this->assertContains($exception, $e->getMessage());
629+
$this->assertStringContainsString($exception, $e->getMessage());
631630
}
632631

633632
return;
@@ -667,7 +666,7 @@ public function testInvalidDate()
667666
$this->assertProcessedConfigurationEquals([], [$format]);
668667
$this->fail('No exception thrown on invalid configuration');
669668
} catch (InvalidConfigurationException $e) {
670-
$this->assertContains('Failed to parse time string', $e->getMessage());
669+
$this->assertStringContainsString('Failed to parse time string', $e->getMessage());
671670
}
672671
}
673672
}

tests/Unit/DependencyInjection/FOSHttpCacheExtensionTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class FOSHttpCacheExtensionTest extends TestCase
3434
*/
3535
protected $extension;
3636

37-
protected function setUp()
37+
protected function setUp(): void
3838
{
3939
$this->extension = new FOSHttpCacheExtension();
4040
}
@@ -65,11 +65,10 @@ public function testConfigLoadVarnishCustomClient()
6565
$this->assertEquals('my_guzzle', $def->getArgument(2)->__toString());
6666
}
6767

68-
/**
69-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
70-
*/
7168
public function testConfigLoadVarnishInvalidUrl()
7269
{
70+
$this->expectException(InvalidConfigurationException::class);
71+
7372
$container = $this->createContainer();
7473
$config = $this->getBaseConfig();
7574
$config['proxy_client']['varnish']['http']['base_url'] = 'ftp:not a valid url';
@@ -193,12 +192,11 @@ public function testEmptyConfig()
193192
$this->assertFalse($container->has('fos_http_cache.user_context.logout_handler'));
194193
}
195194

196-
/**
197-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
198-
* @expectedExceptionMessage You can not enable cache tagging with the nginx client
199-
*/
200195
public function testConfigTagNotSupported()
201196
{
197+
$this->expectException(InvalidConfigurationException::class);
198+
$this->expectExceptionMessage('You can not enable cache tagging with the nginx client');
199+
202200
$config = [
203201
'proxy_client' => [
204202
'nginx' => [

tests/Unit/EventListener/CacheControlListenerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public function testSetOnlyNoCacheHeader()
270270
$listener->onKernelResponse($event);
271271
$newHeaders = $event->getResponse()->headers->all();
272272

273-
$this->assertContains('no-cache', $newHeaders['cache-control'][0]);
273+
$this->assertStringContainsString('no-cache', $newHeaders['cache-control'][0]);
274274
}
275275

276276
public function testSetOnlyNoStoreHeader()
@@ -287,7 +287,7 @@ public function testSetOnlyNoStoreHeader()
287287
$listener->onKernelResponse($event);
288288
$newHeaders = $event->getResponse()->headers->all();
289289

290-
$this->assertContains('no-store', $newHeaders['cache-control'][0]);
290+
$this->assertStringContainsString('no-store', $newHeaders['cache-control'][0]);
291291
}
292292

293293
public function testSkip()
@@ -303,7 +303,7 @@ public function testSkip()
303303
$listener->onKernelResponse($event);
304304
$newHeaders = $event->getResponse()->headers->all();
305305

306-
$this->assertContains('no-cache', $newHeaders['cache-control'][0]);
306+
$this->assertStringContainsString('no-cache', $newHeaders['cache-control'][0]);
307307
}
308308

309309
public function testVary()
@@ -394,7 +394,7 @@ public function testMatchRule()
394394

395395
$listener->onKernelResponse($event2);
396396
$newHeaders = $response2->headers->all();
397-
$this->assertContains('no-cache', $newHeaders['cache-control'][0]);
397+
$this->assertStringContainsString('no-cache', $newHeaders['cache-control'][0]);
398398
}
399399

400400
/**

tests/Unit/EventListener/InvalidationListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class InvalidationListenerTest extends TestCase
6262
*/
6363
private $listener;
6464

65-
public function setUp()
65+
public function setUp(): void
6666
{
6767
$this->cacheManager = \Mockery::mock(CacheManager::class);
6868
$this->urlGenerator = \Mockery::mock(UrlGeneratorInterface::class);

tests/Unit/EventListener/TagListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class TagListenerTest extends TestCase
6161
*/
6262
private $cacheableRule;
6363

64-
public function setUp()
64+
public function setUp(): void
6565
{
6666
$this->cacheManager = \Mockery::mock(
6767
CacheManager::class

0 commit comments

Comments
 (0)