samedi 15 octobre 2016

Testing class against several traits in PHPUnit

I am testing my Validator php class. The class gets its validator methods as trait. So there is Validator.php file in the src folder and there is validatorMethods.php and ValidatorTest.php file in the test folder.

I would like to test the Validator class with some different validatorMethods.php files so different traits of validator methods would be loaded or do anything else to provide some several traits of validator methods to test the Validator class against those methods.

I thought about sth like putting traits to array and then injecting traits to the Validator class in loop. But it was rather not way to inject traits into object...

So how to test class against various traits? Perhaps better would be to use objects that each uses different trait?

Aucun commentaire:

Enregistrer un commentaire