Skip to content

Commit

Permalink
🐛 Set siteUrl to be required
Browse files Browse the repository at this point in the history
  • Loading branch information
HighLiuk committed Dec 23, 2022
1 parent dbc95ac commit 82b50c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public static function setServerUrl( string $url ): void
*/
public static function throwIfSiteDoesNotExist( string $siteUrl ): void
{
if ( ! $siteUrl ) {
throw new \Exception( 'You must export the siteUrl environment variable' );
}

if ( static::stripUrl( \get_site_url() ) !== static::stripUrl( $siteUrl ) ) {
throw new \Exception( "Given site not found: $siteUrl" );
}
Expand Down
4 changes: 2 additions & 2 deletions src/WordPressTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public static function setUpBeforeClass(): void

static::loadWordPress( $wordPressPath, $_ENV['siteUrl'] ?? '' );

if ( is_multisite() && $_ENV['siteUrl'] ?? '' ) {
Helpers::throwIfSiteDoesNotExist( $_ENV['siteUrl'] );
if ( is_multisite() ) {
Helpers::throwIfSiteDoesNotExist( $_ENV['siteUrl'] ?? '' );
}
}

Expand Down

0 comments on commit 82b50c0

Please sign in to comment.