Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

Commit

Permalink
Rename stub as prophet
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelloDuarte committed Sep 11, 2012
1 parent cb2f45f commit 7e32c47
Show file tree
Hide file tree
Showing 23 changed files with 59 additions and 59 deletions.
4 changes: 2 additions & 2 deletions spec/PHPSpec2/Matcher/MatchersCollection.php
Expand Up @@ -14,7 +14,7 @@ function it_will_complain_if_no_matchers_registered()
}

/**
* @param ObjectStub $matcher mock of PHPSpec2\Matcher\MatcherInterface
* @param Prophet $matcher mock of PHPSpec2\Matcher\MatcherInterface
*/
function it_will_complain_if_matcher_is_not_found($matcher)
{
Expand All @@ -24,7 +24,7 @@ function it_will_complain_if_matcher_is_not_found($matcher)
}

/**
* @param ObjectStub $matcher mock of PHPSpec2\Matcher\MatcherInterface
* @param Prophet $matcher mock of PHPSpec2\Matcher\MatcherInterface
*/
function it_will_return_matcher_if_found($matcher)
{
Expand Down
4 changes: 2 additions & 2 deletions spec/PHPSpec2/Matcher/ObjectStateMatcher.php
Expand Up @@ -20,7 +20,7 @@ function it_throws_exception_if_checker_method_not_found()
$subject = new \ReflectionClass($this);
$this->object->supports('beSimple', $subject, array());

$this->object->shouldThrow('PHPSpec2\Exception\Stub\MethodNotFoundException')
$this->object->shouldThrow('PHPSpec2\Exception\Prophet\MethodNotFoundException')
->during('positiveMatch', array('beSimple', $subject, array()));
}

Expand Down Expand Up @@ -54,7 +54,7 @@ function it_throws_exception_if_has_checker_method_not_found()
$subject = new \ReflectionClass($this);
$this->object->supports('haveAnything', $subject, array('str'));

$this->object->shouldThrow('PHPSpec2\Exception\Stub\MethodNotFoundException')
$this->object->shouldThrow('PHPSpec2\Exception\Prophet\MethodNotFoundException')
->during('positiveMatch', array('haveAnything', $subject, array('str')));
}

Expand Down
4 changes: 2 additions & 2 deletions spec/PHPSpec2/Matcher/ThrowMatcher.php
Expand Up @@ -15,7 +15,7 @@ function it_supports_the_throw_alias_for_object_and_exception_name()
}

/**
* @param ObjectStub $subject mock of stdClass
* @param Prophet $subject mock of stdClass
*/
function it_can_specify_a_method_during_which_an_exception_should_be_throw($subject)
{
Expand All @@ -28,7 +28,7 @@ function it_can_specify_a_method_during_which_an_exception_should_be_throw($subj
}

/**
* @param ObjectStub $subject mock of stdClass
* @param Prophet $subject mock of stdClass
*/
function it_can_specify_a_method_during_which_an_exception_should_not_be_throw($subject)
{
Expand Down
2 changes: 1 addition & 1 deletion spec/PHPSpec2/Mocker/MockerFactory.php
Expand Up @@ -3,7 +3,7 @@
namespace spec\PHPSpec2\Mocker;

use PHPSpec2\Specification;
use PHPSpec2\Stub\ArgumentsResolver;
use PHPSpec2\Prophet\ArgumentsResolver;

class MockerFactory implements Specification
{
Expand Down
Expand Up @@ -4,20 +4,20 @@

use PHPSpec2\Specification;

class ObjectStub implements Specification
class Prophet implements Specification
{
function described_with($collection)
{
$collection->isAMockOf('PHPSpec2\Matcher\MatchersCollection');
$subject = new Fake;
$this->objectStub->isAnInstanceOf('PHPSpec2\Stub\ObjectStub', array(
$this->prophet->isAnInstanceOf('PHPSpec2\Prophet\Prophet', array(
$subject, $collection
));
}

function it_calls_magic_method_of_subject_if_one_exists()
{
$this->objectStub->foo('bar')->shouldReturn('bar');
$this->prophet->foo('bar')->shouldReturn('bar');
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/PHPSpec2/Console/Command/RunCommand.php
Expand Up @@ -75,7 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if ($runner->wasAborted()) {
break;
}
$runner->testSpecification($spec);
$runner->runSpecification($spec);
}

$runner->getEventDispatcher()->dispatch('afterSuite', new SuiteEvent($collector));
Expand Down
@@ -1,8 +1,8 @@
<?php

namespace PHPSpec2\Exception\Stub;
namespace PHPSpec2\Exception\Prophet;

class ClassDoesNotExistsException extends StubException
class ClassDoesNotExistsException extends ProphetException
{
private $classname;

Expand Down
@@ -1,8 +1,8 @@
<?php

namespace PHPSpec2\Exception\Stub;
namespace PHPSpec2\Exception\Prophet;

class MethodNotFoundException extends StubException
class MethodNotFoundException extends ProphetException
{
private $subject;
private $method;
Expand Down
@@ -1,8 +1,8 @@
<?php

namespace PHPSpec2\Exception\Stub;
namespace PHPSpec2\Exception\Prophet;

class PropertyNotFoundException extends StubException
class PropertyNotFoundException extends ProphetException
{
private $subject;
private $property;
Expand Down
9 changes: 9 additions & 0 deletions src/PHPSpec2/Exception/Prophet/ProphetException.php
@@ -0,0 +1,9 @@
<?php

namespace PHPSpec2\Exception\Prophet;

use PHPSpec2\Exception\Exception;

class ProphetException extends Exception
{
}
9 changes: 0 additions & 9 deletions src/PHPSpec2/Exception/Stub/StubException.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/PHPSpec2/Matcher/ObjectStateMatcher.php
Expand Up @@ -2,7 +2,7 @@

namespace PHPSpec2\Matcher;

use PHPSpec2\Exception\Stub\MethodNotFoundException;
use PHPSpec2\Exception\Prophet\MethodNotFoundException;
use PHPSpec2\Exception\Example\FailureException;
use PHPSpec2\Formatter\Representer\RepresenterInterface;
use PHPSpec2\Formatter\Representer\BasicRepresenter;
Expand Down
2 changes: 1 addition & 1 deletion src/PHPSpec2/Mocker/MockProxyInterface.php
Expand Up @@ -2,7 +2,7 @@

namespace PHPSpec2\Mocker;

use PHPSpec2\Stub\ArgumentsResolver;
use PHPSpec2\Prophet\ArgumentsResolver;

interface MockProxyInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/PHPSpec2/Mocker/Mockery/ExpectationProxy.php
Expand Up @@ -2,7 +2,7 @@

namespace PHPSpec2\Mocker\Mockery;

use PHPSpec2\Stub\ArgumentsResolver;
use PHPSpec2\Prophet\ArgumentsResolver;

class ExpectationProxy
{
Expand Down
2 changes: 1 addition & 1 deletion src/PHPSpec2/Mocker/Mockery/MockProxy.php
Expand Up @@ -5,7 +5,7 @@
use Mockery;

use PHPSpec2\Mocker\MockProxyInterface;
use PHPSpec2\Stub\ArgumentsResolver;
use PHPSpec2\Prophet\ArgumentsResolver;

class MockProxy implements MockProxyInterface
{
Expand Down
@@ -1,6 +1,6 @@
<?php

namespace PHPSpec2\Stub;
namespace PHPSpec2\Prophet;

use PHPSpec2\Mocker\MockProxyInterface;

Expand All @@ -21,7 +21,7 @@ public function resolveSingle($argument)
return $argument;
}

if ($argument instanceof ObjectStub) {
if ($argument instanceof Prophet) {
$argument = $argument->getStubSubject();
}

Expand Down
@@ -1,11 +1,11 @@
<?php

namespace PHPSpec2\Stub;
namespace PHPSpec2\Prophet;

use ReflectionClass;

use PHPSpec2\Exception\Stub\StubException;
use PHPSpec2\Exception\Stub\ClassDoesNotExistsException;
use PHPSpec2\Exception\Prophet\ProphetException;
use PHPSpec2\Exception\Prophet\ClassDoesNotExistsException;

class LazyInstance implements LazySubjectInterface
{
Expand All @@ -31,7 +31,7 @@ public function getInstance()
}

if (!is_string($this->classname)) {
throw new StubException(sprintf(
throw new ProphetException(sprintf(
'Instantiator expects class name, "%s" got', gettype($this->classname)
));
}
Expand Down
@@ -1,13 +1,13 @@
<?php

namespace PHPSpec2\Stub;
namespace PHPSpec2\Prophet;

use ReflectionClass;

use PHPSpec2\Mocker\MockerFactory;

use PHPSpec2\Exception\Stub\StubException;
use PHPSpec2\Exception\Stub\ClassDoesNotExistsException;
use PHPSpec2\Exception\Prophet\ProphetException;
use PHPSpec2\Exception\Prophet\ClassDoesNotExistsException;

class LazyMock implements LazySubjectInterface
{
Expand All @@ -28,7 +28,7 @@ public function getInstance()
}

if (!is_string($this->classOrInterface)) {
throw new StubException(sprintf(
throw new ProphetException(sprintf(
'Mock creator expects class or interface name, "%s" got',
gettype($this->classOrInterface)
));
Expand Down
@@ -1,6 +1,6 @@
<?php

namespace PHPSpec2\Stub;
namespace PHPSpec2\Prophet;

interface LazySubjectInterface
{
Expand Down
@@ -1,6 +1,6 @@
<?php

namespace PHPSpec2\Stub;
namespace PHPSpec2\Prophet;

use ReflectionMethod;
use ReflectionProperty;
Expand All @@ -9,11 +9,11 @@
use PHPSpec2\Mocker\MockerFactory;
use PHPSpec2\Mocker\MockProxyInterface;

use PHPSpec2\Exception\Stub\StubException;
use PHPSpec2\Exception\Stub\MethodNotFoundException;
use PHPSpec2\Exception\Stub\PropertyNotFoundException;
use PHPSpec2\Exception\Prophet\ProphetException;
use PHPSpec2\Exception\Prophet\MethodNotFoundException;
use PHPSpec2\Exception\Prophet\PropertyNotFoundException;

class ObjectStub
class Prophet
{
private $subject;
private $matchers;
Expand Down Expand Up @@ -52,7 +52,7 @@ public function shouldNot()
public function callOnStub($method, array $arguments = array())
{
if (null === $this->getStubSubject()) {
throw new StubException(sprintf(
throw new ProphetException(sprintf(
'Call to a member function <value>%s()</value> on a non-object.',
$method
));
Expand Down
@@ -1,9 +1,9 @@
<?php

namespace PHPSpec2\Stub\Verification;
namespace PHPSpec2\Prophet\Verification;

use PHPSpec2\Matcher\MatchersCollection;
use PHPSpec2\Stub\ArgumentsResolver;
use PHPSpec2\Prophet\ArgumentsResolver;

class Negative
{
Expand Down
@@ -1,9 +1,9 @@
<?php

namespace PHPSpec2\Stub\Verification;
namespace PHPSpec2\Prophet\Verification;

use PHPSpec2\Matcher\MatchersCollection;
use PHPSpec2\Stub\ArgumentsResolver;
use PHPSpec2\Prophet\ArgumentsResolver;

class Positive
{
Expand Down
16 changes: 8 additions & 8 deletions src/PHPSpec2/Runner.php
Expand Up @@ -9,15 +9,15 @@

use Mockery;

use PHPSpec2\Stub\ObjectStub;
use PHPSpec2\Prophet\Prophet;
use PHPSpec2\Matcher\MatchersCollection;

use PHPSpec2\Event\SpecificationEvent;
use PHPSpec2\Event\ExampleEvent;

use PHPSpec2\Exception\Example\ErrorException;
use PHPSpec2\Exception\Example\PendingException;
use PHPSpec2\Stub\LazyInstance;
use PHPSpec2\Prophet\LazyInstance;

class Runner
{
Expand All @@ -41,7 +41,7 @@ public function getEventDispatcher()
return $this->eventDispatcher;
}

public function testSpecification(ReflectionClass $spec)
public function runSpecification(ReflectionClass $spec)
{
$examples = $spec->getMethods(ReflectionMethod::IS_PUBLIC);

Expand All @@ -57,7 +57,7 @@ public function testSpecification(ReflectionClass $spec)
foreach ($examples as $example) {
if ($this->isExampleTestable($example) &&
$this->exampleIsFiltered($example)) {
$result = max($result, $this->testExample($example));
$result = max($result, $this->runExample($example));

if ($this->failFast && $result) {
$this->wasAborted = true;
Expand All @@ -73,7 +73,7 @@ public function testSpecification(ReflectionClass $spec)
return $result;
}

public function testExample(ReflectionMethod $example)
public function runExample(ReflectionMethod $example)
{
$this->eventDispatcher->dispatch('beforeExample', new ExampleEvent($example));

Expand All @@ -86,7 +86,7 @@ public function testExample(ReflectionMethod $example)
$className = substr($spec->getName(), (int)strrpos($spec->getName(), '\\') + 1);
$className = strtolower($className[0]) . substr($className, 1);

$stub = new ObjectStub($subject, clone $this->matchers);
$stub = new Prophet($subject, clone $this->matchers);
$instance->$className = $instance->object = $stub;

$stubs = $this->getStubsForExample($instance, $example);
Expand Down Expand Up @@ -177,7 +177,7 @@ private function mergeStubsFromMethod(array $stubs, ReflectionMethod $method)

foreach ($method->getParameters() as $parameter) {
if (!isset($stubs[$parameter->getName()])) {
$stubs[$parameter->getName()] = new ObjectStub(null, clone $this->matchers);
$stubs[$parameter->getName()] = new Prophet(null, clone $this->matchers);
}
}

Expand All @@ -195,7 +195,7 @@ private function mergeStubsFromDocComment(array $stubs, $comment)

if (preg_match('#^@param(?: *[^ ]*)? *\$([^ ]*) *mock of (.*)$#', $line, $match)) {
if (!isset($stubs[$match[1]])) {
$stubs[$match[1]] = new ObjectStub(null, clone $this->matchers);
$stubs[$match[1]] = new Prophet(null, clone $this->matchers);
$stubs[$match[1]]->isAMockOf($match[2]);
}
}
Expand Down

0 comments on commit 7e32c47

Please sign in to comment.