commitall
This commit is contained in:
44
hostel/vendor/phpspec/prophecy/src/Prophecy/Comparator/ClosureComparator.php
vendored
Normal file
44
hostel/vendor/phpspec/prophecy/src/Prophecy/Comparator/ClosureComparator.php
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
<?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, array &$processed = array())
|
||||
{
|
||||
if ($expected !== $actual) {
|
||||
throw new ComparisonFailure(
|
||||
$expected,
|
||||
$actual,
|
||||
// we don't need a diff
|
||||
'',
|
||||
'',
|
||||
false,
|
||||
'all closures are different if not identical'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
47
hostel/vendor/phpspec/prophecy/src/Prophecy/Comparator/Factory.php
vendored
Normal file
47
hostel/vendor/phpspec/prophecy/src/Prophecy/Comparator/Factory.php
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
<?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.
|
||||
*
|
||||
* @author Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
*/
|
||||
final class Factory extends BaseFactory
|
||||
{
|
||||
/**
|
||||
* @var Factory
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->register(new ClosureComparator());
|
||||
$this->register(new ProphecyComparator());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Factory
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (self::$instance === null) {
|
||||
self::$instance = new Factory;
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
}
|
28
hostel/vendor/phpspec/prophecy/src/Prophecy/Comparator/ProphecyComparator.php
vendored
Normal file
28
hostel/vendor/phpspec/prophecy/src/Prophecy/Comparator/ProphecyComparator.php
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
<?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 Prophecy\Prophecy\ProphecyInterface;
|
||||
use SebastianBergmann\Comparator\ObjectComparator;
|
||||
|
||||
class ProphecyComparator extends ObjectComparator
|
||||
{
|
||||
public function accepts($expected, $actual)
|
||||
{
|
||||
return is_object($expected) && is_object($actual) && $actual instanceof ProphecyInterface;
|
||||
}
|
||||
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array())
|
||||
{
|
||||
parent::assertEquals($expected, $actual->reveal(), $delta, $canonicalize, $ignoreCase, $processed);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user