-
Notifications
You must be signed in to change notification settings - Fork 0
/
testHttpHaltWpTestCase.php
27 lines (23 loc) · 1.02 KB
/
testHttpHaltWpTestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
use WpUnitTestHelpers\WpTestCaseAbstract;
use WpUnitTestHelpers\Exceptions\HttpHaltException;
class TestHttpHaltWpTestCase extends WpTestCaseAbstract {
public function testThatItRequestsTheCorrectUrl() {
$this->startHttpHalting();
update_option( 'user_profile_api_access_token', '__test_api_token__' );
$test_user = (object) [ 'data' => (object) [ 'user_email' => '__test_email__' ] ];
try {
prefixed_get_user_profile_data_on_login( uniqid(), $test_user );
$e_data = [];
} catch ( HttpHaltException $e ) {
$e_data = $e->getHttpRequest();
}
$this->assertNotEmpty( $e_data );
$this->assertEquals( 'api.joshcanhelp.com', $e_data['url_parsed']['host'] );
$this->assertEquals( '/user', $e_data['url_parsed']['path'] );
$this->assertContains( 'email=__test_email__', $e_data['url_queries'] );
$this->assertEquals( 'GET', $e_data['method'] );
$this->assertArrayHasKey( 'Authorization', $e_data['headers'] );
$this->assertEquals( 'Bearer __test_api_token__', $e_data['headers']['Authorization'] );
}
}