henrotaym / laravel-test-suite
Adding recurrent functionalities to laravel test suite.
Installs: 5 348
Dependents: 7
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.5
README
Installation
composer require henrotaym/laravel-test-suite
Configuration
Your TestCase should use this trait :
Henrotaym\LaravelTestSuite\TestSuite
Functionalities
Mocking
/**
* Mocking given element.
*
* @param string $element Element to mock
* @return MockInterface
*/
protected function mockThis(string $element, bool $is_partial = false): MockInterface
Getting private property
/**
* Getting private property value from given instance.
*
* @param string $property Property we're trying to access to.
* @param mixed $instance Instance where we access property.
* @return mixed Property value.
*/
protected function getPrivateProperty(string $property, $instance);
Setting private property
/**
* Setting private property value in given instance.
*
* @param string $property Property we're trying to access to.
* @param mixed $value Value to set.
* @param mixed $instance Instance where we set value.
* @return mixed Instance in order to chain potential calls.
*/
protected function setPrivateProperty(string $property, $value, $instance);
Calling private method
/**
* Calling private method from given instance.
*
* @param string $method Method we're trying to access to.
* @param mixed $instance Instance where we access method.
* @param mixed $parameters Arguments to give to method.
* @return mixed Method return value.
*/
protected function callPrivateMethod(string $method, $instance, ...$parameters);
Mocking Carbon now helper
/**
* Mocking Carbon now helper.
*
* @param Carbon $now Expected time returned when calling now().
* @return static
*/
public function mockCarbonNow(Carbon $now)