Skip to content

Commit

Permalink
chore: add patterns fectching unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Sep 14, 2023
1 parent 0fc2fbf commit 7472a47
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
44 changes: 44 additions & 0 deletions tests/test-patterns-class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Class CSS
*
* @package gutenberg-blocks
*/

use Yoast\PHPUnitPolyfills\Polyfills\AssertEqualsCanonicalizing;
use Yoast\PHPUnitPolyfills\Polyfills\AssertNotEqualsCanonicalizing;

/**
* Dynamic Content Test Case.
*/
class TestPatterns extends WP_UnitTestCase {

/**
* Test the fetching of patterns.
*/
public function test_fetch_patterns() {

$json_data = file_get_contents( dirname( dirname( __FILE__ ) ) . '/license.json' );
$array_data = json_decode( $json_data, true );

$url = add_query_arg(
array(
'site_url' => get_site_url(),
'license_id' => $array_data['key'],
'cache' => gmdate( 'u' ),
),
'https://api.themeisle.com/templates-cloud/otter-patterns'
);

$response = wp_remote_get( $url );
$response = wp_remote_retrieve_body( $response );

$this->assertTrue( 2000 < strlen( $response ) );

$response = json_decode( $response, true );

$this->assertIsArray( $response );

$this->assertArrayHasKey( 'slug', $response[0] );
}
}
2 changes: 1 addition & 1 deletion tests/test-stripe-api-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ public function test_user_purchase() {
public function test_status_for_price_id() {
$status = $this->stripe_api->get_status_for_price_id( 'sess_1','price_1' );

$this->assertTrue( 'complete' === $status );
$this->assertTrue( 'success' === $status );
}
}

0 comments on commit 7472a47

Please sign in to comment.