Regex to test changing return values in PHPUnit

Code
<?php

class RegexTest extends PHPUnit_Framework_TestCase
{
    public function 
testCreateId()
    {
        
$p '/^id_[\da-f]{13}$/';
        
        
$foo $this->createMock('Foo');
        
$foo->expects($this->once())
            ->
method('useId')
            ->
with(new PHPUnit_Framework_Constraint_PCREMatch($p))
            ->
will($this->returnValue(true));
        
        
$bar = new Bar($foo);
        
$id $bar->createId();
        
        
$this->assertRegexp($p$id);
    }
}

// class to test
class Bar
{
    private 
$foo;
    
    public function 
__construct(Foo $foo)
    {
        
$this->foo $foo;
    }
    
    public function 
createId()
    {
        
$id uniqid('id_');
        
$this->foo->useId($id);
        
        return 
$id;
    }
}

// dependency of Bar
class Foo
{
    public function 
useId($id)
    {
        
// ... doing stuff with id
        
return true;
    }
}
Result
Time: 176 ms, Memory: 2.00MB

OK (1 test, 0 assertions)