precision-soft/symfony-phpunit

library used to make writing phpunit tests easier

v1.0.0 2024-09-17 15:25 UTC

This package is auto-updated.

Last update: 2024-09-18 08:23:30 UTC


README

You may fork and modify it as you wish.

Any suggestions are welcomed.

How to use

  • Extend \PrecisionSoft\Symfony\Phpunit\TestCase\AbstractTestCase or \PrecisionSoft\Symfony\Phpunit\TestCase\AbstractKernelTestCase if you need the symfony kernel.
  • PrecisionSoft\Symfony\Phpunit\Mock contains generic mocks.

Example

namespace Acme\Test\Foo\Service;

use Acme\Foo\Repository\FooRepository;
use Acme\Foo\Service\CreateService;
use PrecisionSoft\Symfony\Phpunit\Mock\ManagerRegistryMock;
use PrecisionSoft\Symfony\Phpunit\MockDto;
use PrecisionSoft\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:precision-soft-open-source/symfony/phpunit.git
cd phpunit

./dc build && ./dc up -d

Todo

  • Unit tests.