test: add missing tests for 100% coverage #107
Merged
+37
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds 3 tests to
UrlHelperTest.php
and 1 test toValidatorTest.php
. These tests brings the code base to 100% coverage.testHelperFormatPathWithNoPath
Touches this piece of code in
UrlHelper.php
:testHelperBuildSignedURLWithNullHashSetterParams & testHelperBuildSignedURLWithHashDeleterParams
Tests that unsetting parameters via
setParameter()
anddeleteParameter()
inUrlHelper.php
works. It tests by first setting a value, and then either setting it tonull
or by usingdeleteParameter()
.testValidateWidthsNegativeValues
Tests that negative values throws an exception in
validateWidths()
.The
$widths == NULL
on line 46 inValidator.php
actually was truthy if$widths
was an empty array.testValidateWidthsEmptyArray()
did therefore pass, but not for the right reason. It was passing because of the loose comparison in $widths == NULL was throwing the exception.Link that shows the comparisons in action:
https://3v4l.org/pWMCvClearer example: https://3v4l.org/JhR03
Changes to the code
The switch to strict comparisons (
==
to===
) just makes the code more "safe" by checking type as well as value.The switch to
is_null()
invalidateWidths()
makes the code work as expected.Before this PR
Run
$ phpunit --coverage-text
. Needs XDebug installed.After this PR
Run
$ phpunit --coverage-text
. Needs XDebug installed.Checklist
Read the contributing guidelines.
Each commit follows the Conventional Commit spec format.
All existing unit tests are still passing.
Add new passing unit tests to cover the code introduced by your PR.