Skip to content

Commit bc1f8c8

Browse files
committed
replace assertEmpty() with stricter assertions
1 parent 91e320f commit bc1f8c8

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

Test/CompoundConstraintTestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ protected function getConstraints(array $options): array
102102
next($expectedViolations);
103103
}
104104

105-
$this->assertEmpty(
105+
$this->assertSame(
106+
[],
106107
$failedToAssertViolations,
107108
\sprintf('Expected violation(s) for constraint(s) %s to be raised by compound.',
108109
implode(', ', array_map(fn ($violation) => ($violation->getConstraint())::class, $failedToAssertViolations))

Tests/Constraints/WhenTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testAttributes()
6161
groups: ['Default', 'WhenTestWithAttributes'],
6262
),
6363
], $classConstraint->constraints);
64-
self::assertEmpty($classConstraint->otherwise);
64+
self::assertSame([], $classConstraint->otherwise);
6565

6666
[$fooConstraint] = $metadata->properties['foo']->getConstraints();
6767

@@ -71,7 +71,7 @@ public function testAttributes()
7171
new NotNull(groups: ['Default', 'WhenTestWithAttributes']),
7272
new NotBlank(groups: ['Default', 'WhenTestWithAttributes']),
7373
], $fooConstraint->constraints);
74-
self::assertEmpty($fooConstraint->otherwise);
74+
self::assertSame([], $fooConstraint->otherwise);
7575
self::assertSame(['Default', 'WhenTestWithAttributes'], $fooConstraint->groups);
7676

7777
[$barConstraint] = $metadata->properties['bar']->getConstraints();
@@ -82,15 +82,15 @@ public function testAttributes()
8282
new NotNull(groups: ['foo']),
8383
new NotBlank(groups: ['foo']),
8484
], $barConstraint->constraints);
85-
self::assertEmpty($barConstraint->otherwise);
85+
self::assertSame([], $barConstraint->otherwise);
8686
self::assertSame(['foo'], $barConstraint->groups);
8787

8888
[$quxConstraint] = $metadata->properties['qux']->getConstraints();
8989

9090
self::assertInstanceOf(When::class, $quxConstraint);
9191
self::assertSame('true', $quxConstraint->expression);
9292
self::assertEquals([new NotNull(groups: ['foo'])], $quxConstraint->constraints);
93-
self::assertEmpty($quxConstraint->otherwise);
93+
self::assertSame([], $quxConstraint->otherwise);
9494
self::assertSame(['foo'], $quxConstraint->groups);
9595

9696
[$bazConstraint] = $metadata->getters['baz']->getConstraints();
@@ -101,7 +101,7 @@ public function testAttributes()
101101
new NotNull(groups: ['Default', 'WhenTestWithAttributes']),
102102
new NotBlank(groups: ['Default', 'WhenTestWithAttributes']),
103103
], $bazConstraint->constraints);
104-
self::assertEmpty($bazConstraint->otherwise);
104+
self::assertSame([], $bazConstraint->otherwise);
105105
self::assertSame(['Default', 'WhenTestWithAttributes'], $bazConstraint->groups);
106106

107107
[$quuxConstraint] = $metadata->properties['quux']->getConstraints();
@@ -135,7 +135,7 @@ public function testAttributesWithClosure()
135135
groups: ['Default', 'WhenTestWithClosure'],
136136
),
137137
], $classConstraint->constraints);
138-
self::assertEmpty($classConstraint->otherwise);
138+
self::assertSame([], $classConstraint->otherwise);
139139

140140
[$fooConstraint] = $metadata->properties['foo']->getConstraints();
141141

@@ -145,7 +145,7 @@ public function testAttributesWithClosure()
145145
new NotNull(groups: ['Default', 'WhenTestWithClosure']),
146146
new NotBlank(groups: ['Default', 'WhenTestWithClosure']),
147147
], $fooConstraint->constraints);
148-
self::assertEmpty($fooConstraint->otherwise);
148+
self::assertSame([], $fooConstraint->otherwise);
149149
self::assertSame(['Default', 'WhenTestWithClosure'], $fooConstraint->groups);
150150
}
151151
}

Tests/Mapping/Loader/PropertyInfoLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function getTypes(string $class, string $property, array $context = []):
214214
$this->assertInstanceOf(Iban::class, $alreadyPartiallyMappedCollectionConstraints[0]->constraints[1]);
215215

216216
$readOnlyMetadata = $classMetadata->getPropertyMetadata('readOnly');
217-
$this->assertEmpty($readOnlyMetadata);
217+
$this->assertSame([], $readOnlyMetadata);
218218

219219
/** @var PropertyMetadata[] $noAutoMappingMetadata */
220220
$noAutoMappingMetadata = $classMetadata->getPropertyMetadata('noAutoMapping');
@@ -298,7 +298,7 @@ public function getTypes(string $class, string $property, array $context = []):
298298

299299
/** @var ClassMetadata $classMetadata */
300300
$classMetadata = $validator->getMetadataFor(new PropertyInfoLoaderNoAutoMappingEntity());
301-
$this->assertEmpty($classMetadata->getPropertyMetadata('string'));
301+
$this->assertSame([], $classMetadata->getPropertyMetadata('string'));
302302
$this->assertCount(2, $classMetadata->getPropertyMetadata('autoMappingExplicitlyEnabled')[0]->constraints);
303303
$this->assertSame(AutoMappingStrategy::ENABLED, $classMetadata->getPropertyMetadata('autoMappingExplicitlyEnabled')[0]->getAutoMappingStrategy());
304304
}

0 commit comments

Comments
 (0)