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 ExceptionMessageRegExpTest extends PHPUnit_Framework_TestCase
12{
13    /**
14     * @expectedException \Exception
15     * @expectedExceptionMessageRegExp /^A polymorphic \w+ message/
16     */
17    public function testRegexMessage()
18    {
19        throw new Exception('A polymorphic exception message');
20    }
21
22    /**
23     * @expectedException \Exception
24     * @expectedExceptionMessageRegExp /^a poly[a-z]+ [a-zA-Z0-9_]+ me(s){2}age$/i
25     */
26    public function testRegexMessageExtreme()
27    {
28        throw new Exception('A polymorphic exception message');
29    }
30
31    /**
32     * @runInSeparateProcess
33     * @requires extension xdebug
34     * @expectedException \Exception
35     * @expectedExceptionMessageRegExp #Screaming preg_match#
36     */
37    public function testMessageXdebugScreamCompatibility()
38    {
39        ini_set('xdebug.scream', '1');
40        throw new Exception('Screaming preg_match');
41    }
42
43    /**
44     * @expectedException \Exception variadic
45     * @expectedExceptionMessageRegExp /^A variadic \w+ message/
46     */
47    public function testSimultaneousLiteralAndRegExpExceptionMessage()
48    {
49        throw new Exception('A variadic exception message');
50    }
51}
52