Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Some traits helping with testing using PHPUnit.

License

Notifications You must be signed in to change notification settings

BluePsyduck/test-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BluePsyduck's Test Helper

GitHub release (latest SemVer) GitHub build Codecov

This library contains a trait helping with testing classes using PHPUnit by providing some shortcut methods for the test cases.

ReflectionTrait

The ReflectionTrait is a trait which adds methods for easier access to non-public properties and methods, making mocking them easier. The trait comes with the following methods:

  • injectProperty($object, $name, $value): Injects the value to a property of the object.
  • injectStaticProperty($className, $name, $value): Injects the value to a static property of the class.
  • extractProperty($object, $name): Extracts the value of a property from the object.
  • extractStaticProperty($className, $name): Extracts the value of a static property from the class.
  • invokeMethod($object, $name, ...$params): Invokes a non-public method on the object.
  • invokeStaticMethod($className, $name, ...$params): Invokes a non-public static method on the class.

Note: The parameters passed to invokeMethod() and invokeStaticMethod() are passed-by-value. If the method uses references, the changes made by the method will not be visible to the outside.

About

Some traits helping with testing using PHPUnit.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages