Skip to content

Commit

Permalink
maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdef committed Sep 13, 2024
1 parent 2067b53 commit 8100976
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
28 changes: 14 additions & 14 deletions tests/inc/rest/DatasourceCrudTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function test_register_new_data_source_with_invalid_input() {
}

public function test_get_data_sources() {
$source1 = DatasourceCRUD::register_new_data_source([
$source1 = DatasourceCRUD::register_new_data_source( [
'token' => 'token1',
'service' => 'airtable',
'base' => [
Expand All @@ -195,19 +195,19 @@ public function test_get_data_sources() {
'name' => 'Table Name 1',
],
'slug' => 'source-1',
]);
] );

$source2 = DatasourceCRUD::register_new_data_source([
$source2 = DatasourceCRUD::register_new_data_source( [
'token' => 'token2',
'service' => 'shopify',
'store' => 'mystore.myshopify.com',
'slug' => 'source-2',
]);
] );

set_mocked_option(DatasourceCRUD::CONFIG_OPTION_NAME, [
set_mocked_option( DatasourceCRUD::CONFIG_OPTION_NAME, [
$source1,
$source2,
]);
] );

$all_sources = DatasourceCRUD::get_data_sources();
$this->assertCount( 2, $all_sources );
Expand All @@ -222,7 +222,7 @@ public function test_get_data_sources() {
}

public function test_get_item_by_uuid_with_valid_uuid() {
$source = DatasourceCRUD::register_new_data_source([
$source = DatasourceCRUD::register_new_data_source( [
'token' => 'token1',
'service' => 'airtable',
'base' => [
Expand All @@ -234,7 +234,7 @@ public function test_get_item_by_uuid_with_valid_uuid() {
'name' => 'Table Name 1',
],
'slug' => 'source-1',
]);
] );

$retrieved_source = DatasourceCRUD::get_item_by_uuid( DatasourceCRUD::get_data_sources(), $source->uuid );
$this->assertEquals( $source, $retrieved_source );
Expand All @@ -246,7 +246,7 @@ public function test_get_item_by_uuid_with_invalid_uuid() {
}

public function test_update_item_by_uuid_with_valid_uuid() {
$source = DatasourceCRUD::register_new_data_source([
$source = DatasourceCRUD::register_new_data_source( [
'token' => 'token1',
'service' => 'airtable',
'base' => [
Expand All @@ -258,12 +258,12 @@ public function test_update_item_by_uuid_with_valid_uuid() {
'name' => 'Table Name 1',
],
'slug' => 'source-1',
]);
] );

$updated_source = DatasourceCRUD::update_item_by_uuid($source->uuid, [
$updated_source = DatasourceCRUD::update_item_by_uuid( $source->uuid, [
'token' => 'updated_token',
'slug' => 'updated-slug',
]);
] );

$this->assertIsObject( $updated_source );
$this->assertEquals( 'updated_token', $updated_source->token );
Expand All @@ -276,7 +276,7 @@ public function test_update_item_by_uuid_with_invalid_uuid() {
}

public function test_delete_item_by_uuid() {
$source = DatasourceCRUD::register_new_data_source([
$source = DatasourceCRUD::register_new_data_source( [
'token' => 'token1',
'service' => 'airtable',
'base' => [
Expand All @@ -288,7 +288,7 @@ public function test_delete_item_by_uuid() {
'name' => 'Table Name 1',
],
'slug' => 'source-1',
]);
] );

$result = DatasourceCRUD::delete_item_by_uuid( $source->uuid );
$this->assertTrue( $result );
Expand Down
4 changes: 2 additions & 2 deletions tests/stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function sanitize_text_field( string $text ): string {
return $text;
}

function __( string $text, string $domain = 'default' ): string {
function __( string $text ): string {
return $text;
}

Expand Down Expand Up @@ -107,7 +107,7 @@ function wp_is_uuid( $uuid, $version = null ) {

if ( is_numeric( $version ) ) {
if ( 4 !== (int) $version ) {
throw new Exception( __( 'Only UUID V4 is supported at this time.' ) );
throw new Exception( esc_html( 'Only UUID V4 is supported at this time.' ) );
}
$regex = '/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/';
} else {
Expand Down

0 comments on commit 8100976

Please sign in to comment.