public function testMatches() { $regex = $this->getMockBuilder(Regex::class)->disableOriginalConstructor()->getMock(); $regex->method('check')->willReturn(true); $text = new Text('This is a test'); $this->assertTrue($text->matches($regex)); }