123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- class Yay
- {
-
-
-
- private static $CLASSPATH = '.';
-
-
-
-
-
- public static function expectations()
- {
- return new Yay_Expectations();
- }
-
-
-
-
-
- public static function optional($value = null)
- {
- return new Yay_Matchers_OptionalMatcher($value);
- }
-
-
-
- public static function any($type = null)
- {
- return new Yay_Matchers_AnyMatcher($type, true);
- }
-
-
-
- public static function none($type = null)
- {
- return new Yay_Matchers_AnyMatcher($type, false);
- }
-
-
-
- public static function identical($value)
- {
- return new Yay_Matchers_IdenticalMatcher($value, true);
- }
-
-
-
- public static function notIdentical($value)
- {
- return new Yay_Matchers_IdenticalMatcher($value, false);
- }
-
-
-
- public static function equal($value)
- {
- return new Yay_Matchers_EqualMatcher($value, true);
- }
-
-
-
- public static function notEqual($value)
- {
- return new Yay_Matchers_EqualMatcher($value, false);
- }
-
-
-
- public static function pattern($pattern)
- {
- return new Yay_Matchers_PatternMatcher($pattern, true);
- }
-
-
-
- public static function noPattern($pattern)
- {
- return new Yay_Matchers_PatternMatcher($pattern, false);
- }
-
-
-
- public static function reference(&$ref)
- {
- return new Yay_Matchers_ReferenceMatcher($ref, true);
- }
-
-
-
- public static function noReference(&$ref)
- {
- return new Yay_Matchers_ReferenceMatcher($ref, false);
- }
-
-
-
- public static function bounds($lower, $upper)
- {
- return new Yay_Matchers_BoundsMatcher($lower, $upper, true);
- }
-
-
-
- public static function outside($lower, $upper)
- {
- return new Yay_Matchers_BoundsMatcher($lower, $upper, false);
- }
-
-
-
-
-
- public static function returnValue($value)
- {
- return new Yay_Actions_ReturnValueAction($value);
- }
-
-
-
- public static function returnReference(&$ref)
- {
- return new Yay_Actions_ReturnReferenceAction($ref);
- }
-
-
-
- public static function throwException(Exception $e)
- {
- return new Yay_Actions_ThrowAction($e);
- }
-
-
-
- public static function call($callback)
- {
- return new Yay_Actions_CallbackAction($callback);
- }
-
-
-
- public static function setClassPath($path)
- {
- self::$CLASSPATH = $path;
- }
-
-
-
- public static function autoload($class)
- {
- if (substr($class, 0, 3) != 'Yay')
- {
- return;
- }
- $file = str_replace('_', '/', $class) . '.php';
- $path = self::$CLASSPATH . '/' . $file;
- if (is_file($path))
- {
- require_once $path;
- }
- }
-
- }
|