Gherkins\RegExpBuilderPHP\Test\UsageExamplesTest::testUsageExample2 PHP Метод

testUsageExample2() публичный Метод

public testUsageExample2 ( )
    public function testUsageExample2()
    {
        $builder = new \Gherkins\RegExpBuilderPHP\RegExpBuilder();
        $a = $builder->startOfInput()->exactly(3)->digits()->anyOf(array(".pdf", ".doc"))->endOfInput();
        $b = $builder->getNew()->startOfInput()->exactly(4)->letters()->then(".jpg")->endOfInput();
        $regExp = $builder->getNew()->eitherFind($a)->orFind($b)->getRegExp();
        $this->assertTrue($regExp->matches("123.pdf"));
        $this->assertTrue($regExp->matches("456.doc"));
        $this->assertTrue($regExp->matches("bbbb.jpg"));
        $this->assertTrue($regExp->matches("aaaa.jpg"));
        $this->assertFalse($regExp->matches("1234.pdf"));
        $this->assertFalse($regExp->matches("123.gif"));
        $this->assertFalse($regExp->matches("aaaaa.jpg"));
        $this->assertFalse($regExp->matches("456.docx"));
    }