Skip to content

Commit

Permalink
allow php 8 and support phpunit 9
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Oct 8, 2020
1 parent 9847773 commit 862bc6d
Show file tree
Hide file tree
Showing 72 changed files with 319 additions and 265 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
}
],
"require": {
"php": "^5.6|^7.0",
"php": "^7.1 || ^8.0",
"phpcr/phpcr-implementation": "2.1.*",
"phpunit/phpunit": "^5.7 || ^6.4 || ^7.0"
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 3 additions & 2 deletions inc/AbstractLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,11 @@ public function doesSessionLastModified()
*/
public function getTestSupported($chapter, $case, $name)
{
return !(in_array($chapter, $this->unsupportedChapters)
return !(
in_array($chapter, $this->unsupportedChapters)
|| in_array($case, $this->unsupportedCases)
|| in_array($name, $this->unsupportedTests)
);
);
}

/**
Expand Down
11 changes: 6 additions & 5 deletions inc/BaseCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ abstract class BaseCase extends TestCase
*
* @see initProperties()
*/
public static function setupBeforeClass($fixtures = 'general/base')
public static function setupBeforeClass($fixtures = 'general/base'): void
{
self::$loader = ImplementationLoader::getInstance();

Expand All @@ -120,7 +120,7 @@ public static function setupBeforeClass($fixtures = 'general/base')
self::$staticSharedFixture['additionalSession'] = self::$loader->getAdditionalSession();
}

protected function setUp()
protected function setUp(): void
{
$fqn = get_called_class();
$parts = explode('\\', $fqn);
Expand All @@ -144,7 +144,7 @@ protected function setUp()
$this->initProperties();
}

public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
if (isset(self::$staticSharedFixture['session'])) {
self::$staticSharedFixture['session']->logout();
Expand Down Expand Up @@ -278,7 +278,8 @@ protected function assertSimilarDateTime($expected, $data)
{
$this->assertInstanceOf(DateTime::class, $expected);
$this->assertInstanceOf(DateTime::class, $data);
$this->assertTrue(abs($expected->getTimestamp() - $data->getTimestamp()) <= 3,
$this->assertTrue(
abs($expected->getTimestamp() - $data->getTimestamp()) <= 3,
$data->format('c').' is not close to the expected '.$expected->format('c')
);
}
Expand All @@ -290,7 +291,7 @@ protected function assertSimilarDateTime($expected, $data)
*
* @return bool True if the test can be done. Otherwise the test is skipped.
*/
protected function skipIfNotSupported($descriptor)
protected function skipIfNotSupported($descriptor): bool
{
if (false === $this->session->getRepository()->getDescriptor($descriptor)) {
$this->markTestSkipped('Descriptor "'.$descriptor.'" not supported');
Expand Down
4 changes: 2 additions & 2 deletions tests/Connecting/RepositoryDescriptorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class RepositoryDescriptorsTest extends BaseCase
{
public static function setupBeforeClass($fixtures = false)
public static function setupBeforeClass($fixtures = false): void
{
// Don't care about fixtures
parent::setupBeforeClass($fixtures);
Expand All @@ -41,7 +41,7 @@ public function testDescriptorKeys()
{
$rep = self::$loader->getRepository();
$keys = $rep->getDescriptorKeys();
$this->assertInternalType('array', $keys);
$this->assertIsArray($keys);
$this->assertNotEmpty($keys);
foreach ($this->expectedDescriptors as $descriptor) {
$this->assertContains($descriptor, $keys);
Expand Down
2 changes: 1 addition & 1 deletion tests/Connecting/RepositoryFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class RepositoryFactoryTest extends BaseCase
{
public static function setupBeforeClass($fixtures = false)
public static function setupBeforeClass($fixtures = false): void
{
// Don't care about fixtures
parent::setupBeforeClass($fixtures);
Expand Down
2 changes: 1 addition & 1 deletion tests/Connecting/RepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

class RepositoryTest extends BaseCase
{
public static function setupBeforeClass($fixtures = null)
public static function setupBeforeClass($fixtures = null): void
{
// Don't care about fixtures
parent::setupBeforeClass($fixtures);
Expand Down
2 changes: 1 addition & 1 deletion tests/Connecting/SessionReadMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testGetAttributeNames()
$cr->setAttribute('foo', 'bar');
$session = $this->assertSession($cr);
$attrs = $session->getAttributeNames();
$this->assertInternalType('array', $attrs);
$this->assertIsArray($attrs);
$this->assertContains('foo', $attrs);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Connecting/SimpleCredentialsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class SimpleCredentialsTest extends BaseCase
{
public static function setupBeforeClass($fixtures = false)
public static function setupBeforeClass($fixtures = false): void
{
// Don't care about fixtures
parent::setupBeforeClass($fixtures);
Expand Down Expand Up @@ -67,7 +67,7 @@ public function testAttributes()
$cr->setAttribute($attrName, $attrValue);
$this->assertEquals($attrValue, $cr->getAttribute($attrName));
$attrs = $cr->getAttributeNames();
$this->assertInternalType('array', $attrs);
$this->assertIsArray($attrs);
$this->assertContains($attrName, $attrs);
$cr->removeAttribute($attrName);
$this->assertNull($cr->getAttribute($attrName));
Expand Down
4 changes: 2 additions & 2 deletions tests/Connecting/WorkspaceReadMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class WorkspaceReadMethodsTest extends BaseCase

//4.5 Workspace Read Methods

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -98,7 +98,7 @@ public function testGetAccessibleWorkspaceNames()
{
$names = $this->workspace->getAccessibleWorkspaceNames();

$this->assertInternalType('array', $names);
$this->assertIsArray($names);
$this->assertContains(self::$loader->getWorkspaceName(), $names);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Export/ExportRepositoryContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//7 Export Repository Content
class ExportRepositoryContentTest extends BaseCase
{
public static function setupBeforeClass($fixtures = '07_Export/systemview')
public static function setupBeforeClass($fixtures = '07_Export/systemview'): void
{
parent::setupBeforeClass($fixtures);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Import/ImportRepositoryContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//6.5 Import Repository Content
class ImportRepositoryContentTest extends BaseCase
{
public static function setupBeforeClass($fixtures = null)
public static function setupBeforeClass($fixtures = null): void
{
parent::setupBeforeClass($fixtures);
}
Expand Down
5 changes: 2 additions & 3 deletions tests/Locking/LockManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class LockManagerTest extends BaseCase
/** @var LockManagerInterface */
private $lm;

public function setUp()
public function setUp(): void
{
parent::setUp();
$this->lm = $this->session->getWorkspace()->getLockManager();
Expand All @@ -42,11 +42,10 @@ public function setUp()

/**
* Try to lock a non-lockable node.
*
* @expectedException \PHPCR\Lock\LockException
*/
public function testCannotLockNonLockableNodes()
{
$this->expectException(LockException::class);
$this->recreateTestNode('non-lockable', false);
$this->lm->lock('/non-lockable', true, true, 3, '');
}
Expand Down
16 changes: 8 additions & 8 deletions tests/NodeTypeDiscovery/NodeDefinitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class NodeDefinitionTest extends BaseCase
*/
private $hierarchyNodeDef;

public static function setupBeforeClass($fixtures = false)
public static function setupBeforeClass($fixtures = false): void
{
parent::setupBeforeClass($fixtures);
/** @var NodeTypeManagerInterface $ntm */
Expand All @@ -66,20 +66,20 @@ public static function setupBeforeClass($fixtures = false)
self::$hierarchyNodeType = $ntm->getNodeType('nt:hierarchyNode');
}

public function setUp()
public function setUp(): void
{
parent::setUp();

try {
$defs = self::$file->getChildNodeDefinitions();
$this->assertInternalType('array', $defs);
$this->assertIsArray($defs);
$this->assertCount(1, $defs);
$this->content = current($defs);
$this->assertInstanceOf(NodeDefinitionInterface::class, $this->content);
$this->assertEquals('jcr:content', $this->content->getName());

$defs = self::$folder->getChildNodeDefinitions();
$this->assertInternalType('array', $defs);
$this->assertIsArray($defs);
$this->assertCount(1, $defs);
$this->hierarchyNodeDef = next($defs);
$this->assertInstanceOf(NodeDefinitionInterface::class, $this->hierarchyNodeDef);
Expand Down Expand Up @@ -107,24 +107,24 @@ public function testDefaultPrimaryTypeName()
public function getRequiredPrimaryTypeNames()
{
$names = $this->content->getRequiredPrimaryTypeNames();
$this->assertInternalType('array', $names);
$this->assertIsArray($names);
$this->assertCount(1, $names);
$this->assertEquals('nt:base', $names[0]);

$names = $this->hierarchyNodeDef->getRequiredPrimaryTypeNames();
$this->assertInternalType('array', $names);
$this->assertIsArray($names);
$this->assertCount(1, $names);
$this->assertEquals('nt:hierarchyNode', $names[0]);
}
public function getRequiredPrimaryTypes()
{
$types = $this->content->getRequiredPrimaryTypeNames();
$this->assertInternalType('array', $types);
$this->assertIsArray($types);
$this->assertCount(1, $types);
$this->assertEquals(self::$base, $types[0]);

$types = $this->hierarchyNodeDef->getRequiredPrimaryTypeNames();
$this->assertInternalType('array', $types);
$this->assertIsArray($types);
$this->assertCount(1, $types);
$this->assertEquals(self::$hierarchyNodeType, $types[0]);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/NodeTypeDiscovery/NodeNodeTypeReadMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class NodeNodeTypeReadMethodsTest extends BaseCase
*/
protected $deepnode;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/NodeTypeDiscovery/NodeTypeDiscoveryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class NodeTypeDiscoveryTest extends BaseCase
'mix:title',
];

public function setUp()
public function setUp(): void
{
parent::setUp(false);

Expand Down
16 changes: 8 additions & 8 deletions tests/NodeTypeDiscovery/NodeTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class NodeTypeTest extends BaseCase
*/
private static $created;

public static function setupBeforeClass($fixtures = false)
public static function setupBeforeClass($fixtures = false): void
{
parent::setupBeforeClass($fixtures);
$ntm = self::$staticSharedFixture['session']->getWorkspace()->getNodeTypeManager();
Expand All @@ -64,7 +64,7 @@ public static function setupBeforeClass($fixtures = false)
public function testGetSupertypes()
{
$types = self::$file->getSupertypes();
$this->assertInternalType('array', $types);
$this->assertIsArray($types);
$typenames = [];

foreach ($types as $type) {
Expand All @@ -77,14 +77,14 @@ public function testGetSupertypes()
public function testGetSupertypesNone()
{
$types = self::$base->getSupertypes();
$this->assertInternalType('array', $types);
$this->assertIsArray($types);
$this->assertCount(0, $types);
}

public function testGetDeclaredSupertypes()
{
$types = self::$file->getDeclaredSupertypes();
$this->assertInternalType('array', $types);
$this->assertIsArray($types);
$typenames = [];

foreach ($types as $type) {
Expand All @@ -96,7 +96,7 @@ public function testGetDeclaredSupertypes()
$this->assertNotContains('nt:base', $typenames);

$types = self::$resource->getDeclaredSupertypes();
$this->assertInternalType('array', $types);
$this->assertIsArray($types);
$typenames = [];

foreach ($types as $type) {
Expand All @@ -112,7 +112,7 @@ public function testGetDeclaredSupertypes()
public function testGetDeclaredSupertypesNone()
{
$types = self::$base->getDeclaredSupertypes();
$this->assertInternalType('array', $types);
$this->assertIsArray($types);
$this->assertCount(0, $types);
}

Expand Down Expand Up @@ -155,7 +155,7 @@ public function testGetDeclaredSubtypes()
public function testGetChildNodeDefinitions()
{
$children = self::$file->getChildNodeDefinitions();
$this->assertInternalType('array', $children);
$this->assertIsArray($children);
$this->assertCount(1, $children);
$child = current($children);
$this->assertInstanceOf(NodeDefinitionInterface::class, $child);
Expand All @@ -166,7 +166,7 @@ public function testGetChildNodeDefinitions()
public function testGetPropertyDefinitions()
{
$properties = self::$file->getPropertyDefinitions();
$this->assertInternalType('array', $properties);
$this->assertIsArray($properties);
$this->assertCount(4, $properties);
$names = [];

Expand Down
Loading

0 comments on commit 862bc6d

Please sign in to comment.