Skip to content

Commit

Permalink
Normalize license code #6722
Browse files Browse the repository at this point in the history
  • Loading branch information
afbora committed Oct 5, 2024
1 parent ec79ec4 commit b1d013e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Cms/License.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public function __construct(
protected string|null $date = null,
protected string|null $signature = null,
) {
// normalize the email address
$this->email = $this->email === null ? null : $this->normalizeEmail($this->email);
// normalize arguments
$this->code = $this->code !== null ? trim($this->code) : null;
$this->email = $this->email !== null ? $this->normalizeEmail($this->email) : null;
}

/**
Expand Down
17 changes: 17 additions & 0 deletions tests/Cms/System/LicenseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,23 @@ public function testLabel()
$this->assertSame('Unregistered', $license->label());
}

/**
* @covers ::__construct
* @covers ::normalizeEmail
*/
public function testNormalize()
{
$code = $this->code(LicenseType::Enterprise);

$license = new License(
code : ' ' . $code . ' ',
email: ' [email protected] '
);

$this->assertSame($code, $license->code());
$this->assertSame('[email protected]', $license->email());
}

/**
* @covers ::normalizeDomain
* @dataProvider providerForLicenseUrls
Expand Down

0 comments on commit b1d013e

Please sign in to comment.