Skip to content

Commit

Permalink
Removed pattern()->is()->*(), for the sake of pattern()->valid() #55
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Nov 2, 2019
1 parent 24a4f75 commit d79ecca
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 130 deletions.
25 changes: 0 additions & 25 deletions src/TRegx/CleanRegex/IsPattern.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/TRegx/CleanRegex/Pattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public function count(string $subject): int
return (new CountPattern($this->pattern, new Subject($subject)))->count();
}

public function is(): IsPattern
public function valid(): bool
{
return new IsPattern($this->pattern);
return (new ValidPattern($this->pattern->pattern))->isValid();
}

public function delimiter(): string
Expand Down
4 changes: 2 additions & 2 deletions test/Feature/TRegx/CleanRegex/ErrorCleanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class ErrorCleanTest extends TestCase
public function shouldNotInfluenceFurtherChecks()
{
// when
pattern('/[a-')->is()->valid();
pattern('/[a-')->valid();

// when
$valid = pattern('/[a-z]/')->is()->valid();
$valid = pattern('/[a-z]/')->valid();

// then
$this->assertTrue($valid);
Expand Down
101 changes: 0 additions & 101 deletions test/Integration/TRegx/CleanRegex/IsPatternTest.php

This file was deleted.

38 changes: 38 additions & 0 deletions test/Integration/TRegx/CleanRegex/PatternTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
namespace Test\Integration\TRegx\CleanRegex;

use PHPUnit\Framework\TestCase;
use TRegx\CleanRegex\Pattern;

class PatternTest extends TestCase
{
/**
* @test
*/
public function shouldBeValid()
{
// given
$pattern = new Pattern('Foo');

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

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

/**
* @test
*/
public function shouldNotBeValid()
{
// given
$pattern = new Pattern('invalid)');

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

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

0 comments on commit d79ecca

Please sign in to comment.