Add PHPUnit test suite

- Add PHPUnit 11.0 as dev dependency
- Add phpunit.xml configuration
- Add DTO tests (LicenseInfo, LicenseStatus, ActivationResult)
- Add Exception tests (factory method, all exception types)
- Add LicenseClient tests with mocked HTTP responses
- Update README with testing instructions
- Update CHANGELOG

32 tests, 93 assertions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-22 16:05:28 +01:00
parent 47317abf56
commit af735df260
11 changed files with 2335 additions and 2 deletions

View File

@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace Magdev\WcLicensedProductClient\Tests\Dto;
use Magdev\WcLicensedProductClient\Dto\ActivationResult;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
#[CoversClass(ActivationResult::class)]
final class ActivationResultTest extends TestCase
{
#[Test]
public function itCanBeCreatedFromArrayWithSuccess(): void
{
$data = [
'success' => true,
'message' => 'License activated successfully.',
];
$result = ActivationResult::fromArray($data);
self::assertTrue($result->success);
self::assertSame('License activated successfully.', $result->message);
}
#[Test]
public function itCanBeCreatedFromArrayWithAlreadyActivated(): void
{
$data = [
'success' => true,
'message' => 'License is already activated for this domain.',
];
$result = ActivationResult::fromArray($data);
self::assertTrue($result->success);
self::assertSame('License is already activated for this domain.', $result->message);
}
}