|
| 1 | +<?php |
| 2 | +namespace JsonMatcher\Tests; |
| 3 | + |
| 4 | +use JsonMatcher\Matcher\TypeMatcher; |
| 5 | + |
| 6 | +class TypeMatcherTest extends \PHPUnit_Framework_TestCase |
| 7 | +{ |
| 8 | + public function test_can_match() |
| 9 | + { |
| 10 | + $matcher = new TypeMatcher(); |
| 11 | + $this->assertTrue($matcher->canMatch('@integer@')); |
| 12 | + $this->assertTrue($matcher->canMatch('@string@')); |
| 13 | + $this->assertTrue($matcher->canMatch('@boolean@')); |
| 14 | + $this->assertFalse($matcher->canMatch('@integer')); |
| 15 | + $this->assertFalse($matcher->canMatch("qweqwe")); |
| 16 | + $this->assertFalse($matcher->canMatch(1)); |
| 17 | + $this->assertFalse($matcher->canMatch("@string")); |
| 18 | + } |
| 19 | + |
| 20 | + public function test_type_match() |
| 21 | + { |
| 22 | + $matcher = new TypeMatcher(); |
| 23 | + $this->assertTrue($matcher->match(false, '@boolean@')); |
| 24 | + $this->assertTrue($matcher->match("Norbert", '@string@')); |
| 25 | + $this->assertTrue($matcher->match(1, '@integer@')); |
| 26 | + $this->assertTrue($matcher->match(1.1, '@double@')); |
| 27 | + |
| 28 | + $this->assertFalse($matcher->match("test", '@boolean@')); |
| 29 | + $this->assertFalse($matcher->match(new \stdClass(), '@string@')); |
| 30 | + $this->assertFalse($matcher->match(1.1, '@integer@')); |
| 31 | + $this->assertFalse($matcher->match(false, '@double@')); |
| 32 | + } |
| 33 | +} |
0 commit comments