Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!!! FEATURE: Raise phpunit to v8.1 #1565

Merged
merged 8 commits into from May 13, 2019
Merged
4 changes: 2 additions & 2 deletions Neos.Cache/Tests/Functional/Backend/RedisBackendTest.php
Expand Up @@ -46,7 +46,7 @@ class RedisBackendTest extends BaseTestCase
*
* @return void
*/
public function setUp()
protected function setUp(): void
{
$phpredisVersion = phpversion('redis');
if (version_compare($phpredisVersion, '1.2.0', '<')) {
Expand All @@ -73,7 +73,7 @@ public function setUp()
*
* @return void
*/
public function tearDown()
protected function tearDown(): void
{
if ($this->backend instanceof RedisBackend) {
$this->backend->flush();
Expand Down
2 changes: 1 addition & 1 deletion Neos.Cache/Tests/Unit/Backend/AbstractBackendTest.php
Expand Up @@ -31,7 +31,7 @@ class AbstractBackendTest extends BaseTestCase
/**
* @return void
*/
public function setUp()
protected function setUp(): void
{
class_exists(AbstractBackend::class);
$className = 'ConcreteBackend_' . md5(uniqid(mt_rand(), true));
Expand Down
5 changes: 3 additions & 2 deletions Neos.Cache/Tests/Unit/Backend/ApcuBackendTest.php
Expand Up @@ -15,6 +15,7 @@

use Neos\Cache\Backend\ApcuBackend;
use Neos\Cache\EnvironmentConfiguration;
use Neos\Cache\Exception;
use Neos\Cache\Tests\BaseTestCase;
use Neos\Cache\Frontend\FrontendInterface;
use Neos\Cache\Frontend\VariableFrontend;
Expand All @@ -31,7 +32,7 @@ class ApcuBackendTest extends BaseTestCase
*
* @return void
*/
public function setUp()
protected function setUp(): void
{
if (ini_get('apc.enabled') == 0 || ini_get('apc.enable_cli') == 0) {
$this->markTestSkipped('APCu is disabled (for CLI).');
Expand All @@ -43,10 +44,10 @@ public function setUp()

/**
* @test
* @expectedException \Neos\Cache\Exception
*/
public function setThrowsExceptionIfNoFrontEndHasBeenSet()
{
$this->expectException(Exception::class);
$backend = new ApcuBackend($this->getEnvironmentConfiguration(), []);
$data = 'Some data';
$identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), true));
Expand Down
29 changes: 16 additions & 13 deletions Neos.Cache/Tests/Unit/Backend/FileBackendTest.php
Expand Up @@ -15,11 +15,14 @@

use Neos\Cache\Backend\FileBackend;
use Neos\Cache\EnvironmentConfiguration;
use Neos\Cache\Exception;
use Neos\Cache\Tests\BaseTestCase;
use org\bovigo\vfs\vfsStream;
use Neos\Cache\Frontend\AbstractFrontend;
use Neos\Cache\Frontend\PhpFrontend;
use Neos\Cache\Frontend\VariableFrontend;
use PHPUnit\Framework\Error\Notice;
use PHPUnit\Framework\Error\Warning;

/**
* Test case for the cache to file backend
Expand All @@ -28,17 +31,17 @@ class FileBackendTest extends BaseTestCase
{
/**
*/
public function setUp()
protected function setUp(): void
{
vfsStream::setup('Foo');
}

/**
* @test
* @expectedException \Neos\Cache\Exception
*/
public function setCacheThrowsExceptionOnNonWritableDirectory()
{
$this->expectException(Exception::class);
$mockCache = $this->createMock(AbstractFrontend::class);

$mockEnvironmentConfiguration = $this->createEnvironmentConfigurationMock([__DIR__ . '~Testing', 'http://localhost/', PHP_MAXPATHLEN]);
Expand Down Expand Up @@ -183,11 +186,11 @@ public function setAlsoSavesSpecifiedTags()

/**
* @test
* @expectedException \Neos\Cache\Exception
* @expectedExceptionCode 1248710426
*/
public function setThrowsExceptionIfCachePathLengthExceedsMaximumPathLength()
{
$this->expectExceptionCode(1248710426);
$this->expectException(Exception::class);
$cachePath = 'vfs://Foo';

$mockEnvironmentConfiguration = $this->createEnvironmentConfigurationMock([
Expand Down Expand Up @@ -427,10 +430,10 @@ public function invalidEntryIdentifiers()
/**
* @test
* @dataProvider invalidEntryIdentifiers
* @expectedException \InvalidArgumentException
*/
public function setThrowsExceptionForInvalidIdentifier($identifier)
{
$this->expectException(\InvalidArgumentException::class);
$mockCache = $this->createMock(AbstractFrontend::class);
$mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));
$backend = $this->prepareDefaultBackend();
Expand All @@ -442,10 +445,10 @@ public function setThrowsExceptionForInvalidIdentifier($identifier)
/**
* @test
* @dataProvider invalidEntryIdentifiers
* @expectedException \InvalidArgumentException
*/
public function getThrowsExceptionForInvalidIdentifier($identifier)
{
$this->expectException(\InvalidArgumentException::class);
$mockCache = $this->createMock(AbstractFrontend::class);
$mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));

Expand All @@ -458,10 +461,10 @@ public function getThrowsExceptionForInvalidIdentifier($identifier)
/**
* @test
* @dataProvider invalidEntryIdentifiers
* @expectedException \InvalidArgumentException
*/
public function hasThrowsExceptionForInvalidIdentifier($identifier)
{
$this->expectException(\InvalidArgumentException::class);
$backend = $this->prepareDefaultBackend(['dummy']);

$backend->has($identifier);
Expand All @@ -470,10 +473,10 @@ public function hasThrowsExceptionForInvalidIdentifier($identifier)
/**
* @test
* @dataProvider invalidEntryIdentifiers
* @expectedException \InvalidArgumentException
*/
public function removeThrowsExceptionForInvalidIdentifier($identifier)
{
$this->expectException(\InvalidArgumentException::class);
$mockCache = $this->createMock(AbstractFrontend::class);
$mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));

Expand All @@ -486,10 +489,10 @@ public function removeThrowsExceptionForInvalidIdentifier($identifier)
/**
* @test
* @dataProvider invalidEntryIdentifiers
* @expectedException \InvalidArgumentException
*/
public function requireOnceThrowsExceptionForInvalidIdentifier($identifier)
{
$this->expectException(\InvalidArgumentException::class);
$mockCache = $this->createMock(AbstractFrontend::class);
$mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));

Expand Down Expand Up @@ -543,10 +546,10 @@ public function requireOnceDoesNotCheckExpiryTimeIfBackendIsFrozen()

/**
* @test
* @expectedException \Exception
*/
public function requireOnceDoesNotSwallowExceptionsOfTheIncludedFile()
{
$this->expectException(\Exception::class);
$mockCache = $this->createMock(AbstractFrontend::class);
$mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));

Expand All @@ -560,10 +563,10 @@ public function requireOnceDoesNotSwallowExceptionsOfTheIncludedFile()

/**
* @test
* @expectedException \PHPUnit\Framework\Error\Warning
*/
public function requireOnceDoesNotSwallowPhpWarningsOfTheIncludedFile()
{
$this->expectException(Warning::class);
$mockCache = $this->createMock(AbstractFrontend::class);
$mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));

Expand All @@ -577,10 +580,10 @@ public function requireOnceDoesNotSwallowPhpWarningsOfTheIncludedFile()

/**
* @test
* @expectedException \PHPUnit\Framework\Error\Notice
*/
public function requireOnceDoesNotSwallowPhpNoticesOfTheIncludedFile()
{
$this->expectException(Notice::class);
$mockCache = $this->createMock(AbstractFrontend::class);
$mockCache->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('UnitTestCache'));

Expand Down Expand Up @@ -611,7 +614,7 @@ public function findIdentifiersByTagFindsCacheEntriesWithSpecifiedTag()
$expectedEntry = 'BackendFileTest2';

$actualEntries = $backend->findIdentifiersByTag('UnitTestTag%special');
$this->assertInternalType('array', $actualEntries);
$this->assertIsArray($actualEntries);

$this->assertEquals($expectedEntry, array_pop($actualEntries));
}
Expand Down
9 changes: 5 additions & 4 deletions Neos.Cache/Tests/Unit/Backend/MemcachedBackendTest.php
Expand Up @@ -15,6 +15,7 @@

use Neos\Cache\Backend\MemcachedBackend;
use Neos\Cache\EnvironmentConfiguration;
use Neos\Cache\Exception;
use Neos\Cache\Tests\BaseTestCase;
use Neos\Cache\Frontend\AbstractFrontend;
use Neos\Cache\Frontend\FrontendInterface;
Expand All @@ -31,7 +32,7 @@ class MemcachedBackendTest extends BaseTestCase
*
* @return void
*/
public function setUp()
protected function setUp(): void
{
try {
if (!@fsockopen('localhost', 11211)) {
Expand All @@ -44,10 +45,10 @@ public function setUp()

/**
* @test
* @expectedException \Neos\Cache\Exception
*/
public function setThrowsExceptionIfNoFrontEndHasBeenSet()
{
$this->expectException(Exception::class);
$backendOptions = ['servers' => ['localhost:11211']];
$backend = new MemcachedBackend($this->getEnvironmentConfiguration(), $backendOptions);
$data = 'Some data';
Expand All @@ -57,19 +58,19 @@ public function setThrowsExceptionIfNoFrontEndHasBeenSet()

/**
* @test
* @expectedException \Neos\Cache\Exception
*/
public function initializeObjectThrowsExceptionIfNoMemcacheServerIsConfigured()
{
$this->expectException(Exception::class);
$backend = new MemcachedBackend($this->getEnvironmentConfiguration(), []);
}

/**
* @test
* @expectedException \Neos\Cache\Exception
*/
public function setThrowsExceptionIfConfiguredServersAreUnreachable()
{
$this->expectException(Exception::class);
$backend = $this->setUpBackend(['servers' => ['localhost:11212']]);
$data = 'Somedata';
$identifier = 'MyIdentifier' . md5(uniqid(mt_rand(), true));
Expand Down
2 changes: 1 addition & 1 deletion Neos.Cache/Tests/Unit/Backend/MultiBackendTest.php
Expand Up @@ -39,10 +39,10 @@ public function noExceptionIsThrownIfBackendFailsToBeCreated()

/**
* @test
* @expectedException \Throwable
*/
public function debugModeWillBubbleExceptions()
{
$this->expectException(\Throwable::class);
$backendOptions = [
'debug' => true,
'backendConfigurations' => [
Expand Down
3 changes: 2 additions & 1 deletion Neos.Cache/Tests/Unit/Backend/PdoBackendTest.php
Expand Up @@ -15,6 +15,7 @@

use Neos\Cache\Backend\PdoBackend;
use Neos\Cache\EnvironmentConfiguration;
use Neos\Cache\Exception;
use Neos\Cache\Frontend\FrontendInterface;
use Neos\Cache\Tests\BaseTestCase;
use PHPUnit\Framework\MockObject\MockObject;
Expand All @@ -38,10 +39,10 @@ class PdoBackendTest extends BaseTestCase

/**
* @test
* @expectedException \Neos\Cache\Exception
*/
public function setThrowsExceptionIfNoFrontEndHasBeenSet()
{
$this->expectException(Exception::class);
$backend = new PdoBackend(new EnvironmentConfiguration('SomeApplication Testing', '/some/path', PHP_MAXPATHLEN));
$data = 'Some data';
$identifier = 'MyIdentifier';
Expand Down
4 changes: 2 additions & 2 deletions Neos.Cache/Tests/Unit/Backend/RedisBackendTest.php
Expand Up @@ -45,7 +45,7 @@ class RedisBackendTest extends BaseTestCase
* Set up test case
* @return void
*/
public function setUp()
protected function setUp(): void
{
$phpredisVersion = phpversion('redis');
if (version_compare($phpredisVersion, '1.2.0', '<')) {
Expand Down Expand Up @@ -194,11 +194,11 @@ public function hasInvokesRedis()
/**
* @test
* @dataProvider writingOperationsProvider
* @expectedException \RuntimeException
* @param string $method
*/
public function writingOperationsThrowAnExceptionIfCacheIsFrozen($method)
{
$this->expectException(\RuntimeException::class);
$this->inject($this->backend, 'frozen', null);
$this->redis->expects($this->once())
->method('exists')
Expand Down