diff --git a/features/maintenance-mode.feature b/features/maintenance-mode.feature index 68da153..60181cd 100644 --- a/features/maintenance-mode.feature +++ b/features/maintenance-mode.feature @@ -55,3 +55,14 @@ Feature: Manage maintenance mode of WordPress install. """ Error: Maintenance mode already deactivated. """ + + When I run `wp maintenance-mode activate` + Then STDOUT should be: + """ + Enabling Maintenance mode... + Success: Activated Maintenance mode. + """ + + When I run `wp eval "file_put_contents('.maintenance', 'abspath() ) . '.maintenance'; - return $wp_filesystem->exists( $maintenance_file ); + if ( ! $wp_filesystem->exists( $maintenance_file ) ) { + return false; + } + + // We use the timestamp defined in the .maintenance file + // to check if the maintenance is available. + $upgrading = 0; + + $contents = $wp_filesystem->get_contents( $maintenance_file ); + $matches = []; + if ( preg_match( '/upgrading = (\d+);/i', $contents, $matches ) ) { + $upgrading = (int) $matches[1]; + } + + if ( ( time() - $upgrading ) >= 10 * MINUTE_IN_SECONDS ) { + return false; + } + return true; } /**