Skip to content

Commit

Permalink
php 8
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Oct 7, 2020
1 parent 2166818 commit e1c0dc8
Show file tree
Hide file tree
Showing 31 changed files with 183 additions and 167 deletions.
2 changes: 2 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ preset: recommended

enabled:
- no_useless_else
disabled:
- align_double_arrow
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
language: php

php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
- nightly

env:
- PACKAGE_VERSION=high
Expand All @@ -15,7 +14,7 @@ sudo: false

matrix:
include:
- php: 5.6
- php: 7.1
env: PACKAGE_VERSION=low
- php: 7.4
env:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

1.5.0
-----

* Support PHP 8
* Drop support for PHP 5.6 and 7.0

1.4.1
-----

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
}
],
"require": {
"php": "^5.6 || ^7.0",
"php": "^7.1 || ^8.0",
"phpcr/phpcr": "~2.1.0",
"symfony/console": "^2.3|^3.0|^4.0|^5.0"
"symfony/console": "^2.3 || ^3.0 || ^4.0 || ^5.0"
},
"require-dev": {
"ramsey/uuid": "^3.5",
"phpunit/phpunit": "^5.7 || ^6.0 || ^7.0"
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
},
"suggest": {
"ramsey/uuid": "A library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID)."
Expand Down
30 changes: 21 additions & 9 deletions tests/PHPCR/Tests/Util/CND/Reader/BufferReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@

class BufferReaderTest extends TestCase
{
public function test__construct()
public function test__construct(): void
{
$buffer = "Some random\nor\r\nstring";
$reader = new BufferReader($buffer);

$this->assertInstanceOf(BufferReader::class, $reader);
$this->assertAttributeEquals(str_replace("\r\n", "\n", $buffer).$reader->getEofMarker(), 'buffer', $reader);
$this->assertAttributeEquals(0, 'startPos', $reader);
$this->assertAttributeEquals(0, 'forwardPos', $reader);
$reflection = new \ReflectionClass($reader);
$bufferProperty = $reflection->getProperty('buffer');
$bufferProperty->setAccessible(true);
$this->assertSame(str_replace("\r\n", "\n", $buffer).$reader->getEofMarker(), $bufferProperty->getValue($reader));
$startPos = $reflection->getProperty('startPos');
$startPos->setAccessible(true);
$this->assertSame(0, $startPos->getValue($reader));
$forwardPos = $reflection->getProperty('forwardPos');
$forwardPos->setAccessible(true);
$this->assertSame(0, $forwardPos->getValue($reader));

$this->assertEquals(1, $reader->getCurrentLine());
$this->assertEquals(1, $reader->getCurrentColumn());
Expand Down Expand Up @@ -90,10 +96,16 @@ public function test__constructEmptyString()
{
$reader = new BufferReader('');

$this->assertInstanceOf(BufferReader::class, $reader);
$this->assertAttributeEquals($reader->getEofMarker(), 'buffer', $reader);
$this->assertAttributeEquals(0, 'startPos', $reader);
$this->assertAttributeEquals(0, 'forwardPos', $reader);
$reflection = new \ReflectionClass($reader);
$buffer = $reflection->getProperty('buffer');
$buffer->setAccessible(true);
$this->assertSame($reader->getEofMarker(), $buffer->getValue($reader));
$startPos = $reflection->getProperty('startPos');
$startPos->setAccessible(true);
$this->assertSame(0, $startPos->getValue($reader));
$forwardPos = $reflection->getProperty('forwardPos');
$forwardPos->setAccessible(true);
$this->assertSame(0, $forwardPos->getValue($reader));

$this->assertEquals(1, $reader->getCurrentLine());
$this->assertEquals(1, $reader->getCurrentColumn());
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPCR/Tests/Util/CND/Reader/FileReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FileReaderTest extends TestCase
*/
private $lines;

public function setUp()
public function setUp(): void
{
$this->filepath = __DIR__.'/../Fixtures/files/TestFile.txt';
$this->reader = new FileReader($this->filepath);
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPCR/Tests/Util/CND/Scanner/GenericScannerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class GenericScannerTest extends TestCase

protected $expectedTokensNoEmptyToken;

public function setUp()
public function setUp(): void
{
$this->expectedTokensNoEmptyToken = [];
foreach ($this->expectedTokens as $token) {
Expand Down
11 changes: 7 additions & 4 deletions tests/PHPCR/Tests/Util/CND/Scanner/TokenQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TokenQueueTest extends TestCase
*/
private $queue;

public function setUp()
public function setUp(): void
{
$this->token0 = new Token(0, 'token 0');
$this->token1 = new Token(1, 'token 1');
Expand All @@ -50,13 +50,16 @@ public function setUp()
public function testAdd()
{
$queue = new TokenQueue();
$this->assertAttributeEquals([], 'tokens', $queue);
$reflection = new \ReflectionClass($queue);
$tokens = $reflection->getProperty('tokens');
$tokens->setAccessible(true);
$this->assertSame([], $tokens->getValue($queue));

$queue->add($this->token0);
$this->assertAttributeEquals([$this->token0], 'tokens', $queue);
$this->assertSame([$this->token0], $tokens->getValue($queue));

$queue->add($this->token1);
$this->assertAttributeEquals([$this->token0, $this->token1], 'tokens', $queue);
$this->assertSame([$this->token0, $this->token1], $tokens->getValue($queue));
}

public function testResetAndPeek()
Expand Down
6 changes: 3 additions & 3 deletions tests/PHPCR/Tests/Util/CND/Scanner/TokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class TokenTest extends TestCase
*/
private $token;

public function setUp()
public function setUp(): void
{
$this->token = new Token(123, 'foobar');
}

public function test__construct()
{
$this->assertAttributeEquals(123, 'type', $this->token);
$this->assertAttributeEquals('foobar', 'data', $this->token);
$this->assertSame(123, $this->token->type);
$this->assertSame('foobar', $this->token->data);
}

public function testGetData()
Expand Down
18 changes: 9 additions & 9 deletions tests/PHPCR/Tests/Util/Console/Command/BaseCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ abstract class BaseCommandTest extends TestCase
*/
public $application;

public function setUp()
public function setUp(): void
{
$this->session = $this->createMock(SessionInterface::class);
$this->workspace = $this->createMock(WorkspaceInterface::class);
Expand All @@ -88,21 +88,21 @@ public function setUp()
'phpcr_console_dumper' => $this->dumperHelper,
]);

$this->session->expects($this->any())
$this->session
->method('getWorkspace')
->will($this->returnValue($this->workspace));
->willReturn($this->workspace);

$this->workspace->expects($this->any())
$this->workspace
->method('getName')
->will($this->returnValue('test'));
->willReturn('test');

$this->workspace->expects($this->any())
$this->workspace
->method('getQueryManager')
->will($this->returnValue($this->queryManager));
->willReturn($this->queryManager);

$this->queryManager->expects($this->any())
$this->queryManager
->method('getSupportedQueryLanguages')
->will($this->returnValue(['JCR-SQL2']));
->willReturn(['JCR-SQL2']);

$this->application = new Application();
$this->application->setHelperSet($this->helperSet);
Expand Down
12 changes: 6 additions & 6 deletions tests/PHPCR/Tests/Util/Console/Command/NodeDumpCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class NodeDumpCommandTest extends BaseCommandTest
/** @var TreeWalker|MockObject */
protected $treeWalker;

public function setUp()
public function setUp(): void
{
parent::setUp();
$this->treeWalker = $this->getMockBuilder(TreeWalker::class)
Expand All @@ -30,13 +30,13 @@ public function testCommand()
$this->dumperHelper
->expects($this->once())
->method('getTreeWalker')
->will($this->returnValue($this->treeWalker));
->willReturn($this->treeWalker);

$this->session
->expects($this->once())
->method('getNode')
->with('/')
->will($this->returnValue($this->node1));
->willReturn($this->node1);

$this->treeWalker
->expects($this->once())
Expand All @@ -53,13 +53,13 @@ public function testCommandIdentifier()
$this->dumperHelper
->expects($this->once())
->method('getTreeWalker')
->will($this->returnValue($this->treeWalker));
->willReturn($this->treeWalker);

$this->session
->expects($this->once())
->method('getNodeByIdentifier')
->with($uuid)
->will($this->returnValue($this->node1));
->willReturn($this->node1);

$this->treeWalker
->expects($this->once())
Expand All @@ -86,6 +86,6 @@ public function testNotFound()
->will($this->throwException(new ItemNotFoundException()));

$ct = $this->executeCommand('phpcr:node:dump', [], 1);
$this->assertContains('does not exist', $ct->getDisplay());
$this->assertStringContainsString('does not exist', $ct->getDisplay());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class NodeRemoveCommandTest extends BaseCommandTest
{
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
34 changes: 17 additions & 17 deletions tests/PHPCR/Tests/Util/Console/Command/NodeTouchCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class NodeTouchCommandTest extends BaseCommandTest
*/
public $phpcrHelper;

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

Expand All @@ -32,13 +32,13 @@ public function setUp()
->disableOriginalConstructor()
->getMock();

$this->phpcrHelper->expects($this->any())
$this->phpcrHelper
->method('getSession')
->will($this->returnValue($this->session));
->willReturn($this->session);

$this->phpcrHelper->expects($this->any())
$this->phpcrHelper
->method('getName')
->will($this->returnValue('phpcr'));
->willReturn('phpcr');

$this->helperSet->set($this->phpcrHelper);
}
Expand All @@ -50,7 +50,7 @@ public function testTouch()

$this->session->expects($this->exactly(2))
->method('getNode')
->will($this->returnCallback(function ($path) use ($node) {
->willReturnCallback(function ($path) use ($node) {
switch ($path) {
case '/':
return $node;
Expand All @@ -59,12 +59,12 @@ public function testTouch()
}

throw new Exception('Unexpected '.$path);
}));
});

$this->node1->expects($this->once())
->method('addNode')
->with('cms')
->will($this->returnValue($child));
->willReturn($child);

$this->session->expects($this->once())
->method('save');
Expand All @@ -77,31 +77,31 @@ public function testUpdate()
$nodeType = $this->createMock(NodeTypeInterface::class);
$nodeType->expects($this->once())
->method('getName')
->will($this->returnValue('nt:unstructured'));
->willReturn('nt:unstructured');

$this->session->expects($this->exactly(1))
->method('getNode')
->with('/cms')
->will($this->returnValue($this->node1));
->willReturn($this->node1);

$this->node1->expects($this->once())
->method('getPrimaryNodeType')
->will($this->returnValue($nodeType));
->willReturn($nodeType);

$me = $this;

$this->phpcrHelper->expects($this->once())
->method('processNode')
->will($this->returnCallback(function ($output, $node, $options) use ($me) {
->willReturnCallback(function ($output, $node, $options) use ($me) {
$me->assertEquals($me->node1, $node);
$me->assertEquals([
'setProp' => ['foo=bar'],
'removeProp' => ['bar'],
'addMixins' => ['foo:bar'],
'setProp' => ['foo=bar'],
'removeProp' => ['bar'],
'addMixins' => ['foo:bar'],
'removeMixins' => ['bar:foo'],
'dump' => true,
'dump' => true,
], $options);
}));
});

$this->executeCommand('phpcr:node:touch', [
'path' => '/cms',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class NodeTypeListCommandTest extends BaseCommandTest
*/
private $nodeTypeManager;

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

Expand All @@ -27,15 +27,15 @@ public function testNodeTypeList()
{
$this->session->expects($this->once())
->method('getWorkspace')
->will($this->returnValue($this->workspace));
->willReturn($this->workspace);

$this->workspace->expects($this->once())
->method('getNodeTypeManager')
->will($this->returnValue($this->nodeTypeManager));
->willReturn($this->nodeTypeManager);

$this->nodeTypeManager->expects($this->once())
->method('getAllNodeTypes')
->will($this->returnValue([]));
->willReturn([]);

$this->executeCommand('phpcr:node-type:list', []);
}
Expand Down
Loading

0 comments on commit e1c0dc8

Please sign in to comment.