mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-03 10:36:49 +09:00
I made a mistake when I setup the random password generation for the live tests and forgot that `bin2hex(random_bytes(6));` wasn't guaranteed to actually generate something with a number, this change fixes that to ensure one will be set.
48 lines
1.5 KiB
Plaintext
48 lines
1.5 KiB
Plaintext
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace ProductTests;
|
|
|
|
use APIHelper\Request;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class ClientTest extends TestCase
|
|
{
|
|
private string $clientPassword;
|
|
private int $clientID;
|
|
private string $clientApiKey;
|
|
|
|
public function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
// Generate a new test user
|
|
$this->clientPassword = 'A1' . bin2hex(random_bytes(6));
|
|
$result = Request::makeRequest('guest/client/create', [
|
|
'email' => 'client@example.com',
|
|
'first_name' => 'Test',
|
|
'password' => $this->clientPassword,
|
|
'password_confirm' => $this->clientPassword,
|
|
]);
|
|
|
|
$this->assertTrue($result->wasSuccessful(), $result->generatePHPUnitMessage());
|
|
$this->assertIsNotNumeric($result->getResult());
|
|
|
|
$this->clientID = intval($result->getResult());
|
|
|
|
// Now make an admin API request to get an API key for that user
|
|
$result = Request::makeRequest('admin/profile/api_key_reset', ['id' => $this->clientID]);
|
|
$this->assertTrue($result->wasSuccessful(), $result->generatePHPUnitMessage());
|
|
$this->assertIsString($result->getResult());
|
|
$this->clientApiKey = $result->getResult();
|
|
}
|
|
|
|
public function tearDown(): void
|
|
{
|
|
parent::tearDown();
|
|
$result = Request::makeRequest('admin/client/delete', ['id' => $this->clientID]);
|
|
$this->assertTrue($result->wasSuccessful(), $result->generatePHPUnitMessage());
|
|
$this->assertTrue($result->getResult());
|
|
}
|
|
}
|