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

Add support for php7 and get all tests running #53

Merged
merged 8 commits into from
Aug 18, 2016
17 changes: 10 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ php:
- 5.4
- 5.5
- 5.6
- 7.0

cache:
directories:
- $HOME/.composer/cache/files

# test only master (+ Pull requests)
branches:
Expand All @@ -14,24 +19,22 @@ branches:

# setup requirements for running unit tests
before_script:
# Get latests version of composer which is faster (and to attempt to avoid memory issues with legacy package)
- composer self-update
# Disable xdebug to speed things up as we don't currently generate coverge on travis
- if [ $TRAVIS_PHP_VERSION != "hhvm" ]; then phpenv config-rm xdebug.ini ; fi
# Avoid issues on composer install since we pull in both legacy and platform stack
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
# Setup github key to avoid api rate limit
- ./composer_install_github_key.sh
# Setup github key to avoid api rate limit (pure auth read only key, no rights, for use in ezsystems repos only)
- composer config -g github-oauth.github.com "d0285ed5c8644f30547572ead2ed897431c1fc09"
# Install packages using composer
- composer install --dev --prefer-dist
- travis_retry composer install --dev --prefer-dist
# Copy default test configuration
- cp config.php-DEVELOPMENT config.php

# execute phpunit as the script command
script: "./bin/phpunit -d date.timezone='America/New_York' -d memory_limit=-1"
script: "php -d date.timezone='America/New_York' -d memory_limit=-1 bin/phpunit"

# disable mail notifications
notification:
notifications:
email: false

# reduce depth (history) of git checkout
Expand Down
10 changes: 5 additions & 5 deletions bundle/Cache/SwitchableHttpCachePurger.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public function __construct(GatewayCachePurger $gatewayCachePurger)
$this->gatewayCachePurger = $gatewayCachePurger;
}

public function purge($cacheElements)
public function purge($locationIds)
{
if ($this->isSwitchedOff()) {
return $cacheElements;
return $locationIds;
}

return $this->gatewayCachePurger->purge($cacheElements);
return $this->gatewayCachePurger->purge($locationIds);
}

public function purgeAll()
Expand All @@ -42,12 +42,12 @@ public function purgeAll()
$this->gatewayCachePurger->purgeAll();
}

public function purgeForContent($contentId)
public function purgeForContent($contentId, $locationIds = array())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a breaking change? If so, we should require eZ Kernel >=6.3.2|>=6.4.2 (when 6.4.2 is released) in composer.json, right?

Copy link
Contributor Author

@andrerom andrerom Aug 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but adding optional argument won't break the contract. In retrospective it was the kernel that broke the contract here.

So besides the fact that kernel should not have done this change, I think this fix is ok as is, it will work on older kernels also.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So besides the fact that kernel should not have done this change, I think this fix is ok as is, it will work on older kernels also.

Agreed.

{
if ($this->isSwitchedOff()) {
return;
}

$this->gatewayCachePurger->purgeForContent($contentId);
$this->gatewayCachePurger->purgeForContent($contentId, $locationIds);
}
}
2 changes: 1 addition & 1 deletion bundle/DependencyInjection/EzPublishLegacyExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function load(array $configs, ContainerBuilder $container)
$processor = new ConfigurationProcessor($container, 'ezpublish_legacy');
$processor->mapConfig(
$config,
function (array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer) {
function (array $scopeSettings, $currentScope, ContextualizerInterface $contextualizer) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that could break on PHP 5.x?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't see how, the variable is not modified inside the closure.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, just wanted to confirm.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it won't break.

if (isset($scopeSettings['templating']['view_layout'])) {
$contextualizer->setContextualParameter('view_default_layout', $currentScope, $scopeSettings['templating']['view_layout']);
}
Expand Down
16 changes: 16 additions & 0 deletions bundle/Tests/SiteAccess/LegacyMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@

class LegacyMapperTest extends LegacyBasedTestCase
{
private $systemErrorLevel;

protected function setUp()
{
parent::setUp();

// Silence E_DEPRECATED to avoid issues with notices from legacy in regards to constructors
$this->systemErrorLevel = error_reporting(E_ALL & ~E_DEPRECATED);
}

protected function tearDown()
{
error_reporting($this->systemErrorLevel);
parent::tearDown();
}

/**
* @dataProvider siteAccessMatchProvider
*/
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
"require": {
"ezsystems/ezpublish-legacy": ">=2014.11",
"ezsystems/ezpublish-kernel": "~6.0@dev",
"sensio/distribution-bundle": "^3.0|^4.0",
"twig/twig": "^1.23 | ^2.0"
},
"require-dev": {
"matthiasnoback/symfony-dependency-injection-test": "0.*",
"phpunit/phpunit": "~4.1.3",
"mikey179/vfsStream": "1.1.0",
"mockery/mockery": "dev-master"
"matthiasnoback/symfony-dependency-injection-test": "^1.0",
"phpunit/phpunit": "~4.7",
"mikey179/vfsStream": "~1.1.0",
"mockery/mockery": "^0.9"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 0 additions & 4 deletions composer_install_github_key.sh

This file was deleted.

2 changes: 1 addition & 1 deletion mvc/Tests/KernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testRunCallbackWithException()
$iterations = 1;
do {
try {
$this->getLegacyKernel()->runCallback('');
$this->getLegacyKernel()->runCallback(function () {});
}
// this will occur on the 2nd iteration if the kernel state hasn't been correctly reset
catch (RuntimeException $e) {
Expand Down
3 changes: 2 additions & 1 deletion mvc/Tests/Security/SSOListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public function testGetPreAuthenticatedData()

$userId = 123;
$passwordHash = md5('password');
$legacyUser = new eZUser(array('contentobject_id' => $userId));
// Specifically silence E_DEPRECATED on constructor name for php7
$legacyUser = @new eZUser(array('contentobject_id' => $userId));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above. Better manipulate php.ini to silent E_DEPRECATED before start.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did not fix this as the aim is to only silence deprecation errors regarding constructor since that is the only one we most likely can't do anything about w/o introducing BC.

So left this one here but with a comment, which I guess is ok given this is test code only.
see 90d6969

$apiUser = $this
->getMockBuilder('eZ\Publish\API\Repository\Values\User\User')
->setConstructorArgs(array(array('passwordHash' => $passwordHash)))
Expand Down