-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mgd-php/add-visible-string-type
Added ASN.1 VisibleString type
- Loading branch information
Showing
4 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Readdle\AppStoreReceiptVerification\ASN1\Universal; | ||
|
||
use Readdle\AppStoreReceiptVerification\ASN1\AbstractASN1Object; | ||
|
||
final class VisibleString extends AbstractASN1Object | ||
{ | ||
protected string $value = ''; | ||
|
||
protected function setValue($value): void | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
public function getValue(): string | ||
{ | ||
return $this->value; | ||
} | ||
|
||
public function jsonSerialize(): string | ||
{ | ||
return $this->value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Readdle\AppStoreReceiptVerification\Tests\Unit\ASN1\Universal; | ||
|
||
use Readdle\AppStoreReceiptVerification\ASN1\ASN1Identifier; | ||
use Readdle\AppStoreReceiptVerification\Tests\Unit\Traits\AsBinaryTestTrait; | ||
use Readdle\AppStoreReceiptVerification\Tests\Unit\Traits\StringTestTrait; | ||
use Readdle\AppStoreReceiptVerification\Tests\Unit\UnitTestCase; | ||
|
||
final class VisibleStringTest extends UnitTestCase | ||
{ | ||
use AsBinaryTestTrait; | ||
use StringTestTrait; | ||
|
||
public function testIdentifier(): void | ||
{ | ||
$this->assertEquals( | ||
ASN1Identifier::TYPE__VISIBLE_STRING, | ||
$this->createASN1Object(ASN1Identifier::TYPE__VISIBLE_STRING, 1)->getIdentifier()->getType() | ||
); | ||
} | ||
|
||
public function testStringLength(): void | ||
{ | ||
$this->performStringLengthTests(ASN1Identifier::TYPE__VISIBLE_STRING); | ||
} | ||
|
||
public function testJsonSerialize(): void | ||
{ | ||
$this->assertJsonSerializeResult(ASN1Identifier::TYPE__VISIBLE_STRING, '', ''); | ||
$this->assertJsonSerializeResult(ASN1Identifier::TYPE__VISIBLE_STRING, 'test', 'test'); | ||
} | ||
|
||
public function testAsBinary(): void | ||
{ | ||
$this->performAsBinaryTest(ASN1Identifier::TYPE__VISIBLE_STRING, 'test'); | ||
} | ||
} |