LimeTester.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /*
  3. * This file is part of the Lime framework.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. * (c) Bernhard Schussek <bernhard.schussek@symfony-project.com>
  7. *
  8. * This source file is subject to the MIT license that is bundled
  9. * with this source code in the file LICENSE.
  10. */
  11. abstract class LimeTester implements LimeTesterInterface
  12. {
  13. protected static
  14. $factory = null;
  15. protected
  16. $value = null,
  17. $type = null;
  18. public static function create($value)
  19. {
  20. return self::getFactory()->create($value);
  21. }
  22. public static function register($type, $tester)
  23. {
  24. return self::getFactory()->register($type, $tester);
  25. }
  26. public static function unregister($type)
  27. {
  28. return self::getFactory()->unregister($type);
  29. }
  30. private static function getFactory()
  31. {
  32. if (is_null(self::$factory))
  33. {
  34. self::$factory = new LimeTesterFactory();
  35. }
  36. return self::$factory;
  37. }
  38. public function __construct($value)
  39. {
  40. $this->value = $value;
  41. }
  42. public function is(LimeTesterInterface $expected)
  43. {
  44. throw new LimeAssertionFailedException($this, $expected);
  45. }
  46. public function isnt(LimeTesterInterface $expected)
  47. {
  48. throw new LimeAssertionFailedException($this, $expected);
  49. }
  50. public function same(LimeTesterInterface $expected)
  51. {
  52. throw new LimeAssertionFailedException($this, $expected);
  53. }
  54. public function isntSame(LimeTesterInterface $expected)
  55. {
  56. throw new LimeAssertionFailedException($this, $expected);
  57. }
  58. public function like(LimeTesterInterface $expected)
  59. {
  60. throw new LimeAssertionFailedException($this, $expected);
  61. }
  62. public function unlike(LimeTesterInterface $expected)
  63. {
  64. throw new LimeAssertionFailedException($this, $expected);
  65. }
  66. public function greaterThan(LimeTesterInterface $expected)
  67. {
  68. throw new LimeAssertionFailedException($this, $expected);
  69. }
  70. public function greaterThanEqual(LimeTesterInterface $expected)
  71. {
  72. throw new LimeAssertionFailedException($this, $expected);
  73. }
  74. public function lessThan(LimeTesterInterface $expected)
  75. {
  76. throw new LimeAssertionFailedException($this, $expected);
  77. }
  78. public function lessThanEqual(LimeTesterInterface $expected)
  79. {
  80. throw new LimeAssertionFailedException($this, $expected);
  81. }
  82. public function contains(LimeTesterInterface $expected)
  83. {
  84. throw new LimeAssertionFailedException($this, $expected);
  85. }
  86. public function containsNot(LimeTesterInterface $expected)
  87. {
  88. throw new LimeAssertionFailedException($this, $expected);
  89. }
  90. }