This repository has been archived by the owner on Mar 24, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented working proof of concept
- Loading branch information
Showing
15 changed files
with
387 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
guard 'ctags-composer', :src_path => ["src"], :vendor_path => ["vendor"] do | ||
watch(/^(src|tests)\/.*\.php$/) | ||
watch('composer.lock') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Spec\PHPSpec\PHPSpec2; | ||
|
||
use PHPSpec\PHPSpec2\SpecificationInterface; | ||
|
||
class Stub implements SpecificationInterface | ||
{ | ||
public function described_with($stub) | ||
{ | ||
$stub->isAnInstanceOf('PHPSpec\PHPSpec2\Stub'); | ||
} | ||
|
||
public function registers_matcher_if_it_has_aliases($stub, $matcher) | ||
{ | ||
$matcher->isAMockOf('PHPSpec\PHPSpec2\Matcher\MatcherInterface'); | ||
$matcher->getAliases()->should_return(array('should_be_equal')); | ||
|
||
$stub->__registerMatcher($matcher); | ||
$stub->__getMatchers()->should_contain(1); | ||
} | ||
|
||
public function does_not_registers_matcher_if_it_has_no_aliases($stub, $matcher) | ||
{ | ||
$matcher->isAMockOf('PHPSpec\PHPSpec2\Matcher\MatcherInterface'); | ||
$matcher->getAliases()->should_return(array()); | ||
|
||
$stub->__registerMatcher($matcher); | ||
$stub->__getMatchers()->should_contain(0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/PHPSpec/PHPSpec2/Exception/ClassDoesNotExistsException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace PHPSpec\PHPSpec2\Exception; | ||
|
||
class ClassDoesNotExistsException extends StubException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace PHPSpec\PHPSpec2\Exception; | ||
|
||
class Exception extends \Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace PHPSpec\PHPSpec2\Exception\Matcher; | ||
|
||
use PHPSpec\PHPSpec2\Exception\Exception; | ||
|
||
class MatcherException extends Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace PHPSpec\PHPSpec2\Exception; | ||
|
||
class MethodNotFoundException extends StubException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace PHPSpec\PHPSpec2\Exception; | ||
|
||
class PropertyNotFoundException extends StubException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace PHPSpec\PHPSpec2\Exception; | ||
|
||
class StubException extends Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace PHPSpec\PHPSpec2\Matcher; | ||
|
||
use PHPSpec\PHPSpec2\Stub; | ||
|
||
interface MatcherInterface | ||
{ | ||
public function getAliases(); | ||
public function match(Stub $stub, array $arguments); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace PHPSpec\PHPSpec2\Matcher; | ||
|
||
use PHPSpec\PHPSpec2\Stub; | ||
use PHPSpec\PHPSpec2\Exception\Matcher\MatcherException; | ||
|
||
class ShouldContainMatcher implements MatcherInterface | ||
{ | ||
public function getAliases() | ||
{ | ||
return array('should_contain', 'shouldContain', 'contains'); | ||
} | ||
|
||
public function match(Stub $stub, array $arguments) | ||
{ | ||
if ($arguments[0] !== count($stub->getSubject())) { | ||
throw new MatcherException(sprintf( | ||
'Expected to have %d items in %s, got %d', | ||
$arguments[0], | ||
gettype($stub->getSubject()), | ||
count($stub->getSubject()) | ||
)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace PHPSpec\PHPSpec2\Matcher; | ||
|
||
use PHPSpec\PHPSpec2\Stub; | ||
|
||
class ShouldReturnMatcher implements MatcherInterface | ||
{ | ||
public function getAliases() | ||
{ | ||
return array('should_return', 'shouldReturn', 'returns'); | ||
} | ||
|
||
public function match(Stub $stub, array $arguments) | ||
{ | ||
return new Stub( | ||
$stub->getSubject()->andReturn($arguments[0]), | ||
$stub->getMatchers() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace PHPSpec\PHPSpec2; | ||
|
||
interface SpecificationInterface | ||
{ | ||
} |
Oops, something went wrong.