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
11class Util_RegexTest extends PHPUnit_Framework_TestCase
12{
13    public function validRegexpProvider()
14    {
15        return [
16          ['#valid regexp#', 'valid regexp', 1],
17          [';val.*xp;', 'valid regexp', 1],
18          ['/val.*xp/i', 'VALID REGEXP', 1],
19          ['/a val.*p/','valid regexp', 0],
20        ];
21    }
22
23    public function invalidRegexpProvider()
24    {
25        return [
26          ['valid regexp', 'valid regexp'],
27          [';val.*xp', 'valid regexp'],
28          ['val.*xp/i', 'VALID REGEXP'],
29        ];
30    }
31
32    /**
33     * @dataProvider validRegexpProvider
34     */
35    public function testValidRegex($pattern, $subject, $return)
36    {
37        $this->assertEquals($return, PHPUnit_Util_Regex::pregMatchSafe($pattern, $subject));
38    }
39
40    /**
41     * @dataProvider invalidRegexpProvider
42     */
43    public function testInvalidRegex($pattern, $subject)
44    {
45        $this->assertFalse(PHPUnit_Util_Regex::pregMatchSafe($pattern, $subject));
46    }
47}
48