Skip to content

Commit 55350b3

Browse files
committed
Test fix
1 parent a754379 commit 55350b3

File tree

4 files changed

+33
-25
lines changed

4 files changed

+33
-25
lines changed

tests/CPClientTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ public function testGetUser(): void
301301
"status": "ACTIVE",
302302
"vatNumber": null
303303
}
304+
"wptIsPreviewEnabled": {
305+
"enabled": false
306+
}
304307
}
305308
}');
306309
$host = "http://webpagetest.org";

tests/RequestContextTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ public function testSetGetClient(): void
3636
$client = new CPClient($host);
3737
$request = new RequestContext($global_req);
3838
$request->setClient($client);
39-
$this->assertEquals($host, $request->getClient()->host);
39+
$this->assertEquals($host, $request->getClient()->getHost());
4040
}
4141
}

www/src/CPClient.php

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ public function isAuthenticated(): bool
102102
return !!$this->access_token;
103103
}
104104

105+
public function getHost(): ?string
106+
{
107+
return $this->host;
108+
}
109+
105110
public function login(string $code, string $code_verifier, string $redirect_uri): AuthToken
106111
{
107112
if (is_null($this->client_id) || is_null($this->client_secret)) {
@@ -316,19 +321,19 @@ public function getFullWptPlanSet(): PlanListSet
316321
return new Plan($options);
317322
}, $results->getData()['wptPlan'] ?? []);
318323

319-
$current_plans = array_filter($all_plans, function (Plan $plan) {
320-
/** This is a bit of a hack for now. These are our approved plans for new
321-
* customers to be able to use. We will better handle this from the backend
322-
* */
323-
return strtolower($plan->getId()) == 'ap5' ||
324-
strtolower($plan->getId()) == 'ap6' ||
325-
strtolower($plan->getId()) == 'ap7' ||
326-
strtolower($plan->getId()) == 'ap8' ||
327-
strtolower($plan->getId()) == 'mp5' ||
328-
strtolower($plan->getId()) == 'mp6' ||
329-
strtolower($plan->getId()) == 'mp7' ||
330-
strtolower($plan->getId()) == 'mp8';
331-
});
324+
$current_plans = array_filter($all_plans, function (Plan $plan) {
325+
/** This is a bit of a hack for now. These are our approved plans for new
326+
* customers to be able to use. We will better handle this from the backend
327+
* */
328+
return strtolower($plan->getId()) == 'ap5' ||
329+
strtolower($plan->getId()) == 'ap6' ||
330+
strtolower($plan->getId()) == 'ap7' ||
331+
strtolower($plan->getId()) == 'ap8' ||
332+
strtolower($plan->getId()) == 'mp5' ||
333+
strtolower($plan->getId()) == 'mp6' ||
334+
strtolower($plan->getId()) == 'mp7' ||
335+
strtolower($plan->getId()) == 'mp8';
336+
});
332337
$set = new PlanListSet();
333338
$set->setAllPlans(new PlanList(...$all_plans));
334339
$set->setCurrentPlans(new PlanList(...$current_plans));
@@ -1070,18 +1075,18 @@ public function updatePlan(string $subscription_id, string $next_plan_handle, bo
10701075
public function updatePaymentMethod(string $token, ShippingAddress $address): bool
10711076
{
10721077
$gql = (new Mutation('wptUpdateSubscriptionPayment'))
1073-
->setVariables([
1074-
new Variable('paymentToken', 'String', true),
1075-
new Variable('shippingAddress', 'ChargifyAddressInputType', true)
1076-
])
1077-
->setArguments([
1078-
'paymentToken' => '$paymentToken',
1079-
'shippingAddress' => '$shippingAddress'
1080-
]);
1078+
->setVariables([
1079+
new Variable('paymentToken', 'String', true),
1080+
new Variable('shippingAddress', 'ChargifyAddressInputType', true)
1081+
])
1082+
->setArguments([
1083+
'paymentToken' => '$paymentToken',
1084+
'shippingAddress' => '$shippingAddress'
1085+
]);
10811086

10821087
$variables = [
1083-
'paymentToken' => $token,
1084-
'shippingAddress' => $address->toArray()
1088+
'paymentToken' => $token,
1089+
'shippingAddress' => $address->toArray()
10851090
];
10861091

10871092
$results = $this->graphql_client->runQuery($gql, true, $variables);

www/templates/layouts/includes/wpt-header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function addTab($tabName, $tabUrl, $addClass = '')
5050
$is_logged_in = Util::getSetting('cp_auth') && (!is_null($request_context)) && (!is_null($request_context->getClient()) && $request_context->getClient()->isAuthenticated());
5151
$user = !is_null($request_context) ? $request_context->getUser() : null;
5252

53-
if ($request_context->isReadOnly()) {
53+
if (isset($request_context) && $request_context->isReadOnly()) {
5454

5555
?>
5656
<wpt-header style='margin-bottom: -1rem;'>

0 commit comments

Comments
 (0)