Skip to content

Commit

Permalink
Add compatibility for symfony 5.0 #SymfonyHackday (#26)
Browse files Browse the repository at this point in the history
* Add compatibility to Symfony 5
* Remove compatibility to Symfony <= 4.4
* Update PHPUnit to 7
* Replace BaseEvent with Symfony Contract Event
* Fix php 7.4 compatibility
  • Loading branch information
alexander-schranz authored Feb 14, 2020
1 parent acd36ab commit 52899e9
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
composer.lock
tests/data/
vendor/
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
language: php

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

env:
- PACKAGE_VERSION=high
Expand All @@ -13,7 +12,7 @@ sudo: false

matrix:
include:
- php: 5.6
- php: 7.2
env: PACKAGE_VERSION=low

before_script:
Expand Down
24 changes: 13 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,33 @@
}
],
"require": {
"php": ">=5.4",
"jackalope/jackalope": "~1.3",
"symfony/yaml": "~2.8 || ~3.4 || ~4.0",
"symfony/filesystem": "~2.8 || ~3.4 || ~4.0",
"symfony/event-dispatcher": "~2.8 || ~3.4 || ~4.0",
"zendframework/zend-stdlib": "~2.3",
"zendframework/zendsearch": "@dev"
"php": "^7.2",
"jackalope/jackalope": "^1.3.4",
"symfony/yaml": "^4.4 || ^5.0",
"symfony/filesystem": "^4.4 || ^5.0",
"symfony/event-dispatcher": "^4.4 || ^5.0",
"symfony/event-dispatcher-contracts": "^1.0 || ^2.0",
"handcraftedinthealps/zendsearch": "^2.0"
},
"conflict": {
"phpcr/phpcr-utils": "<1.3.1"
},
"provide": {
"jackalope/jackalope-transport": "1.1.0"
},
"require-dev": {
"phpcr/phpcr-api-tests": "dev-master",
"phpunit/phpunit": "~5.7",
"phpspec/prophecy-phpunit": "~1.0"
"phpunit/phpunit": "^7.0"
},
"autoload": {
"psr-4": {
"psr-4": {
"Jackalope\\": "src/",
"Jackalope\\Test\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "1.x-dev"
}
}
}
2 changes: 1 addition & 1 deletion src/Transport/Fs/Event/NodeWriteEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Jackalope\Transport\Fs\Event;

use Symfony\Component\EventDispatcher\Event;
use Jackalope\Transport\Fs\Model\Node;
use Symfony\Contracts\EventDispatcher\Event;

/**
* Event which is dispatched when a node is written.
Expand Down
6 changes: 3 additions & 3 deletions src/Transport/Fs/Filesystem/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
use Jackalope\Transport\Fs\NodeSerializer\YamlNodeSerializer;
use Jackalope\Transport\Fs\Filesystem\Storage\Index;
use PHPCR\Util\PathHelper;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Contracts\EventDispatcher\Event;
use Jackalope\Transport\Fs\Model\Node;
use Jackalope\Transport\Fs\Filesystem\Storage\NodeRemover;

Expand Down Expand Up @@ -52,7 +52,7 @@ public function __construct(Filesystem $filesystem, EventDispatcher $eventDispat
public function writeNode($workspace, $path, Node $node)
{
$node = $this->nodeWriter->writeNode($workspace, $path, $node);
$this->eventDispatcher->dispatch(Events::POST_WRITE_NODE, new NodeWriteEvent($workspace, $path, $node));
$this->eventDispatcher->dispatch(new NodeWriteEvent($workspace, $path, $node), Events::POST_WRITE_NODE);
}

public function readNode($workspace, $path)
Expand Down Expand Up @@ -200,7 +200,7 @@ public function unregisterNamespace($workspaceName, $targetPrefix)

public function commit()
{
$this->eventDispatcher->dispatch(Events::COMMIT, new Event());
$this->eventDispatcher->dispatch(new Event(), Events::COMMIT);
}

public function getNamespaces()
Expand Down
4 changes: 2 additions & 2 deletions src/Transport/Fs/Filesystem/Storage/NodeReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function readBinaryStream($workspace, $path)

$originalBinaryHash = $binaryHashMap[$propertyName];
$binaryHashes = (array) $originalBinaryHash;

$streams = array();
foreach ($binaryHashes as $binaryHash) {
$path = $this->helper->getBinaryPath($workspace, $parentPath, $binaryHash);
Expand Down Expand Up @@ -155,7 +155,7 @@ public function readNodeReferrers($workspace, $path, $weak = false, $name)
foreach ($referrers as $internalUuid => $propertyNames) {
foreach (array_keys($propertyNames) as $propertyName) {
$referrer = $this->readNodesByUuids(array($internalUuid), true);
$referrerPaths[] = sprintf('%s/%s', key($referrer), $propertyName);
$referrerPaths[] = sprintf('%s/%s', $referrer->getIterator()->key(), $propertyName);
}
}

Expand Down
19 changes: 19 additions & 0 deletions tests/ImplementationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,25 @@ protected function __construct()
'Query\QuerySql2OperationsTest::testLengthOperandOnEmptyProperty',
'Query\QuerySql2OperationsTest::testLengthOperandOnStringProperty',

// invalid query for zendsearch
'Query\QuerySql2OperationsTest::testQueryFieldDate',

// source class 'Jackalope\Query\QOM\Join' is not supported
'Query\QuerySql2OperationsTest::testQueryJoinNested',
'Query\QuerySql2OperationsTest::testQueryLeftJoinNull',

// this doesn't work with ZendSearch yet
'Query\QueryResultsTest::testCompareNumberFieldsMulti',
'Reading\BinaryReadMethodsTest::testReadEmptyBinaryMultivalue',
'Writing\CombinedManipulationsTest::testRemoveSessionRefresh',
'Writing\CopyMethodsTest::testCopyPreserveChildOrder',
'Writing\DeleteMethodsTest::testDeletePreviouslyReferencedNodeInMultipleProperty',
'Writing\SetPropertyMethodsTest::testSetPropertyMultivalueAllNull',
'Writing\CopyMethodsTest::testWorkspaceCopyReference',
'Writing\CopyMethodsTest::testCopyChildrenBinaryData',
'Writing\CopyMethodsTest::testCopyChildrenBinaryDataMultivalue',
'Writing\MoveMethodsTest::testNodeRename',

// this doesn't work with ZendSearch -- need to implement a native search engine
'Writing\CombinedManipulationsTest::testAddAndRemoveAndAdd',
'Writing\CombinedManipulationsTest::testRemoveAndAddToplevelNode',
Expand Down
3 changes: 2 additions & 1 deletion tests/Transport/Fs/Filesystem/Adapter/AdapterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace Jackalope\Tests\Transport\Fs\Filesystem\Adapter;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Filesystem;
use Jackalope\Transport\Fs\Filesystem\Adapter\LocalAdapter;

abstract class AdapterTestCase extends \PHPUnit_Framework_TestCase
abstract class AdapterTestCase extends TestCase
{
protected $testDir;

Expand Down
4 changes: 3 additions & 1 deletion tests/Transport/Fs/Filesystem/PathRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Jackalope\Transport\Fs\Filesystem;

class PathRegistryTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class PathRegistryTest extends TestCase
{
public function setUp()
{
Expand Down

0 comments on commit 52899e9

Please sign in to comment.