Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Feb 6, 2024
1 parent 06371ce commit 2eb4cc3
Show file tree
Hide file tree
Showing 3 changed files with 2,195 additions and 1,683 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public function test_get_item_invalid_parent_id() {
$response = rest_get_server()->dispatch( $request );
$this->assertErrorResponse( 'rest_font_face_parent_id_mismatch', $response, 404 );

$expected_message = 'The font face does not belong to the specified font family with id of "' . self::$other_font_family_id . '"';
$expected_message = 'The font face does not belong to the specified font family with id of "' . self::$other_font_family_id . '".';
$this->assertSame( $expected_message, $response->as_error()->get_error_messages()[0], 'The message must contain the correct parent ID.' );
}

Expand Down Expand Up @@ -926,7 +926,7 @@ public function test_delete_item_invalid_parent_id() {
$response = rest_get_server()->dispatch( $request );
$this->assertErrorResponse( 'rest_font_face_parent_id_mismatch', $response, 404, 'The response should return an error for "rest_font_face_parent_id_mismatch" with 404 status.' );

$expected_message = 'The font face does not belong to the specified font family with id of "' . self::$other_font_family_id . '"';
$expected_message = 'The font face does not belong to the specified font family with id of "' . self::$other_font_family_id . '".';
$this->assertSame( $expected_message, $response->as_error()->get_error_messages()[0], 'The message must contain the correct parent ID.' );
}

Expand Down Expand Up @@ -1048,7 +1048,7 @@ protected function check_file_meta( $font_face_id, $src_attributes ) {
protected function setup_font_file_upload( $formats ) {
$files = array();
foreach ( $formats as $format ) {
$font_file = DIR_TESTDATA . 'fonts/OpenSans-Regular.' . $format;
$font_file = DIR_TESTDATA . '/fonts/OpenSans-Regular.' . $format;
$font_path = wp_tempnam( 'OpenSans-Regular.' . $format );
copy( $font_file, $font_path );

Expand Down
7 changes: 7 additions & 0 deletions tests/phpunit/tests/rest-api/rest-schema-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ public function test_expected_routes_in_schema() {
'/wp-site-health/v1/directory-sizes',
'/wp/v2/wp_pattern_category',
'/wp/v2/wp_pattern_category/(?P<id>[\d]+)',
'/wp/v2/font-collections',
'/wp/v2/font-collections/(?P<slug>[\/\w-]+)',
'/wp/v2/font-families',
'/wp/v2/font-families/(?P<font_family_id>[\d]+)/font-faces',
'/wp/v2/font-families/(?P<font_family_id>[\d]+)/font-faces/(?P<id>[\d]+)',
'/wp/v2/font-families/(?P<id>[\d]+)',

);

$this->assertSameSets( $expected_routes, $routes );
Expand Down
Loading

0 comments on commit 2eb4cc3

Please sign in to comment.