Files
FOSSBilling/tests/Modules/Product/ClientTest.php.skip
T
Belle Aerni 0493c3a3e5 Further test improvements (#2122)
* Slight structure change to the testcases

* Fix

* Ported some random low-level tests

* Spelling

* Ported over some other low-level tests

* Fixes

* And now other fixes

* Another one
2024-02-06 13:13:04 -08:00

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 = 'A' . 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());
}
}