avinash403 / phpunit-testing-kit
Gives all the helper traits and classes that you will ever need to test a PHP application
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 0
Open Issues: 2
Type:package
Requires (Dev)
- phpunit/phpunit: ^7.1
This package is not auto-updated.
Last update: 2025-03-10 16:40:00 UTC
README
Collection of useful traits and classes that can be handy while testing a PHP application.
Installation by Composer
$ composer require avinash403/phpunit-testing-kit
Available Traits
Assertions
Contains some common assertions that is commonly used but PHPunit doesn't provide it.
USAGE
use TestingKit\Assertions;
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
use Assertions;
public function test_exampleTest()
{
$this->assertAlpha('a');
}
}
Available Assertions
* assertAlpha * assertNotAlpha * assertNumber * assertNotNumber * assertArrayHasKeys * assertStringContainsSubstring * assertStringNotContainsSubstring
PrivateAccess
Allows testing private and protected method and properties of a class.
USAGE
use TestingKit\PrivateAccess;
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
use PrivateAccess;
public function test_exampleTest_forGettingPrivateMethod()
{
$classObject = new Class();
//getting private method
$methodResponse = $this->getPrivateMethod($classObject, 'exampleMethod', ['some text']);
$this->assertEquals($methodResponse, 'some text');
}
}
class ExampleClass
{
private exampleMethod($someArgument)
{
return $someArgument;
}
}
Available Features
* getPrivateMethod * setPrivateProperty * getPrivateProperty
Test
Run test by simply typing
composer test
from the root directory of this package.
Contribute on github
clone this repository( https://github.com/avinash403/laravel-dynamic-observer.git ), make your changes and raise a pull request to development branch