Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
"neto737\\HestiaCP\\": "src/HestiaCP/"
}
},
"autoload-dev": {
"psr-4": {
"neto737\\HestiaCP\\Tests\\": "tests/"
}
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.86",
"phpstan/phpstan": "^2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

use neto737\HestiaCP\Authorization\Credentials;
namespace neto737\HestiaCP\Tests\Authorization;

require_once __DIR__ . '/../vendor/autoload.php';
use neto737\HestiaCP\Authorization\Credentials;

class credentialTest extends \PHPUnit\Framework\TestCase {
class CredentialsTest extends \PHPUnit\Framework\TestCase {

public function testApiKey(): void {
$credentials = new Credentials('');
Expand Down
6 changes: 3 additions & 3 deletions tests/hostTest.php → tests/Authorization/HostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

declare(strict_types=1);

namespace neto737\HestiaCP\Tests\Authorization;

use neto737\HestiaCP\Authorization\Credentials;
use neto737\HestiaCP\Authorization\Host;
use neto737\HestiaCP\Exceptions\InvalidArgumentException;

require_once __DIR__ . '/../vendor/autoload.php';

class hostTest extends \PHPUnit\Framework\TestCase {
class HostTest extends \PHPUnit\Framework\TestCase {

public function testHost(): void {
$credentials = new Credentials('', '');
Expand Down
6 changes: 3 additions & 3 deletions tests/clientSendTest.php → tests/ClientSendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

declare(strict_types=1);

namespace neto737\HestiaCP\Tests;

use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
Expand All @@ -24,16 +26,14 @@
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

require_once __DIR__ . '/../vendor/autoload.php';

/**
* Responses mimic HestiaCP's web/api/index.php: the access key endpoint sets the
* Hestia-Exit-Code header and an HTTP error status, the legacy endpoint only echoes the code.
*
* @phpstan-import-type ClientOptions from Client
* @phpstan-type HistoryEntry array{request: RequestInterface, response: ResponseInterface|null, error: mixed, options: array<array-key, mixed>}
*/
class clientSendTest extends \PHPUnit\Framework\TestCase {
class ClientSendTest extends \PHPUnit\Framework\TestCase {

/** @var array<array-key, HistoryEntry> */
private array $history = [];
Expand Down
6 changes: 3 additions & 3 deletions tests/clientTest.php → tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

declare(strict_types=1);

namespace neto737\HestiaCP\Tests;

use neto737\HestiaCP\Authorization\Credentials;
use neto737\HestiaCP\Authorization\Host;
use neto737\HestiaCP\Client;

require_once __DIR__ . '/../vendor/autoload.php';

class clientTest extends \PHPUnit\Framework\TestCase {
class ClientTest extends \PHPUnit\Framework\TestCase {

public function testHostWithAPIKey(): void {
$credentials = new Credentials('');
Expand Down
6 changes: 3 additions & 3 deletions tests/commandAddTest.php → tests/Command/AddTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

declare(strict_types=1);

namespace neto737\HestiaCP\Tests\Command;

use neto737\HestiaCP\Command\Add\User;
use neto737\HestiaCP\Command\Add\WebDomain;
use neto737\HestiaCP\Command\Add\WebDomainFtp;
Expand All @@ -10,9 +12,7 @@
use neto737\HestiaCP\Command\Add\MailDomain;
use neto737\HestiaCP\Command\Add\Database;

require_once __DIR__ . '/../vendor/autoload.php';

class commandAddTest extends \PHPUnit\Framework\TestCase {
class AddTest extends \PHPUnit\Framework\TestCase {

public function testUser(): void {
$command = new User('admin', 'pass', 'mail@domain.com');
Expand Down
6 changes: 3 additions & 3 deletions tests/commandBackupTest.php → tests/Command/BackupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace neto737\HestiaCP\Tests\Command;

use neto737\HestiaCP\Command\Backup\Users;
use neto737\HestiaCP\Command\Backup\User;

require_once __DIR__ . '/../vendor/autoload.php';

class commandBackupTest extends \PHPUnit\Framework\TestCase {
class BackupTest extends \PHPUnit\Framework\TestCase {

public function testBackupUsers(): void {
$command = new Users();
Expand Down
6 changes: 3 additions & 3 deletions tests/commandChangeTest.php → tests/Command/ChangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

declare(strict_types=1);

namespace neto737\HestiaCP\Tests\Command;

use neto737\HestiaCP\Command\Change\UserPassword;
use neto737\HestiaCP\Command\Change\MailAccountPassword;
use neto737\HestiaCP\Command\Change\WebDomainFtpPassword;
use neto737\HestiaCP\Command\Change\WebDomainFtpPath;

require_once __DIR__ . '/../vendor/autoload.php';

class commandChangeTest extends \PHPUnit\Framework\TestCase {
class ChangeTest extends \PHPUnit\Framework\TestCase {

public function testUserPassword(): void {
$command = new UserPassword('admin', 'pass');
Expand Down
6 changes: 3 additions & 3 deletions tests/commandDeleteTest.php → tests/Command/DeleteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

declare(strict_types=1);

namespace neto737\HestiaCP\Tests\Command;

use neto737\HestiaCP\Command\Delete\User;
use neto737\HestiaCP\Command\Delete\WebDomain;
use neto737\HestiaCP\Command\Delete\WebDomainFtp;
Expand All @@ -13,9 +15,7 @@
use neto737\HestiaCP\Command\Delete\Database;
use neto737\HestiaCP\Command\Delete\Databases;

require_once __DIR__ . '/../vendor/autoload.php';

class commandDeleteTest extends \PHPUnit\Framework\TestCase {
class DeleteTest extends \PHPUnit\Framework\TestCase {

public function testUser(): void {
$command = new User('admin');
Expand Down
6 changes: 3 additions & 3 deletions tests/commandListTest.php → tests/Command/ListsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

declare(strict_types=1);

namespace neto737\HestiaCP\Tests\Command;

use neto737\HestiaCP\Command\Lists\User;
use neto737\HestiaCP\Command\Lists\Users;
use neto737\HestiaCP\Command\Lists\WebDomains;
Expand All @@ -15,9 +17,7 @@
use neto737\HestiaCP\Command\Lists\Database;
use neto737\HestiaCP\Command\Lists\Databases;

require_once __DIR__ . '/../vendor/autoload.php';

class commandListTest extends \PHPUnit\Framework\TestCase {
class ListsTest extends \PHPUnit\Framework\TestCase {

public function testUser(): void {
$command = new User('admin');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

declare(strict_types=1);

namespace neto737\HestiaCP\Tests\Command;

use neto737\HestiaCP\Command\Suspend\User;
use neto737\HestiaCP\Command\Suspend\WebDomain;
use neto737\HestiaCP\Command\Suspend\MailAccount;
use neto737\HestiaCP\Command\Suspend\MailDomain;

require_once __DIR__ . '/../vendor/autoload.php';

class commandSuspendTest extends \PHPUnit\Framework\TestCase {
class SuspendTest extends \PHPUnit\Framework\TestCase {

public function testUser(): void {
$command = new User('admin');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace neto737\HestiaCP\Tests\Command;

use neto737\HestiaCP\Command\TestAuthorization;
use neto737\HestiaCP\Exceptions\InvalidResponseException;

require_once __DIR__ . '/../vendor/autoload.php';

class commandTest extends \PHPUnit\Framework\TestCase {
class TestAuthorizationTest extends \PHPUnit\Framework\TestCase {

public function testCommands(): void {
$command = new TestAuthorization();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

declare(strict_types=1);

namespace neto737\HestiaCP\Tests\Command;

use neto737\HestiaCP\Command\Unsuspend\User;
use neto737\HestiaCP\Command\Unsuspend\WebDomain;
use neto737\HestiaCP\Command\Unsuspend\MailAccount;
use neto737\HestiaCP\Command\Unsuspend\MailDomain;

require_once __DIR__ . '/../vendor/autoload.php';

class commandUnsuspendTest extends \PHPUnit\Framework\TestCase {
class UnsuspendTest extends \PHPUnit\Framework\TestCase {

public function testUser(): void {
$command = new User('admin');
Expand Down
6 changes: 3 additions & 3 deletions tests/moduleSendTest.php → tests/Module/ModuleSendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

declare(strict_types=1);

namespace neto737\HestiaCP\Tests\Module;

use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
Expand All @@ -16,16 +18,14 @@
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

require_once __DIR__ . '/../vendor/autoload.php';

/**
* Calls every module method through a mocked client and checks the request it sends and the value it returns.
* Arguments use distinct values (and non-default booleans) so a swapped or dropped argument fails here.
*
* @phpstan-type HistoryEntry array{request: RequestInterface, response: ResponseInterface|null, error: mixed, options: array<array-key, mixed>}
* @phpstan-type ModuleCall \Closure(Client): mixed
*/
class moduleSendTest extends \PHPUnit\Framework\TestCase {
class ModuleSendTest extends \PHPUnit\Framework\TestCase {

private const LIST_BODY = '{"first": {"NAME": "First"}, "second": {"NAME": "Second"}}';

Expand Down
6 changes: 3 additions & 3 deletions tests/moduleTest.php → tests/Module/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

declare(strict_types=1);

namespace neto737\HestiaCP\Tests\Module;

use neto737\HestiaCP\Client;
use neto737\HestiaCP\Module\Backups;
use neto737\HestiaCP\Module\Databases;
use neto737\HestiaCP\Module\Users;
use neto737\HestiaCP\Module\Webs;
use neto737\HestiaCP\Module\Mails;

require_once __DIR__ . '/../vendor/autoload.php';

class moduleTest extends \PHPUnit\Framework\TestCase {
class ModuleTest extends \PHPUnit\Framework\TestCase {

public function createClient(): Client {
return Client::simpleFactory('https://someHost', 'someUser', 'somePass');
Expand Down
Loading