drjele / symfony-phpunit
Library used to make writing phpunit tests easier
v5.2.0
2024-03-01 10:29 UTC
Requires
- php: >=8.2
- mockery/mockery: 1.*
- symfony/phpunit-bridge: ^4.0|^5.0|^6.0|^7.0
Requires (Dev)
- doctrine/doctrine-bundle: 2.*
- doctrine/orm: 2.*|3.*|4.*
- friendsofphp/php-cs-fixer: 3.*
- phpstan/phpstan: 1.*
- squizlabs/php_codesniffer: 3.*
- symfony/framework-bundle: ^4.0|^5.0|^6.0|^7.0
README
You may fork and modify it as you wish.
Any suggestions are welcomed.
How to use
- Extend \Drjele\Symfony\Phpunit\TestCase\AbstractTestCase or \Drjele\Symfony\Phpunit\TestCase\AbstractKernelTestCase if you need the symfony kernel.
- Drjele\Symfony\Phpunit\Mock contains generic mocks.
Example
namespace Acme\Test\Foo\Service;
use Acme\Foo\Repository\FooRepository;
use Acme\Foo\Service\CreateService;
use Drjele\Symfony\Phpunit\Mock\ManagerRegistryMock;
use Drjele\Symfony\Phpunit\MockDto;
use Drjele\Symfony\Phpunit\TestCase\AbstractTestCase;
final class CreateServiceTest extends AbstractTestCase
{
public static function getMockDto(): MockDto
{
return new MockDto(
CreateService::class,
[
ManagerRegistryMock::class,
new MockDto(FooRepository::class),
'staticDependency'
],
true
);
}
public function testCreate(): void
{
}
}
Dev
git clone git@gitlab.com:drjele-symfony/phpunit.git
cd phpunit
rm -rf .git/hooks && ln -s ../dev/git-hooks .git/hooks
./dc build && ./dc up -d
Todo
- Unit tests.