Skip to content

Commit 4201112

Browse files
committed
started upgrading to phpspec4
1 parent f9d5753 commit 4201112

8 files changed

+33
-30
lines changed

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
],
1414
"license": "MIT",
1515
"require": {
16-
"phpspec/phpspec": "^4.3.0",
17-
"php-mock/php-mock-prophecy": "0.0.2"
16+
"php-mock/php-mock-prophecy": "0.0.2",
17+
"phpspec/phpspec": "^4.3"
1818
},
1919
"autoload": {
2020
"psr-4": {

phpspec.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ suites:
44
psr4_prefix: PhpSpec\PhpMock
55

66
extensions:
7-
- PhpSpec\PhpMock\Extension\PhpMockExtension
7+
PhpSpec\PhpMock\Extension\PhpMockExtension: ~

spec/Extension/PhpMockExtensionSpec.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ class PhpMockExtensionSpec extends ObjectBehavior
1414
function it_is_initializable()
1515
{
1616
$this->shouldHaveType('PhpSpec\PhpMock\Extension\PhpMockExtension');
17-
$this->shouldImplement('PhpSpec\Extension\ExtensionInterface');
17+
$this->shouldImplement('PhpSpec\Extension');
1818
}
1919

2020
function it_loads_the_collaborator_maintainer_into_the_container(ServiceContainer $container)
2121
{
22-
$container->set('runner.maintainers.function_collaborator', Argument::type('Callable'))
22+
$container->define('runner.maintainers.function_collaborator', Argument::type('Callable'))
2323
->shouldBeCalled();
2424
$this->load($container);
2525
}

spec/Runner/Maintainer/FunctionCollaboratorMaintainerSpec.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33
namespace spec\PhpSpec\PhpMock\Runner\Maintainer;
44

5+
use PhpSpec\Locator\Resource;
56
use PhpSpec\ObjectBehavior;
7+
use PhpSpec\Specification;
68
use Prophecy\Argument;
79
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
810
use PhpSpec\Loader\Node\ExampleNode;
9-
use PhpSpec\SpecificationInterface;
1011
use PhpSpec\Runner\MatcherManager;
1112
use PhpSpec\Runner\CollaboratorManager;
1213
use PhpSpec\Loader\Node\SpecificationNode;
13-
use PhpSpec\Locator\ResourceInterface;
1414

1515
class FunctionCollaboratorMaintainerSpec extends ObjectBehavior
1616
{
1717
function it_is_initializable()
1818
{
1919
$this->shouldHaveType('PhpSpec\PhpMock\Runner\Maintainer\FunctionCollaboratorMaintainer');
20-
$this->shouldImplement('PhpSpec\Runner\Maintainer\MaintainerInterface');
20+
$this->shouldImplement('PhpSpec\Runner\Maintainer\Maintainer');
2121
}
2222

2323
function let(
@@ -28,11 +28,11 @@ function let(
2828

2929
function it_prepares_and_tears_down_an_example_with_a_function_prophecy_collaborator(
3030
ExampleNode $example,
31-
SpecificationInterface $context,
31+
Specification $context,
3232
MatcherManager $matchers,
3333
CollaboratorManager $collaborators,
3434
SpecificationNode $specification,
35-
ResourceInterface $resource
35+
Resource $resource
3636
) {
3737
$collaborators->has('functions')->willReturn(false);
3838
$collaborators->set('functions', Argument::any())->shouldNotBeCalled();
@@ -41,6 +41,7 @@ function it_prepares_and_tears_down_an_example_with_a_function_prophecy_collabor
4141

4242
$collaborators->has('functions')->willReturn(true);
4343
$example->getSpecification()->willReturn($specification);
44+
$resource->getSrcNamespace()->willReturn('');
4445
$specification->getResource()->willReturn($resource);
4546
$collaborators->set('functions', Argument::any())->shouldBeCalled();
4647
$this->prepare($example, $context, $matchers, $collaborators)->shouldReturn(true);

spec/Wrapper/FunctionCollaboratorSpec.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
use PhpSpec\ObjectBehavior;
66
use Prophecy\Argument;
7-
use PhpSpec\Locator\ResourceInterface;
7+
use PhpSpec\Locator\Resource;
88

99
class FunctionCollaboratorSpec extends ObjectBehavior
1010
{
1111

1212
function it_is_initializable()
1313
{
1414
$this->shouldHaveType('PhpSpec\PhpMock\Wrapper\FunctionCollaborator');
15-
$this->shouldImplement('PhpSpec\Wrapper\WrapperInterface');
15+
$this->shouldImplement('PhpSpec\Wrapper\ObjectWrapper');
1616
}
1717

18-
function let(ResourceInterface $resource) {
18+
function let(Resource $resource) {
1919
$this->beConstructedWith($resource);
2020
$resource->getSrcNamespace()->willReturn('TestNamespace');
2121
}

src/Extension/PhpMockExtension.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@
22

33
namespace PhpSpec\PhpMock\Extension;
44

5-
use PhpSpec\Extension\ExtensionInterface;
5+
use PhpSpec\Extension;
66
use PhpSpec\ServiceContainer;
7+
use PhpSpec\ServiceContainer\IndexedServiceContainer;
78
use PhpSpec\PhpMock\Runner\Maintainer\FunctionCollaboratorMaintainer;
89
use Prophecy\Prophet;
910
use phpmock\MockRegistry;
1011

11-
class PhpMockExtension implements ExtensionInterface
12+
class PhpMockExtension implements Extension
1213
{
1314
/**
1415
* @param ServiceContainer $container
1516
*/
16-
public function load(ServiceContainer $container)
17+
public function load(ServiceContainer $container, array $params = [])
1718
{
18-
$container->set('runner.maintainers.function_collaborator', [$this, 'createMaintainer']);
19+
$container->define('runner.maintainers.function_collaborator', [$this, 'createMaintainer']);
1920
}
2021

21-
public function createMaintainer(ServiceContainer $container)
22+
public function createMaintainer(IndexedServiceContainer $container)
2223
{
2324
return new FunctionCollaboratorMaintainer(
2425
$container->get('event_dispatcher'),

src/Runner/Maintainer/FunctionCollaboratorMaintainer.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
namespace PhpSpec\PhpMock\Runner\Maintainer;
44

5+
use PhpSpec\Runner\Maintainer\Maintainer;
56
use PhpSpec\Runner\MatcherManager;
67
use PhpSpec\Runner\CollaboratorManager;
78
use PhpSpec\Loader\Node\ExampleNode;
8-
use PhpSpec\SpecificationInterface;
9+
use PhpSpec\Specification;
910
use PhpSpec\PhpMock\Wrapper\FunctionCollaborator;
1011
use Symfony\Component\EventDispatcher\EventDispatcherInterface as Dispatcher;
1112
use PhpSpec\Wrapper\Unwrapper;
1213
use PhpSpec\Loader\Transformer\TypeHintIndex;
13-
use PhpSpec\Runner\Maintainer\MaintainerInterface;
1414
use PhpSpec\Event\MethodCallEvent;
1515

16-
class FunctionCollaboratorMaintainer implements MaintainerInterface
16+
class FunctionCollaboratorMaintainer implements Maintainer
1717
{
1818
const FUNCTIONS_PARAMETER = 'functions';
1919

@@ -44,13 +44,14 @@ public function __construct(Dispatcher $dispatcher)
4444
*/
4545
public function prepare(
4646
ExampleNode $example,
47-
SpecificationInterface $context,
47+
Specification $context,
4848
MatcherManager $matchers,
4949
CollaboratorManager $collaborators
5050
) {
5151
if (!$collaborators->has(self::FUNCTIONS_PARAMETER)) return false;
5252
$this->collaborator = new FunctionCollaborator($example->getSpecification()->getResource());
5353
$collaborators->set(self::FUNCTIONS_PARAMETER, $this->collaborator);
54+
5455
$this->dispatcher->addListener('beforeMethodCall', [$this, 'revealFunctionProphecy']);
5556
return true;
5657
}
@@ -63,7 +64,7 @@ public function prepare(
6364
*/
6465
public function teardown(
6566
ExampleNode $example,
66-
SpecificationInterface $context,
67+
Specification $context,
6768
MatcherManager $matchers,
6869
CollaboratorManager $collaborators
6970
) {
@@ -83,15 +84,15 @@ public function revealFunctionProphecy(MethodCallEvent $event)
8384
*
8485
* @return bool
8586
*/
86-
public function supports(ExampleNode $example)
87+
public function supports(ExampleNode $example): bool
8788
{
8889
return true;
8990
}
9091

9192
/**
9293
* @return int
9394
*/
94-
public function getPriority()
95+
public function getPriority(): int
9596
{
9697
return 40;
9798
}

src/Wrapper/FunctionCollaborator.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace PhpSpec\PhpMock\Wrapper;
44

5-
use PhpSpec\Wrapper\WrapperInterface;
5+
use PhpSpec\Wrapper\ObjectWrapper;
66
use phpmock\prophecy\PHPProphet;
77
use Prophecy\Prophecy\ProphecyInterface;
8-
use PhpSpec\Locator\ResourceInterface;
8+
use PhpSpec\Locator\Resource;
99

10-
class FunctionCollaborator implements WrapperInterface
10+
class FunctionCollaborator implements ObjectWrapper
1111
{
1212
/**
1313
* @var ProphecyInterface
@@ -20,9 +20,9 @@ class FunctionCollaborator implements WrapperInterface
2020
protected $function_prophet;
2121

2222
/**
23-
* @param ResourceInterface $resource
23+
* @param Resource $resource
2424
*/
25-
public function __construct(ResourceInterface $resource)
25+
public function __construct(Resource $resource)
2626
{
2727
$this->function_prophet = new PHPProphet();
2828
$this->prophecy = $this->function_prophet->prophesize($resource->getSrcNamespace());

0 commit comments

Comments
 (0)