Commit 9601e39d authored by catch's avatar catch

Issue #2287139 by alexpott: Fixed Various serialization test failures after updating to php 5.4.29.

parent 4086829b
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "cca4a51cbd3445ccdba4df24bdd2f49e", "hash": "d89a37ea785ca09523298ff00ade2eca",
"packages": [ "packages": [
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
...@@ -970,16 +970,16 @@ ...@@ -970,16 +970,16 @@
}, },
{ {
"name": "phpunit/phpunit-mock-objects", "name": "phpunit/phpunit-mock-objects",
"version": "2.1.4", "version": "dev-master",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "1a894a16b6c15fcdc5ef2b110f0e6233952c9b0f" "reference": "e60bb929c50ae4237aaf680a4f6773f4ee17f0a2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/1a894a16b6c15fcdc5ef2b110f0e6233952c9b0f", "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/32f97c9198be565b6051983c70dc8d8e758725f4",
"reference": "1a894a16b6c15fcdc5ef2b110f0e6233952c9b0f", "reference": "e60bb929c50ae4237aaf680a4f6773f4ee17f0a2",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -987,7 +987,7 @@ ...@@ -987,7 +987,7 @@
"phpunit/php-text-template": "~1.2" "phpunit/php-text-template": "~1.2"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.1" "phpunit/phpunit": "4.3.*@dev"
}, },
"suggest": { "suggest": {
"ext-soap": "*" "ext-soap": "*"
...@@ -995,7 +995,7 @@ ...@@ -995,7 +995,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.1.x-dev" "dev-master": "2.3.x-dev"
} }
}, },
"autoload": { "autoload": {
...@@ -1023,7 +1023,7 @@ ...@@ -1023,7 +1023,7 @@
"mock", "mock",
"xunit" "xunit"
], ],
"time": "2014-06-07 16:22:57" "time": "2014-06-12 07:22:27"
}, },
{ {
"name": "psr/log", "name": "psr/log",
...@@ -2405,7 +2405,8 @@ ...@@ -2405,7 +2405,8 @@
"doctrine/common": 20, "doctrine/common": 20,
"doctrine/annotations": 20, "doctrine/annotations": 20,
"kriswallsmith/assetic": 15, "kriswallsmith/assetic": 15,
"symfony-cmf/routing": 15 "symfony-cmf/routing": 15,
"phpunit/phpunit-mock-objects": 20
}, },
"platform": { "platform": {
"php": ">=5.4.2" "php": ">=5.4.2"
......
...@@ -87,7 +87,6 @@ ...@@ -87,7 +87,6 @@
'PHPUnit_Framework_MockObject_Matcher' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher.php', 'PHPUnit_Framework_MockObject_Matcher' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher.php',
'PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/AnyInvokedCount.php', 'PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/AnyInvokedCount.php',
'PHPUnit_Framework_MockObject_Matcher_AnyParameters' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/AnyParameters.php', 'PHPUnit_Framework_MockObject_Matcher_AnyParameters' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/AnyParameters.php',
'PHPUnit_Framework_MockObject_Matcher_ConsecutiveParameters' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/ConsecutiveParameters.php',
'PHPUnit_Framework_MockObject_Matcher_Invocation' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/Invocation.php', 'PHPUnit_Framework_MockObject_Matcher_Invocation' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/Invocation.php',
'PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtIndex.php', 'PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtIndex.php',
'PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtLeastOnce.php', 'PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce' => $vendorDir . '/phpunit/phpunit-mock-objects/src/Framework/MockObject/Matcher/InvokedAtLeastOnce.php',
......
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
return array( return array(
$vendorDir . '/phpunit/php-text-template', $vendorDir . '/phpunit/php-text-template',
$vendorDir . '/phpunit/phpunit-mock-objects',
$vendorDir . '/phpunit/php-timer', $vendorDir . '/phpunit/php-timer',
$vendorDir . '/phpunit/php-token-stream', $vendorDir . '/phpunit/php-token-stream',
$vendorDir . '/phpunit/php-file-iterator', $vendorDir . '/phpunit/php-file-iterator',
$vendorDir . '/phpunit/php-code-coverage', $vendorDir . '/phpunit/php-code-coverage',
$vendorDir . '/phpunit/phpunit', $vendorDir . '/phpunit/phpunit',
$vendorDir . '/symfony/yaml', $vendorDir . '/symfony/yaml',
$vendorDir . '/phpunit/phpunit-mock-objects',
); );
...@@ -2124,65 +2124,6 @@ ...@@ -2124,65 +2124,6 @@
"template" "template"
] ]
}, },
{
"name": "phpunit/phpunit-mock-objects",
"version": "2.1.4",
"version_normalized": "2.1.4.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "1a894a16b6c15fcdc5ef2b110f0e6233952c9b0f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/1a894a16b6c15fcdc5ef2b110f0e6233952c9b0f",
"reference": "1a894a16b6c15fcdc5ef2b110f0e6233952c9b0f",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"phpunit/php-text-template": "~1.2"
},
"require-dev": {
"phpunit/phpunit": "~4.1"
},
"suggest": {
"ext-soap": "*"
},
"time": "2014-06-07 16:22:57",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
""
],
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"role": "lead"
}
],
"description": "Mock Object library for PHPUnit",
"homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
"keywords": [
"mock",
"xunit"
]
},
{ {
"name": "phpunit/php-timer", "name": "phpunit/php-timer",
"version": "1.0.5", "version": "1.0.5",
...@@ -2470,5 +2411,64 @@ ...@@ -2470,5 +2411,64 @@
"testing", "testing",
"xunit" "xunit"
] ]
},
{
"name": "phpunit/phpunit-mock-objects",
"version": "dev-master",
"version_normalized": "9999999-dev",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "e60bb929c50ae4237aaf680a4f6773f4ee17f0a2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/32f97c9198be565b6051983c70dc8d8e758725f4",
"reference": "e60bb929c50ae4237aaf680a4f6773f4ee17f0a2",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"phpunit/php-text-template": "~1.2"
},
"require-dev": {
"phpunit/phpunit": "4.3.*@dev"
},
"suggest": {
"ext-soap": "*"
},
"time": "2014-06-12 07:22:27",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
""
],
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"role": "lead"
}
],
"description": "Mock Object library for PHPUnit",
"homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
"keywords": [
"mock",
"xunit"
]
} }
] ]
[![Latest Stable Version](https://poser.pugx.org/phpunit/phpunit-mock-objects/v/stable.png)](https://packagist.org/packages/phpunit/phpunit-mock-objects) [![Latest Stable Version](https://poser.pugx.org/phpunit/phpunit-mock-objects/v/stable.png)](https://packagist.org/packages/phpunit/phpunit-mock-objects)
[![Build Status](https://travis-ci.org/sebastianbergmann/phpunit-mock-objects.png?branch=master)](https://travis-ci.org/sebastianbergmann/phpunit-mock-objects) [![Build Status](https://travis-ci.org/sebastianbergmann/phpunit-mock-objects.png?branch=2.0)](https://travis-ci.org/sebastianbergmann/phpunit-mock-objects)
# PHPUnit_MockObject # PHPUnit_MockObject
...@@ -15,7 +15,7 @@ To add PHPUnit_MockObject as a local, per-project dependency to your project, si ...@@ -15,7 +15,7 @@ To add PHPUnit_MockObject as a local, per-project dependency to your project, si
{ {
"require": { "require": {
"phpunit/phpunit-mock-objects": "2.1.*" "phpunit/phpunit-mock-objects": "2.0.*"
} }
} }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.0/phpunit.xsd"
bootstrap="../tests/bootstrap.php" bootstrap="../tests/bootstrap.php"
backupGlobals="false" backupGlobals="false"
verbose="true"> verbose="true">
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
"phpunit/php-text-template": "~1.2" "phpunit/php-text-template": "~1.2"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.1" "phpunit/phpunit": ">=4.0.0,<4.1.0"
}, },
"suggest": { "suggest": {
"ext-soap": "*" "ext-soap": "*"
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
}, },
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.1.x-dev" "dev-master": "2.0.x-dev"
} }
}, },
"include-path": [ "include-path": [
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.0/phpunit.xsd"
bootstrap="tests/bootstrap.php" bootstrap="tests/bootstrap.php"
backupGlobals="false" backupGlobals="false"
verbose="true"> verbose="true">
......
...@@ -212,12 +212,13 @@ public function after($id) ...@@ -212,12 +212,13 @@ public function after($id)
} }
/** /**
* Validate that a parameters matcher can be defined, throw exceptions otherwise. * @param mixed $argument, ...
* * @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
* @throws PHPUnit_Framework_Exception
*/ */
private function canDefineParameters() public function with()
{ {
$args = func_get_args();
if ($this->matcher->methodNameMatcher === NULL) { if ($this->matcher->methodNameMatcher === NULL) {
throw new PHPUnit_Framework_Exception( throw new PHPUnit_Framework_Exception(
'Method name matcher is not defined, cannot define parameter ' . 'Method name matcher is not defined, cannot define parameter ' .
...@@ -230,45 +231,29 @@ private function canDefineParameters() ...@@ -230,45 +231,29 @@ private function canDefineParameters()
'Parameter matcher is already defined, cannot redefine' 'Parameter matcher is already defined, cannot redefine'
); );
} }
}
/**
* @param mixed $argument, ...
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
*/
public function with()
{
$args = func_get_args();
$this->canDefineParameters();
$this->matcher->parametersMatcher = new PHPUnit_Framework_MockObject_Matcher_Parameters($args); $this->matcher->parametersMatcher = new PHPUnit_Framework_MockObject_Matcher_Parameters($args);
return $this; return $this;
} }
/**
* @param mixed ...$argument
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
*/
public function withConsecutive() {
$args = func_get_args();
$this->canDefineParameters();
$this->matcher->parametersMatcher =
new PHPUnit_Framework_MockObject_Matcher_ConsecutiveParameters($args);
return $this;
}
/** /**
* @return PHPUnit_Framework_MockObject_Builder_InvocationMocker * @return PHPUnit_Framework_MockObject_Builder_InvocationMocker
*/ */
public function withAnyParameters() public function withAnyParameters()
{ {
$this->canDefineParameters(); if ($this->matcher->methodNameMatcher === NULL) {
throw new PHPUnit_Framework_Exception(
'Method name matcher is not defined, cannot define parameter ' .
'matcher without one'
);
}
if ($this->matcher->parametersMatcher !== NULL) {
throw new PHPUnit_Framework_Exception(
'Parameter matcher is already defined, cannot redefine'
);
}
$this->matcher->parametersMatcher = new PHPUnit_Framework_MockObject_Matcher_AnyParameters; $this->matcher->parametersMatcher = new PHPUnit_Framework_MockObject_Matcher_AnyParameters;
......
...@@ -274,15 +274,13 @@ protected function getObject($code, $className, $type = '', $callOriginalConstru ...@@ -274,15 +274,13 @@ protected function getObject($code, $className, $type = '', $callOriginalConstru
$class = new ReflectionClass($className); $class = new ReflectionClass($className);
$isInternal = $this->isInternalClass($class); $isInternal = $this->isInternalClass($class);
if ($isInternal && !$this->unserializeHackIsSupported()) {
throw new PHPUnit_Framework_MockObject_RuntimeException(
'Internal classes cannot be mocked without invoking their constructor in PHP ' . PHP_VERSION
);
}
if ($isInternal || !$hasNewInstanceWithoutConstructor) { if ($isInternal || !$hasNewInstanceWithoutConstructor) {
$object = unserialize( $object = unserialize(
sprintf('O:%d:"%s":0:{}', strlen($className), $className) sprintf('%s:%d:"%s":0:{}',
(version_compare(PHP_VERSION, '5.4', '>') && $class->implementsInterface("Serializable") ? "C" : "O"),
strlen($className),
$className
)
); );
} else { } else {
$object = $class->newInstanceWithoutConstructor(); $object = $class->newInstanceWithoutConstructor();
...@@ -1097,18 +1095,4 @@ private function isInternalClass(ReflectionClass $class) ...@@ -1097,18 +1095,4 @@ private function isInternalClass(ReflectionClass $class)
return false; return false;
} }
/**
* @return boolean
* @since Method available since Release 2.0.9
*/
private function unserializeHackIsSupported()
{
if (PHP_VERSION == '5.4.29' || PHP_VERSION == '5.5.13' ||
version_compare(PHP_VERSION, '5.6.0', '>=')) {
return FALSE;
}
return TRUE;
}
} }
<?php
/**
* PHPUnit
*
* Copyright (c) 2010-2014, Sebastian Bergmann <sebastian@phpunit.de>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Sebastian Bergmann nor the names of his
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package PHPUnit_MockObject
* @author Sebastian Bergmann <sebastian@phpunit.de>
* @copyright 2010-2014 Sebastian Bergmann <sebastian@phpunit.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @link http://github.com/sebastianbergmann/phpunit-mock-objects
*/
/**
* Invocation matcher which looks for sets of specific parameters in the invocations.
*
* Checks the parameters of the incoming invocations, the parameter list is
* checked against the defined constraints in $parameters. If the constraint
* is met it will return true in matches().
*
* It takes a list of match groups and and increases a call index after each invocation.
* So the first invocation uses the first group of constraints, the second the next and so on.
*
* @package PHPUnit_MockObject
* @author Sebastian Bergmann <sebastian@phpunit.de>
* @copyright 2010-2014 Sebastian Bergmann <sebastian@phpunit.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @version Release: @package_version@
* @link http://github.com/sebastianbergmann/phpunit-mock-objects
*/
class PHPUnit_Framework_MockObject_Matcher_ConsecutiveParameters
extends PHPUnit_Framework_MockObject_Matcher_StatelessInvocation
{
/**
* @var array
*/
private $_parameterGroups = array();
/**
* @var array
*/
private $_invocations = array();
/**
* @param array $parameterGroups
*/
public function __construct(array $parameterGroups)
{
foreach ($parameterGroups as $index => $parameters) {
foreach ($parameters as $parameter) {
if (!($parameter instanceof \PHPUnit_Framework_Constraint))
{
$parameter = new \PHPUnit_Framework_Constraint_IsEqual($parameter);
}
$this->_parameterGroups[$index][] = $parameter;
}
}
}
/**
* @return string
*/
public function toString()
{
$text = 'with consecutive parameters';
return $text;
}
/**
* @param PHPUnit_Framework_MockObject_Invocation $invocation
* @return bool
*/
public function matches(PHPUnit_Framework_MockObject_Invocation $invocation)
{
$this->_invocations[] = $invocation;
$callIndex = count($this->_invocations) - 1;
$this->verifyInvocation($invocation, $callIndex);