Skip to content

Commit d58efbc

Browse files
authored
Merge branch 'WordPress:trunk' into trunk
2 parents dce0a34 + cb28c8c commit d58efbc

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

tests/phpunit/tests/basic.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,47 @@ public function test_composer_json() {
136136

137137
$this->assertSame( $version, $composer_json['version'], "composer.json's version needs to be updated to $version." );
138138
}
139+
140+
/**
141+
* Test the src wp_version always ends with '-src'.
142+
*
143+
* @coversNothing
144+
*/
145+
public function test_src_wp_version_ends_with_src() {
146+
$version_file = dirname( ABSPATH ) . '/src/wp-includes/version.php';
147+
148+
$src_wp_version = $this->get_wp_version_from_file( $version_file );
149+
150+
$this->assertStringEndsWith( '-src', $src_wp_version, 'The src wp_version must end with -src.' );
151+
}
152+
153+
/**
154+
* Test the build wp_version never ends with '-src'.
155+
*
156+
* @coversNothing
157+
*/
158+
public function test_build_wp_version_does_not_end_with_src() {
159+
$version_file = dirname( ABSPATH ) . '/build/wp-includes/version.php';
160+
161+
if ( ! file_exists( $version_file ) ) {
162+
$this->markTestSkipped( 'The build directory does not exist.' );
163+
}
164+
165+
$build_wp_version = $this->get_wp_version_from_file( $version_file );
166+
167+
$this->assertStringEndsNotWith( '-src', $build_wp_version, 'The build wp_version must not end with -src.' );
168+
}
169+
170+
/**
171+
* Includes a version.php file in an isolated scope and returns its $wp_version.
172+
*
173+
* @param string $file Path to a version.php file.
174+
* @return string The value of $wp_version defined in the file.
175+
*/
176+
private function get_wp_version_from_file( $file ) {
177+
$wp_version = '';
178+
include $file;
179+
180+
return $wp_version;
181+
}
139182
}

0 commit comments

Comments
 (0)