maks3w/phpunit-methods-trait
PHP trait exposing PHPUnit TestCase helper methods for use inside reusable test traits. Lets traits call mocking, expectations, and other TestCase APIs without extending TestCase directly; assertions are via PHPUnit\Framework\Assert.
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.
You can use Composer .
composer require maks3w/phpunit-methods-trait
Example of use in a trait
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());
}
}
Code licensed under BSD 2 clauses terms & conditions.
See LICENSE.txt for more information.
How can I help you explore Laravel packages today?