Skip to content

Commit

Permalink
Merge pull request #2436 from WPO-Foundation/fix-explosion-account-page
Browse files Browse the repository at this point in the history
fix(account): sometimes company name is null, not empty
  • Loading branch information
jefflembeck authored Oct 6, 2022
2 parents dd3e181 + 76ca195 commit c03e23b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions tests/Handlers/AccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -636,4 +636,35 @@ public function testGetAccountPageDefaultFree(): void

Account::getAccountPage($req, $page);
}

public function testGetAccountPageDefaultFreeCompanyNull(): void
{
$page = "";

$req = new RequestContext([]);
$user = new User();
$user->setUserId(12345);
$req->setUser($user);

$client = $this->createMock(CPClient::class);
$client->expects($this->once())
->method('getFullWptPlanSet');
$client->expects($this->once())
->method('getUserContactInfo')
->with(12345)
->willReturn([
'firstName' => "Goober",
'lastName' => "Goob",
'companyName' => null
]);
$req->setClient($client);

$bmm = $this->createMock(BannerMessageManager::class);
$bmm->expects($this->once())
->method('get')
->willReturn([]);
$req->setBannerMessageManager($bmm);

Account::getAccountPage($req, $page);
}
}
2 changes: 1 addition & 1 deletion www/src/Handlers/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ public static function getAccountPage(RequestContext $request_context, string $p
$contact_info = $request_context->getClient()->getUserContactInfo($user_id);
$first_name = $contact_info['firstName'];
$last_name = $contact_info['lastName'];
$company_name = $contact_info['companyName'];
$company_name = $contact_info['companyName'] ?? "";


$contact_info = [
Expand Down

0 comments on commit c03e23b

Please sign in to comment.