Skip to content

Commit

Permalink
Refactor /Test/Integration/TRegx/CleanRegex/PatternTest to validate o…
Browse files Browse the repository at this point in the history
…f() and pcre() methods #55
  • Loading branch information
danon committed Feb 18, 2020
1 parent 75377e9 commit c13a295
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions test/Integration/TRegx/CleanRegex/PatternTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,50 @@ class PatternTest extends TestCase
{
/**
* @test
* @dataProvider patterns
* @param string $pattern
* @param bool $expected
* @param bool $_
*/
public function shouldBeValid()
public function testStandard(string $pattern, bool $expected, bool $_)
{
// given
$pattern = Pattern::of('Foo');
$pattern = Pattern::of($pattern);

// when
$valid = $pattern->valid();

// then
$this->assertTrue($valid);
$this->assertEquals($expected, $valid);
}

/**
* @test
* @dataProvider patterns
* @param string $pattern
* @param bool $_
* @param bool $expected
*/
public function shouldNotBeValid()
public function testPcre(string $pattern, bool $_, bool $expected)
{
// given
$pattern = Pattern::of('invalid)');
$pattern = Pattern::pcre($pattern);

// when
$valid = $pattern->valid();

// then
$this->assertFalse($valid);
$this->assertEquals($expected, $valid);
}

public function patterns(): array
{
return [
'of' => ['Foo', true, false],
'pcre' => ['/Foo/', true, true],
'pcre,invalid' => ['/invalid)/', false, false],
'invalid' => ['invalid)', false, false],
'empty' => ['', true, false],
];
}
}

0 comments on commit c13a295

Please sign in to comment.