Skip to content

Commit b6846de

Browse files
authored
Support for symfony 4 (#42)
* Support for syfmony 4 * adding more dependencies * adding RC flag * Using simple-phpunit * Bugfixes * Fixed tests * bump versions * Bugfix * Added changelog * Added nyholm reporter * Bump min reqs
1 parent 3faa6e8 commit b6846de

File tree

6 files changed

+104
-26
lines changed

6 files changed

+104
-26
lines changed

.travis.yml

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,10 @@ cache:
66
directories:
77
- $HOME/.composer/cache/files
88

9-
php:
10-
- 7.0
11-
- 7.1
12-
139
env:
1410
global:
1511
- TEST_COMMAND="composer test"
16-
matrix:
17-
- SYMFONY_VERSION=3.2.*
18-
- SYMFONY_VERSION=2.8.*
19-
- SYMFONY_VERSION=2.7.*
12+
- SYMFONY_PHPUNIT_VERSION="6.3"
2013

2114
branches:
2215
except:
@@ -25,18 +18,53 @@ branches:
2518
matrix:
2619
fast_finish: true
2720
include:
21+
# Test with lowest dependencies
22+
- php: 7.2
23+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak"
2824
- php: 7.0
29-
env: SYMFONY_VERSION="3.2.* graphaware/neo4j-php-ogm:^1.0" COVERAGE=true TEST_COMMAND="composer test-ci"
25+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak"
26+
27+
# Test the latest stable release
3028
- php: 7.0
31-
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_VERSION=2.7.*
29+
- php: 7.1
30+
- php: 7.2
31+
env: COVERAGE=true TEST_COMMAND="composer test-ci" DEPENDENCIES="graphaware/neo4j-php-ogm:^1.0@rc"
32+
33+
# Force some major versions of Symfony
34+
- php: 7.2
35+
env: DEPENDENCIES="dunglas/symfony-lock:^2"
36+
- php: 7.2
37+
env: DEPENDENCIES="dunglas/symfony-lock:^3"
38+
- php: 7.2
39+
env: DEPENDENCIES="dunglas/symfony-lock:^4"
40+
41+
# Latest commit to master
42+
- php: 7.2
43+
env: STABILITY="dev"
44+
45+
allow_failures:
46+
# Dev-master is allowed to fail.
47+
- env: STABILITY="dev"
48+
49+
before_install:
50+
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
51+
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
52+
- if ! [ -z "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;
3253

3354
install:
34-
- composer require symfony/symfony:${SYMFONY_VERSION} --no-update
35-
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
55+
# To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355
56+
- if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi
57+
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
58+
- vendor/bin/simple-phpunit install
3659

3760
script:
61+
- composer validate --strict --no-check-lock
3862
- $TEST_COMMAND
3963

4064
after_success:
41-
- if [[ $COVERAGE = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
42-
- if [[ $COVERAGE = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi
65+
- if [[ "$COVERAGE" = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
66+
- if [[ "$COVERAGE" = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi
67+
68+
after_script:
69+
- wget http://tnyholm.se/reporter.phar
70+
- php reporter.phar build:upload

Changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
44

5+
## 0.4.0
6+
7+
### Added
8+
9+
- Support for Symfony 4
10+
11+
### Fixed
12+
13+
- Updating the twig path for symfony flex
14+
- Register an autoloader for proxies to avoid issues when unserializing
15+
516
## 0.3.0
617

718
### Added

DependencyInjection/Neo4jExtension.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use GraphAware\Neo4j\Client\HttpDriver\Driver as HttpDriver;
1111
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1212
use Symfony\Component\Config\FileLocator;
13+
use Symfony\Component\DependencyInjection\ChildDefinition;
1314
use Symfony\Component\DependencyInjection\ContainerBuilder;
1415
use Symfony\Component\DependencyInjection\Definition;
1516
use Symfony\Component\DependencyInjection\DefinitionDecorator;
@@ -99,8 +100,12 @@ private function handleClients(array &$config, ContainerBuilder $container): arr
99100
$connections[] = 'default';
100101
}
101102

103+
$definition = class_exists(ChildDefinition::class)
104+
? new ChildDefinition('neo4j.client.abstract')
105+
: new DefinitionDecorator('neo4j.client.abstract');
106+
102107
$container
103-
->setDefinition($serviceId, new DefinitionDecorator('neo4j.client.abstract'))
108+
->setDefinition($serviceId, $definition)
104109
->setArguments([$connections]);
105110
}
106111

@@ -127,8 +132,13 @@ private function handleEntityMangers(array &$config, ContainerBuilder $container
127132
$clientName
128133
));
129134
}
135+
136+
$definition = class_exists(ChildDefinition::class)
137+
? new ChildDefinition('neo4j.entity_manager.abstract')
138+
: new DefinitionDecorator('neo4j.entity_manager.abstract');
139+
130140
$container
131-
->setDefinition($serviceId, new DefinitionDecorator('neo4j.entity_manager.abstract'))
141+
->setDefinition($serviceId, $definition)
132142
->setArguments([
133143
$container->getDefinition($clientServiceIds[$clientName]),
134144
empty($data['cache_dir']) ? $container->getParameter('kernel.cache_dir').'/neo4j' : $data['cache_dir'],

Tests/Functional/app/AppKernel.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use Neo4j\Neo4jBundle\Neo4jBundle;
66
use Symfony\Component\Config\Loader\LoaderInterface;
7+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8+
use Symfony\Component\DependencyInjection\ContainerBuilder;
79
use Symfony\Component\Filesystem\Filesystem;
810
use Symfony\Component\HttpKernel\Kernel;
911

@@ -55,4 +57,26 @@ public function unserialize($config)
5557
{
5658
$this->__construct($config);
5759
}
60+
61+
protected function build(ContainerBuilder $container)
62+
{
63+
$container->addCompilerPass(new PublicServicesForFunctionalTestsPass());
64+
}
65+
}
66+
67+
class PublicServicesForFunctionalTestsPass implements CompilerPassInterface
68+
{
69+
public function process(ContainerBuilder $container)
70+
{
71+
$aliases = [
72+
'neo4j.connection',
73+
'neo4j.client',
74+
'neo4j.entity_manager',
75+
];
76+
foreach ($aliases as $alias) {
77+
if ($container->hasAlias($alias)) {
78+
$container->getAlias($alias)->setPublic(true);
79+
}
80+
}
81+
}
5882
}

Tests/Unit/Collector/Twig/Neo4jResultExtensionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
use GraphAware\Neo4j\Client\Formatter\Type\Node;
66
use Neo4j\Neo4jBundle\Collector\Twig\Neo4jResultExtension;
7+
use PHPUnit\Framework\TestCase;
78

89
/**
910
* @author Tobias Nyholm <[email protected]>
1011
*/
11-
class Neo4jResultExtensionTest extends \PHPUnit_Framework_TestCase
12+
class Neo4jResultExtensionTest extends TestCase
1213
{
1314
public function testEmptyArray()
1415
{

composer.json

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616
],
1717
"require": {
1818
"php": "^7.0",
19+
"graphaware/neo4j-bolt": "^1.6",
1920
"graphaware/neo4j-php-client": "^4.6.4",
20-
"symfony/framework-bundle": "^2.7 || ^3.0",
21-
"graphaware/neo4j-bolt": "^1.6"
21+
"symfony/dependency-injection": " ^2.8.3 || ^3.0.3 || ^4.0",
22+
"symfony/framework-bundle": "^2.8.32 || ^3.0 || ^4.0",
23+
"symfony/http-kernel": "^2.8 || ^3.0 || ^4.0",
24+
"twig/twig": "^1.18 || ^2.0"
2225
},
2326
"require-dev": {
24-
"phpunit/phpunit": "^5.4",
25-
"symfony/symfony": "^2.7 || ^3.0",
26-
"matthiasnoback/symfony-dependency-injection-test": "^1.0"
27+
"symfony/phpunit-bridge": "^3.3 || ^4.0",
28+
"matthiasnoback/symfony-dependency-injection-test": "^2.3"
2729
},
2830
"suggest": {
2931
"graphaware/neo4j-php-ogm": "To have EntityManager support"
@@ -33,9 +35,11 @@
3335
"Neo4j\\Neo4jBundle\\": ""
3436
}
3537
},
36-
"scripts": {
37-
"test": "vendor/bin/phpunit",
38-
"test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml"
38+
"config": {
39+
"sort-packages": true
3940
},
40-
"minimum-stability": "beta"
41+
"scripts": {
42+
"test": "vendor/bin/simple-phpunit",
43+
"test-ci": "vendor/bin/simple-phpunit --coverage-text --coverage-clover=build/coverage.xml"
44+
}
4145
}

0 commit comments

Comments
 (0)