Skip to content

Commit ca1ec87

Browse files
Merge pull request #10 from jakzal/wrapper-fix
Provided a custom implementation of Wrapper
2 parents d28fd0a + b44a4cb commit ca1ec87

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

Bossa/PhpSpec/Expect/Wrapper.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace Bossa\PhpSpec\Expect;
4+
5+
use PhpSpec\Exception\ExceptionFactory;
6+
use PhpSpec\Runner\MatcherManager;
7+
use PhpSpec\Formatter\Presenter\PresenterInterface;
8+
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
9+
use PhpSpec\Loader\Node\ExampleNode;
10+
11+
use PhpSpec\Wrapper\Subject\WrappedObject;
12+
use PhpSpec\Wrapper\Subject\Caller;
13+
use PhpSpec\Wrapper\Subject\SubjectWithArrayAccess;
14+
use PhpSpec\Wrapper\Subject\ExpectationFactory;
15+
use PhpSpec\Wrapper\Wrapper as BaseWrapper;
16+
17+
class Wrapper extends BaseWrapper
18+
{
19+
private $matchers;
20+
private $presenter;
21+
private $dispatcher;
22+
private $example;
23+
24+
public function __construct(MatcherManager $matchers, PresenterInterface $presenter,
25+
EventDispatcherInterface $dispatcher, ExampleNode $example)
26+
{
27+
$this->matchers = $matchers;
28+
$this->presenter = $presenter;
29+
$this->dispatcher = $dispatcher;
30+
$this->example = $example;
31+
}
32+
33+
public function wrap($value = null)
34+
{
35+
$exceptionFactory = new ExceptionFactory($this->presenter);
36+
$wrappedObject = new WrappedObject($value, $this->presenter);
37+
$caller = new Caller($wrappedObject, $this->example, $this->dispatcher, $exceptionFactory, $this);
38+
$arrayAccess = new SubjectWithArrayAccess($caller, $this->presenter, $this->dispatcher);
39+
$expectationFactory = new ExpectationFactory($this->example, $this->dispatcher, $this->matchers);
40+
41+
return new Subject(
42+
$value, $this, $wrappedObject, $caller, $arrayAccess, $expectationFactory
43+
);
44+
}
45+
}
46+

expect.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
}
1616

1717
use Bossa\PhpSpec\Expect\Subject;
18+
use Bossa\PhpSpec\Expect\Wrapper;
1819
use PhpSpec\Exception\ExceptionFactory;
1920
use PhpSpec\Formatter\Presenter\Differ\Differ;
2021
use PhpSpec\Formatter\Presenter\TaggedPresenter;
@@ -40,10 +41,10 @@
4041
use PhpSpec\Wrapper\Subject\SubjectWithArrayAccess;
4142
use PhpSpec\Wrapper\Subject\WrappedObject;
4243
use PhpSpec\Wrapper\Unwrapper;
43-
use PhpSpec\Wrapper\Wrapper;
4444
use Symfony\Component\EventDispatcher\EventDispatcher;
4545

4646
require_once 'Bossa/PhpSpec/Expect/Subject.php';
47+
require_once 'Bossa/PhpSpec/Expect/Wrapper.php';
4748

4849
if (!function_exists('expect')) {
4950
function expect($sus)

0 commit comments

Comments
 (0)