Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions tests/AssertCompositeEntityExistValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;

use function K2gl\PHPUnitFluentAssertions\fact;

class AssertCompositeEntityExistValidatorTest extends TestCase
{
private MockObject $entityManager;
Expand All @@ -42,23 +44,18 @@ protected function setUp(): void

public function testValidateWithWrongConstraint(): void
{
// assert
$this->expectException(UnexpectedTypeException::class);

// act
$this->assertCompositeEntityExistValidator->validate(new class () {}, new NotNull);
// act + assert
fact(fn () => $this->assertCompositeEntityExistValidator->validate(new class () {}, new NotNull))
->throws(UnexpectedTypeException::class);
}

public function testValidateWithNonObjectValue(): void
{
// assert
$this->expectException(UnexpectedValueException::class);

// act
$this->assertCompositeEntityExistValidator->validate(
// act + assert
fact(fn () => $this->assertCompositeEntityExistValidator->validate(
'foo',
new AssertCompositeEntityExist(entity: 'App\Entity\WarehouseItem', fields: ['warehouseId', 'companyId']),
);
))->throws(UnexpectedValueException::class);
}

public function testValidateSkipsIfValueNull(): void
Expand Down
10 changes: 5 additions & 5 deletions tests/AssertEntityExistValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;

use function K2gl\PHPUnitFluentAssertions\fact;

class AssertEntityExistValidatorTest extends TestCase
{
private MockObject $entityManager;
Expand All @@ -41,11 +43,9 @@ protected function setUp(): void

public function testValidateWithWrongConstraint(): void
{
// assert
$this->expectException(UnexpectedTypeException::class);

// act
$this->assertEntityExistValidator->validate('foo', new NotNull);
// act + assert
fact(fn () => $this->assertEntityExistValidator->validate('foo', new NotNull))
->throws(UnexpectedTypeException::class);
}

public function testValidateValidEntity(): void
Expand Down
10 changes: 5 additions & 5 deletions tests/AssertEntityNotExistValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;

use function K2gl\PHPUnitFluentAssertions\fact;

class AssertEntityNotExistValidatorTest extends TestCase
{
private MockObject $entityManager;
Expand All @@ -41,11 +43,9 @@ protected function setUp(): void

public function testValidateWithWrongConstraint(): void
{
// assert
$this->expectException(UnexpectedTypeException::class);

// act
$this->assertEntityNotExistValidator->validate('foo', new NotNull);
// act + assert
fact(fn () => $this->assertEntityNotExistValidator->validate('foo', new NotNull))
->throws(UnexpectedTypeException::class);
}

public function testValidateValidEntity(): void
Expand Down