-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add patterns fectching unit test
- Loading branch information
1 parent
0fc2fbf
commit 7472a47
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters