Skip to content

Commit

Permalink
Fix failing unit tests due to unset defaults
Browse files Browse the repository at this point in the history
Amended default conditions from null checks to empty checks in function-coauthors.php and class-components.php. Previously, there were no defaults set when running unit tests which led to unexpected fails. This change will ensure that unit tests pass even when certain parameters are not explicitly set.
  • Loading branch information
attackant committed Oct 31, 2023
1 parent 0066034 commit 1410294
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion includes/apple-exporter/builders/class-components.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ private function get_components_from_node( $node ) {
*/
private function get_image_full_size_url( $url ) {

if(null === $url) {
if( empty( $url ) ) {
return '';
}

Expand Down
4 changes: 3 additions & 1 deletion tests/mocks/function-coauthors.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ function coauthors( $between = ', ', $between_last = ' and ', $before = '', $aft
// Get last index.
$last_index = count( $apple_news_coauthors ) - 1;

if(null === $between) {
// Default was not set when running unit tests,
// causing failures.
if(empty( $between)) {
$between = ', ';
}

Expand Down

0 comments on commit 1410294

Please sign in to comment.