MethodMatcherTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Elgg;
  3. class MethodMatcherTest extends \PHPUnit_Framework_TestCase {
  4. public function testMatchesStrings() {
  5. $matcher = new MethodMatcher('stdClass', 'bar');
  6. $this->assertTrue($matcher->matches('stdClass::bar'));
  7. $this->assertTrue($matcher->matches('\STDClass::BAR'));
  8. $this->assertFalse($matcher->matches('foooo::bar'));
  9. $this->assertFalse($matcher->matches('foo\bar'));
  10. }
  11. public function testMatchesStaticArrays() {
  12. $matcher = new MethodMatcher('stdClass', 'bar');
  13. $this->assertTrue($matcher->matches(['stdClass', 'bar']));
  14. $this->assertTrue($matcher->matches(['\STDClass', 'BAR']));
  15. $this->assertFalse($matcher->matches(['foooo', 'bar']));
  16. }
  17. public function testMatchesDynamicArrays() {
  18. $matcher = new MethodMatcher('stdClass', 'bar');
  19. $this->assertTrue($matcher->matches([new \stdClass(), 'bar']));
  20. $this->assertTrue($matcher->matches([new \stdClass(), 'BAR']));
  21. $this->assertFalse($matcher->matches([new MethodMatcherTestObject, 'bar']));
  22. }
  23. }
  24. class MethodMatcherTestObject {}