-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
126 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace C0ntax\ParsleyBundle\Parsleys; | ||
|
||
use C0ntax\ParsleyBundle\Contracts\DirectiveInterface; | ||
|
||
/** | ||
* Class RemoveParsleyConstraint | ||
* | ||
* Used to remove Parsley Directives after they've been put in | ||
* | ||
* @package C0ntax\ParsleyBundle\Parsleys | ||
*/ | ||
class RemoveParsleyDirective extends AbstractRemove | ||
{ | ||
/** | ||
* RemoveParsley constructor. | ||
* | ||
* @param string $className | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function __construct(string $className) | ||
{ | ||
parent::__construct($className, DirectiveInterface::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
namespace C0ntax\ParsleyBundle\Tests\Parsleys; | ||
|
||
use C0ntax\ParsleyBundle\Parsleys\Directive\Field\Constraint as ParsleyConstraint; | ||
use C0ntax\ParsleyBundle\Parsleys\Directive\Field\ConstraintErrorMessage; | ||
use C0ntax\ParsleyBundle\Parsleys\Directive\Field\Generic; | ||
use C0ntax\ParsleyBundle\Parsleys\Directive\Field\Trigger; | ||
use C0ntax\ParsleyBundle\Parsleys\RemoveParsleyDirective; | ||
use Symfony\Component\Validator\Constraints as SymfonyConstraint; | ||
|
||
class RemoveParsleyDirectiveTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @dataProvider getValidClassNames | ||
* @param string $className | ||
*/ | ||
public function testValid(string $className) | ||
{ | ||
self::assertInstanceOf(RemoveParsleyDirective::class, new RemoveParsleyDirective($className)); | ||
} | ||
|
||
/** | ||
* @dataProvider getInvalidClassNames | ||
* @param string $className | ||
* @expectedException \InvalidArgumentException | ||
* @expectedExceptionMessageRegExp /^Class [\S]+ does not implement C0ntax\\ParsleyBundle\\Contracts\\DirectiveInterface$/ | ||
*/ | ||
public function testInvalid(string $className) | ||
{ | ||
new RemoveParsleyDirective($className); | ||
} | ||
|
||
public function getValidClassNames() | ||
{ | ||
return [ | ||
[ | ||
'className' => ConstraintErrorMessage::class, | ||
], | ||
[ | ||
'className' => Generic::class, | ||
], | ||
[ | ||
'className' => Trigger::class, | ||
], | ||
[ | ||
'className' => ParsleyConstraint\Email::class, | ||
], | ||
[ | ||
'className' => ParsleyConstraint\Length::class, | ||
], | ||
[ | ||
'className' => ParsleyConstraint\Max::class, | ||
], | ||
[ | ||
'className' => ParsleyConstraint\MaxLength::class, | ||
], | ||
[ | ||
'className' => ParsleyConstraint\Min::class, | ||
], | ||
[ | ||
'className' => ParsleyConstraint\MinLength::class, | ||
], | ||
[ | ||
'className' => ParsleyConstraint\Pattern::class, | ||
], | ||
[ | ||
'className' => ParsleyConstraint\Range::class, | ||
], | ||
[ | ||
'className' => ParsleyConstraint\Required::class, | ||
], | ||
]; | ||
} | ||
|
||
public function getInvalidClassNames() | ||
{ | ||
return [ | ||
[ | ||
'className' => SymfonyConstraint\Email::class, | ||
], | ||
[ | ||
'className' => SymfonyConstraint\Length::class, | ||
], | ||
[ | ||
'className' => SymfonyConstraint\Regex::class, | ||
], | ||
]; | ||
} | ||
} |