Yaffs site version 1.1
[yaffs-website] / vendor / phpunit / phpunit / tests / Util / RegexTest.php
1 <?php
2 /*
3  * This file is part of PHPUnit.
4  *
5  * (c) Sebastian Bergmann <sebastian@phpunit.de>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * @since      Class available since Release 4.2.0
13  */
14 class Util_RegexTest extends PHPUnit_Framework_TestCase
15 {
16     public function validRegexpProvider()
17     {
18         return array(
19           array('#valid regexp#', 'valid regexp', 1),
20           array(';val.*xp;', 'valid regexp', 1),
21           array('/val.*xp/i', 'VALID REGEXP', 1),
22           array('/a val.*p/','valid regexp', 0),
23         );
24     }
25
26     public function invalidRegexpProvider()
27     {
28         return array(
29           array('valid regexp', 'valid regexp'),
30           array(';val.*xp', 'valid regexp'),
31           array('val.*xp/i', 'VALID REGEXP'),
32         );
33     }
34
35     /**
36      * @dataProvider validRegexpProvider
37      * @covers       PHPUnit_Util_Regex::pregMatchSafe
38      */
39     public function testValidRegex($pattern, $subject, $return)
40     {
41         $this->assertEquals($return, PHPUnit_Util_Regex::pregMatchSafe($pattern, $subject));
42     }
43
44     /**
45      * @dataProvider invalidRegexpProvider
46      * @covers       PHPUnit_Util_Regex::pregMatchSafe
47      */
48     public function testInvalidRegex($pattern, $subject)
49     {
50         $this->assertFalse(PHPUnit_Util_Regex::pregMatchSafe($pattern, $subject));
51     }
52 }