File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments