diff --git a/composer.json b/composer.json index 0853854..643dced 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/tests/credentialTest.php b/tests/Authorization/CredentialsTest.php similarity index 95% rename from tests/credentialTest.php rename to tests/Authorization/CredentialsTest.php index 300546b..e5bbb84 100644 --- a/tests/credentialTest.php +++ b/tests/Authorization/CredentialsTest.php @@ -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(''); diff --git a/tests/hostTest.php b/tests/Authorization/HostTest.php similarity index 97% rename from tests/hostTest.php rename to tests/Authorization/HostTest.php index 01bed59..31a681e 100644 --- a/tests/hostTest.php +++ b/tests/Authorization/HostTest.php @@ -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('', ''); diff --git a/tests/clientSendTest.php b/tests/ClientSendTest.php similarity index 99% rename from tests/clientSendTest.php rename to tests/ClientSendTest.php index 1fb2df3..10b7c32 100644 --- a/tests/clientSendTest.php +++ b/tests/ClientSendTest.php @@ -2,6 +2,8 @@ declare(strict_types=1); +namespace neto737\HestiaCP\Tests; + use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Handler\MockHandler; use GuzzleHttp\HandlerStack; @@ -24,8 +26,6 @@ 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. @@ -33,7 +33,7 @@ * @phpstan-import-type ClientOptions from Client * @phpstan-type HistoryEntry array{request: RequestInterface, response: ResponseInterface|null, error: mixed, options: array} */ -class clientSendTest extends \PHPUnit\Framework\TestCase { +class ClientSendTest extends \PHPUnit\Framework\TestCase { /** @var array */ private array $history = []; diff --git a/tests/clientTest.php b/tests/ClientTest.php similarity index 94% rename from tests/clientTest.php rename to tests/ClientTest.php index 60bdf82..14c37fe 100644 --- a/tests/clientTest.php +++ b/tests/ClientTest.php @@ -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(''); diff --git a/tests/commandAddTest.php b/tests/Command/AddTest.php similarity index 97% rename from tests/commandAddTest.php rename to tests/Command/AddTest.php index 8247a00..cb1deb0 100644 --- a/tests/commandAddTest.php +++ b/tests/Command/AddTest.php @@ -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; @@ -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'); diff --git a/tests/commandBackupTest.php b/tests/Command/BackupTest.php similarity index 87% rename from tests/commandBackupTest.php rename to tests/Command/BackupTest.php index f344a69..4aa478e 100644 --- a/tests/commandBackupTest.php +++ b/tests/Command/BackupTest.php @@ -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(); diff --git a/tests/commandChangeTest.php b/tests/Command/ChangeTest.php similarity index 95% rename from tests/commandChangeTest.php rename to tests/Command/ChangeTest.php index 8d84e7d..3455e86 100644 --- a/tests/commandChangeTest.php +++ b/tests/Command/ChangeTest.php @@ -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'); diff --git a/tests/commandDeleteTest.php b/tests/Command/DeleteTest.php similarity index 97% rename from tests/commandDeleteTest.php rename to tests/Command/DeleteTest.php index 2c917f5..6195696 100644 --- a/tests/commandDeleteTest.php +++ b/tests/Command/DeleteTest.php @@ -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; @@ -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'); diff --git a/tests/commandListTest.php b/tests/Command/ListsTest.php similarity index 97% rename from tests/commandListTest.php rename to tests/Command/ListsTest.php index 67355aa..8ff3671 100644 --- a/tests/commandListTest.php +++ b/tests/Command/ListsTest.php @@ -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; @@ -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'); diff --git a/tests/commandSuspendTest.php b/tests/Command/SuspendTest.php similarity index 94% rename from tests/commandSuspendTest.php rename to tests/Command/SuspendTest.php index 66b0419..55e54c0 100644 --- a/tests/commandSuspendTest.php +++ b/tests/Command/SuspendTest.php @@ -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'); diff --git a/tests/commandTest.php b/tests/Command/TestAuthorizationTest.php similarity index 82% rename from tests/commandTest.php rename to tests/Command/TestAuthorizationTest.php index c2f5a55..f69838c 100644 --- a/tests/commandTest.php +++ b/tests/Command/TestAuthorizationTest.php @@ -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(); diff --git a/tests/commandUnsuspendTest.php b/tests/Command/UnsuspendTest.php similarity index 94% rename from tests/commandUnsuspendTest.php rename to tests/Command/UnsuspendTest.php index 4c53321..5c4c21a 100644 --- a/tests/commandUnsuspendTest.php +++ b/tests/Command/UnsuspendTest.php @@ -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'); diff --git a/tests/moduleSendTest.php b/tests/Module/ModuleSendTest.php similarity index 99% rename from tests/moduleSendTest.php rename to tests/Module/ModuleSendTest.php index 0fddb4c..0f68d06 100644 --- a/tests/moduleSendTest.php +++ b/tests/Module/ModuleSendTest.php @@ -2,6 +2,8 @@ declare(strict_types=1); +namespace neto737\HestiaCP\Tests\Module; + use GuzzleHttp\Handler\MockHandler; use GuzzleHttp\HandlerStack; use GuzzleHttp\Middleware; @@ -16,8 +18,6 @@ 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. @@ -25,7 +25,7 @@ * @phpstan-type HistoryEntry array{request: RequestInterface, response: ResponseInterface|null, error: mixed, options: array} * @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"}}'; diff --git a/tests/moduleTest.php b/tests/Module/ModuleTest.php similarity index 94% rename from tests/moduleTest.php rename to tests/Module/ModuleTest.php index a9183a1..250f22c 100644 --- a/tests/moduleTest.php +++ b/tests/Module/ModuleTest.php @@ -2,6 +2,8 @@ declare(strict_types=1); +namespace neto737\HestiaCP\Tests\Module; + use neto737\HestiaCP\Client; use neto737\HestiaCP\Module\Backups; use neto737\HestiaCP\Module\Databases; @@ -9,9 +11,7 @@ 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');