|
| 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 | + |
0 commit comments