Skip to content

Commit 26fe315

Browse files
authored
Merge pull request #487 from localheinz/fix/assertion
Fix: Use more appropriate assertions
2 parents bb4f2e4 + fd05668 commit 26fe315

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

tests/Constraints/CoerciveTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,14 @@ public function testCoerceCases($schema, $data, $startType, $endType, $endValue,
178178

179179
// check end value
180180
$value = LooseTypeCheck::propertyGet($data, 'propertyOne');
181-
$this->assertTrue(
182-
$value === $endValue,
183-
sprintf(
184-
"Incorrect value '%s': expected '%s'",
185-
is_scalar($value) ? $value : gettype($value),
186-
is_scalar($endValue) ? $endValue : gettype($endValue)
187-
)
188-
);
181+
$this->assertSame($value, $endValue, sprintf(
182+
"Incorrect value '%s': expected '%s'",
183+
is_scalar($value) ? $value : gettype($value),
184+
is_scalar($endValue) ? $endValue : gettype($endValue)
185+
));
189186
} else {
190187
$this->assertFalse($validator->isValid(), 'Validation succeeded, but should have failed');
191-
$this->assertEquals(1, count($validator->getErrors()));
188+
$this->assertCount(1, $validator->getErrors());
192189
}
193190
}
194191

tests/Constraints/FormatTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function testInvalidFormat($string, $format)
7777
$schema->format = $format;
7878

7979
$validator->check($string, $schema);
80-
$this->assertEquals(1, count($validator->getErrors()), 'Expected 1 error');
80+
$this->assertCount(1, $validator->getErrors(), 'Expected 1 error');
8181
}
8282

8383
/**

0 commit comments

Comments
 (0)