Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maks3w/phpunitmethodstrait
Provide PHPUnit method signatures as traits for IDE autocomplete
https://github.com/maks3w/phpunitmethodstrait
hacktoberfest phpunit testcase testing trait
Last synced: about 2 months ago
JSON representation
Provide PHPUnit method signatures as traits for IDE autocomplete
- Host: GitHub
- URL: https://github.com/maks3w/phpunitmethodstrait
- Owner: Maks3w
- License: other
- Created: 2015-06-14T09:46:59.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-04-03T05:00:15.000Z (over 1 year ago)
- Last Synced: 2024-08-08T16:53:58.604Z (5 months ago)
- Topics: hacktoberfest, phpunit, testcase, testing, trait
- Language: PHP
- Homepage:
- Size: 40 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# PHPUnit methods trait
Provide a PHP Trait with methods present in PHPUnit Test Framework and expected to be implemented by TestCase.
This is useful when traits are used for test reuse, and it's necessary to access to PHPUnit\Framework\TestCase
methods from the trait.## Installing via Composer
You can use [Composer](https://getcomposer.org) .
```bash
composer require maks3w/phpunit-methods-trait
```## Usage
Example of use in a trait
```php
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;trait FooTrait {
use \Maks3w\PhpUnitMethodsTrait\Framework\TestCaseTrait;public function testFoo() {
$mockFoo = $this->getMock('Foo');
$mockFoo->expects(TestCase::any())
->method('getFoo')
->willReturn(true)
;Assert::assertTrue($mockFoo->getFoo());
}
}
```## FAQ
- Q: Assertion methods are not recognized. Why?
-
A: Assertion methods like `assertTrue` are static methods present in `PHPUnit\Framework\Assert` just access them
using static method call `PHPUnit\Framework\Assert::assertTrue(...)`
## License
Code licensed under BSD 2 clauses terms & conditions.
See [LICENSE.txt](LICENSE.txt) for more information.