Commit 345367fd authored by webchick's avatar webchick

Issue #2400407 by DuaelFr: Ensure vendor phpspec/prophecy is on latest stable release

parent 836574f2
......@@ -1117,16 +1117,16 @@
},
{
"name": "phpspec/prophecy",
"version": "1.4.0",
"version": "v1.5.0",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5"
"reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5",
"reference": "8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/4745ded9307786b730d7a60df5cb5a6c43cf95f7",
"reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7",
"shasum": ""
},
"require": {
......@@ -1173,7 +1173,7 @@
"spy",
"stub"
],
"time": "2015-03-27 19:31:25"
"time": "2015-08-13 10:07:40"
},
{
"name": "phpunit/php-code-coverage",
......
......@@ -761,68 +761,6 @@
}
]
},
{
"name": "phpspec/prophecy",
"version": "1.4.0",
"version_normalized": "1.4.0.0",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5",
"reference": "8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"phpdocumentor/reflection-docblock": "~2.0",
"sebastian/comparator": "~1.1"
},
"require-dev": {
"phpspec/phpspec": "~2.0"
},
"time": "2015-03-27 19:31:25",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Prophecy\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Konstantin Kudryashov",
"email": "ever.zet@gmail.com",
"homepage": "http://everzet.com"
},
{
"name": "Marcello Duarte",
"email": "marcello.duarte@gmail.com"
}
],
"description": "Highly opinionated mocking framework for PHP 5.3+",
"homepage": "https://github.com/phpspec/prophecy",
"keywords": [
"Double",
"Dummy",
"fake",
"mock",
"spy",
"stub"
]
},
{
"name": "phpunit/phpunit-mock-objects",
"version": "2.3.1",
......@@ -3486,5 +3424,67 @@
"keywords": [
"scraper"
]
},
{
"name": "phpspec/prophecy",
"version": "v1.5.0",
"version_normalized": "1.5.0.0",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/4745ded9307786b730d7a60df5cb5a6c43cf95f7",
"reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"phpdocumentor/reflection-docblock": "~2.0",
"sebastian/comparator": "~1.1"
},
"require-dev": {
"phpspec/phpspec": "~2.0"
},
"time": "2015-08-13 10:07:40",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Prophecy\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Konstantin Kudryashov",
"email": "ever.zet@gmail.com",
"homepage": "http://everzet.com"
},
{
"name": "Marcello Duarte",
"email": "marcello.duarte@gmail.com"
}
],
"description": "Highly opinionated mocking framework for PHP 5.3+",
"homepage": "https://github.com/phpspec/prophecy",
"keywords": [
"Double",
"Dummy",
"fake",
"mock",
"spy",
"stub"
]
}
]
......@@ -2,4 +2,3 @@
*.phar
bin
vendor
composer.lock
language: php
php: [5.3, 5.4, 5.5, hhvm, hhvm-nightly]
php: [5.3, 5.4, 5.5, 5.6, 7, hhvm]
sudo: false
before_script: travis_retry composer install --no-interaction --prefer-source
cache:
directories:
- $HOME/.composer/cache
branches:
except:
- /^bugfix\/.*$/
- /^feature\/.*$/
- /^optimization\/.*$/
before_script: travis_retry composer install --no-interaction
script: vendor/bin/phpspec run -fpretty -v
1.5.0 / 2015-04-27
==================
* Add support for PHP7 scalar type hints (thanks @trowski)
* Add support for PHP7 return types (thanks @trowski)
* Update internal test suite to support PHP7
1.4.1 / 2015-04-27
==================
* Fixed bug in closure-based argument tokens (#181)
1.4.0 / 2015-03-27
==================
......
......@@ -17,5 +17,5 @@ Make sure that you don't break anything with your changes by running:
```bash
$> composer install --dev --prefer-dist
$> vendor/bin/phpspec
$> vendor/bin/phpspec run
```
......@@ -244,6 +244,7 @@ That's why Prophecy comes bundled with a bunch of other tokens:
- `CallbackToken` or `Argument::that(callback)` - checks that the argument matches a custom callback
- `AnyValueToken` or `Argument::any()` - matches any argument
- `AnyValuesToken` or `Argument::cetera()` - matches any arguments to the rest of the signature
- `StringContainsToken` or `Argument::containingString($value)` - checks that the argument contains a specific string value
And you can add even more by implementing `TokenInterface` with your own custom classes.
......
This diff is collapsed.
......@@ -35,7 +35,10 @@ function it_generates_string_representation_from_all_tokens_imploded($token1, $t
$this->__toString()->shouldReturn('token_1, token_2, token_3');
}
function it_exposes_list_of_tokens(TokenInterface $token)
/**
* @param \Prophecy\Argument\Token\TokenInterface $token
*/
function it_exposes_list_of_tokens($token)
{
$this->beConstructedWith(array($token));
......
......@@ -50,7 +50,10 @@ function it_has_simple_string_representation()
$this->__toString()->shouldReturn('type(integer)');
}
function it_scores_5_if_argument_is_an_instance_of_specified_interface(\Prophecy\Argument\Token\TokenInterface $interface)
/**
* @param \Prophecy\Argument\Token\TokenInterface $interface
*/
function it_scores_5_if_argument_is_an_instance_of_specified_interface($interface)
{
$this->beConstructedWith('Prophecy\Argument\Token\TokenInterface');
......
......@@ -8,11 +8,18 @@
class CallCenterSpec extends ObjectBehavior
{
function let(ObjectProphecy $objectProphecy)
/**
* @param \Prophecy\Prophecy\ObjectProphecy $objectProphecy
*/
function let($objectProphecy)
{
}
function it_records_calls_made_through_makeCall_method(ObjectProphecy $objectProphecy, ArgumentsWildcard $wildcard)
/**
* @param \Prophecy\Prophecy\ObjectProphecy $objectProphecy
* @param \Prophecy\Argument\ArgumentsWildcard $wildcard
*/
function it_records_calls_made_through_makeCall_method($objectProphecy, $wildcard)
{
$wildcard->scoreArguments(array(5, 2, 3))->willReturn(10);
$objectProphecy->getMethodProphecies()->willReturn(array());
......
<?php
namespace spec\Prophecy\Comparator;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class ClosureComparatorSpec extends ObjectBehavior
{
function it_is_comparator()
{
$this->shouldHaveType('SebastianBergmann\Comparator\Comparator');
}
function it_accepts_only_closures()
{
$this->accepts(123, 321)->shouldReturn(false);
$this->accepts('string', 'string')->shouldReturn(false);
$this->accepts(false, true)->shouldReturn(false);
$this->accepts(true, false)->shouldReturn(false);
$this->accepts((object)array(), (object)array())->shouldReturn(false);
$this->accepts(function(){}, (object)array())->shouldReturn(false);
$this->accepts(function(){}, (object)array())->shouldReturn(false);
$this->accepts(function(){}, function(){})->shouldReturn(true);
}
function it_asserts_that_all_closures_are_different()
{
$this->shouldThrow()->duringAssertEquals(function(){}, function(){});
}
function it_asserts_that_all_closures_are_different_even_if_its_the_same_closure()
{
$closure = function(){};
$this->shouldThrow()->duringAssertEquals($closure, $closure);
}
}
<?php
namespace spec\Prophecy\Comparator;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class FactorySpec extends ObjectBehavior
{
function it_extends_Sebastian_Comparator_Factory()
{
$this->shouldHaveType('SebastianBergmann\Comparator\Factory');
}
function it_should_have_ClosureComparator_registered()
{
$comparator = $this->getInstance()->getComparatorFor(function(){}, function(){});
$comparator->shouldHaveType('Prophecy\Comparator\ClosureComparator');
}
}
......@@ -32,6 +32,8 @@ function it_generates_proper_php_code_for_specific_ClassNode(
$method1->returnsReference()->willReturn(false);
$method1->isStatic()->willReturn(true);
$method1->getArguments()->willReturn(array($argument11, $argument12));
$method1->hasReturnType()->willReturn(true);
$method1->getReturnType()->willReturn('string');
$method1->getCode()->willReturn('return $this->name;');
$method2->getName()->willReturn('getEmail');
......@@ -39,6 +41,7 @@ function it_generates_proper_php_code_for_specific_ClassNode(
$method2->returnsReference()->willReturn(false);
$method2->isStatic()->willReturn(false);
$method2->getArguments()->willReturn(array($argument21));
$method2->hasReturnType()->willReturn(false);
$method2->getCode()->willReturn('return $this->email;');
$method3->getName()->willReturn('getRefValue');
......@@ -46,6 +49,7 @@ function it_generates_proper_php_code_for_specific_ClassNode(
$method3->returnsReference()->willReturn(true);
$method3->isStatic()->willReturn(false);
$method3->getArguments()->willReturn(array($argument31));
$method3->hasReturnType()->willReturn(false);
$method3->getCode()->willReturn('return $this->refValue;');
$argument11->getName()->willReturn('fullname');
......@@ -78,7 +82,7 @@ class CustomClass extends \RuntimeException implements \Prophecy\Doubler\Generat
public $name;
private $email;
public static function getName(array $fullname = NULL, \ReflectionClass $class) {
public static function getName(array $fullname = NULL, \ReflectionClass $class): string {
return $this->name;
}
protected function getEmail( $default = 'ever.zet@gmail.com') {
......@@ -113,6 +117,7 @@ function it_overrides_properly_methods_with_args_passed_by_reference(
$method->getVisibility()->willReturn('public');
$method->isStatic()->willReturn(false);
$method->getArguments()->willReturn(array($argument));
$method->hasReturnType()->willReturn(false);
$method->returnsReference()->willReturn(false);
$method->getCode()->willReturn('return $this->name;');
......
......@@ -53,6 +53,12 @@ function it_reflects_a_class_by_mirroring_all_its_public_methods(
$method2->getParameters()->willReturn(array());
$method3->getParameters()->willReturn(array());
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$method1->hasReturnType()->willReturn(false);
$method2->hasReturnType()->willReturn(false);
$method3->hasReturnType()->willReturn(false);
}
$classNode = $this->reflect($class, array());
$classNode->shouldBeAnInstanceOf('Prophecy\Doubler\Generator\Node\ClassNode');
$classNode->getParentClass()->shouldReturn('Custom\ClassName');
......@@ -86,6 +92,10 @@ function it_changes_argument_names_if_they_are_varying($class, $method, $paramet
$method->isStatic()->willReturn(false);
$method->returnsReference()->willReturn(false);
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$method->hasReturnType()->willReturn(false);
}
$parameter->getName()->willReturn('...');
$parameter->isDefaultValueAvailable()->willReturn(true);
$parameter->getDefaultValue()->willReturn(null);
......@@ -120,6 +130,9 @@ function it_reflects_protected_abstract_methods($class, $method)
$method->getName()->willReturn('innerDetail');
$method->returnsReference()->willReturn(false);
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$method->hasReturnType()->willReturn(false);
}
$classNode = $this->reflect($class, array());
$classNode->shouldBeAnInstanceOf('Prophecy\Doubler\Generator\Node\ClassNode');
......@@ -149,6 +162,10 @@ function it_reflects_public_static_methods($class, $method)
$method->getName()->willReturn('innerDetail');
$method->returnsReference()->willReturn(false);
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$method->hasReturnType()->willReturn(false);
}
$classNode = $this->reflect($class, array());
$classNode->shouldBeAnInstanceOf('Prophecy\Doubler\Generator\Node\ClassNode');
$classNode->getParentClass()->shouldReturn('Custom\ClassName');
......@@ -185,6 +202,10 @@ function it_properly_reads_methods_arguments_with_types(
$method->returnsReference()->willReturn(false);
$method->getParameters()->willReturn(array($param1, $param2, $param3));
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$method->hasReturnType()->willReturn(false);
}
$param1->getName()->willReturn('arg_1');
$param1->isArray()->willReturn(true);
$param1->getClass()->willReturn(null);
......@@ -258,12 +279,21 @@ function it_marks_required_args_without_types_as_not_optional(
$method->returnsReference()->willReturn(false);
$method->getParameters()->willReturn(array($param1));
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$method->hasReturnType()->willReturn(false);
}
$param1->getName()->willReturn('arg_1');
$param1->isArray()->willReturn(false);
if (version_compare(PHP_VERSION, '5.4', '>=')) {
$param1->isCallable()->willReturn(false);
}
$param1->getClass()->willReturn(null);
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$param1->hasType()->willReturn(false);
}
$param1->isDefaultValueAvailable()->willReturn(false);
$param1->isOptional()->willReturn(false);
$param1->isPassedByReference()->willReturn(false);
......@@ -303,6 +333,10 @@ function it_marks_passed_by_reference_args_as_passed_by_reference(
$method->returnsReference()->willReturn(false);
$method->getParameters()->willReturn(array($param1, $param2));
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$method->hasReturnType()->willReturn(false);
}
$param1->getName()->willReturn('arg_1');
$param1->isArray()->willReturn(false);
if (version_compare(PHP_VERSION, '5.4', '>=')) {
......@@ -312,6 +346,11 @@ function it_marks_passed_by_reference_args_as_passed_by_reference(
$param1->isDefaultValueAvailable()->willReturn(false);
$param1->isOptional()->willReturn(true);
$param1->isPassedByReference()->willReturn(true);
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$param1->hasType()->willReturn(false);
}
$param1->allowsNull()->willReturn(false);
if (defined('HHVM_VERSION')) {
$param1->getTypehintText()->willReturn(null);
......@@ -323,6 +362,11 @@ function it_marks_passed_by_reference_args_as_passed_by_reference(
$param2->isDefaultValueAvailable()->willReturn(false);
$param2->isOptional()->willReturn(false);
$param2->isPassedByReference()->willReturn(false);
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$param2->hasType()->willReturn(false);
}
$param2->allowsNull()->willReturn(false);
$typeHint->getName()->willReturn('ArrayAccess');
......@@ -418,6 +462,12 @@ function it_reflects_all_interfaces_methods(
$method2->getParameters()->willReturn(array());
$method3->getParameters()->willReturn(array());
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$method1->hasReturnType()->willReturn(false);
$method2->hasReturnType()->willReturn(false);
$method3->hasReturnType()->willReturn(false);
}
$classNode = $this->reflect(null, array($interface1, $interface2));
$classNode->shouldBeAnInstanceOf('Prophecy\Doubler\Generator\Node\ClassNode');
......@@ -472,6 +522,12 @@ function it_ignores_virtually_private_methods($class, $method1, $method2, $metho
$method2->getParameters()->willReturn(array());
$method3->getParameters()->willReturn(array());
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$method1->hasReturnType()->willReturn(false);
$method2->hasReturnType()->willReturn(false);
$method3->hasReturnType()->willReturn(false);
}
$classNode = $this->reflect($class, array());
$methodNodes = $classNode->getMethods();
$methodNodes->shouldHaveCount(2);
......
......@@ -120,4 +120,19 @@ function it_supports_adding_arguments($argument1, $argument2)
$this->getArguments()->shouldReturn(array($argument1, $argument2));
}
function it_does_not_have_return_type_by_default()
{
$this->hasReturnType()->shouldReturn(false);
}
function it_setReturnType_sets_return_type()
{
$returnType = 'string';
$this->setReturnType($returnType);
$this->hasReturnType()->shouldReturn(true);
$this->getReturnType()->shouldReturn($returnType);
}
}
......@@ -4,6 +4,11 @@
use PhpSpec\ObjectBehavior;
class ClassWithFinalMethod
{
final public function finalMethod() {}
}
class MethodProphecySpec extends ObjectBehavior
{
/**
......@@ -29,7 +34,10 @@ function its_constructor_throws_MethodNotFoundException_for_unexisting_method($o
);
}
function its_constructor_throws_MethodProphecyException_for_final_methods($objectProphecy, ClassWithFinalMethod $subject)
/**
* @param ClassWithFinalMethod $subject
*/
function its_constructor_throws_MethodProphecyException_for_final_methods($objectProphecy, $subject)
{
$objectProphecy->reveal()->willReturn($subject);
......@@ -374,8 +382,3 @@ function its_withArguments_throws_exception_if_wrong_arguments_provided()
$this->shouldThrow('Prophecy\Exception\InvalidArgumentException')->duringWithArguments(42);
}
}
class ClassWithFinalMethod
{
final public function finalMethod() {}
}
......@@ -286,6 +286,20 @@ function it_returns_new_MethodProphecy_for_different_signatures($doubler, $refle
$methodProphecy2->shouldNotBe($methodProphecy1);
}
/**
* @param \Prophecy\Doubler\Doubler $doubler
* @param \Prophecy\Prophecy\ProphecySubjectInterface $reflection
*/
function it_returns_new_MethodProphecy_for_all_callback_signatures($doubler, $reflection)
{
$doubler->double(Argument::any())->willReturn($reflection);
$this->addMethodProphecy($methodProphecy1 = $this->getProphecy(function(){}));
$methodProphecy2 = $this->getProphecy(function(){});
$methodProphecy2->shouldNotBe($methodProphecy1);
}
}
class ObjectProphecySpecFixtureA
......
......@@ -11,8 +11,8 @@
namespace Prophecy\Argument\Token;
use SebastianBergmann\Comparator\Factory as ComparatorFactory;
use SebastianBergmann\Comparator\ComparisonFailure;
use Prophecy\Comparator\Factory as ComparatorFactory;
use Prophecy\Util\StringUtil;
/**
......@@ -62,7 +62,7 @@ public function scoreArgument($argument)
} catch (ComparisonFailure $failure) {}
}
// If either one is an object it should castable to a string
// If either one is an object it should be castable to a string
if (is_object($argument) xor is_object($this->value)) {
if (is_object($argument) && !method_exists($argument, '__toString')) {
return false;
......
......@@ -11,8 +11,8 @@
namespace Prophecy\Argument\Token;
use SebastianBergmann\Comparator\Factory as ComparatorFactory;
use SebastianBergmann\Comparator\ComparisonFailure;
use Prophecy\Comparator\Factory as ComparatorFactory;
use Prophecy\Util\StringUtil;
/**
......
<?php
/*
* This file is part of the Prophecy.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
* Marcello Duarte <marcello.duarte@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Prophecy\Comparator;
use SebastianBergmann\Comparator\Comparator;
use SebastianBergmann\Comparator\ComparisonFailure;
/**
* Closure comparator.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
final class ClosureComparator extends Comparator
{
public function accepts($expected, $actual)
{
return is_object($expected) && $expected instanceof \Closure
&& is_object($actual) && $actual instanceof \Closure;
}
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
{
throw new ComparisonFailure(
$expected,
$actual,
// we don't need a diff
'',
'',
false,
'all closures are born different'
);
}
}
<?php
/*
* This file is part of the Prophecy.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
* Marcello Duarte <marcello.duarte@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Prophecy\Comparator;
use SebastianBergmann\Comparator\Factory as BaseFactory;
/**
* Prophecy comparator factory.