Gherkins\RegExpBuilderPHP\Test\UsageExamplesTest::testUsageExample PHP Method

testUsageExample() public method

public testUsageExample ( )
    public function testUsageExample()
    {
        $builder = new \Gherkins\RegExpBuilderPHP\RegExpBuilder();
        $regExp = $builder->startOfInput()->exactly(4)->digits()->then("_")->exactly(2)->digits()->then("_")->min(3)->max(10)->letters()->then(".")->anyOf(array("png", "jpg", "gif"))->endOfInput()->getRegExp();
        $this->assertTrue($regExp->matches("2020_10_hund.jpg"));
        $this->assertTrue($regExp->matches("2030_11_katze.png"));
        $this->assertTrue($regExp->matches("4000_99_maus.gif"));
        $this->assertFalse($regExp->matches("4000_99_f.gif"));
        $this->assertFalse($regExp->matches("4000_09_frogt.pdf"));
        $this->assertFalse($regExp->matches("2015_05_thisnameistoolong.jpg"));
    }