public function testGetBinary()
 {
     $tag = 0x1;
     $string = new PrintableString('test');
     $expectedType = chr(Identifier::create(Identifier::CLASS_CONTEXT_SPECIFIC, $isConstructed = true, $tag));
     $expectedLength = chr($string->getObjectLength());
     $encodedStringObject = $string->getBinary();
     $object = new ExplicitlyTaggedObject($tag, $string);
     $this->assertBinaryEquals($expectedType . $expectedLength . $encodedStringObject, $object->getBinary());
 }
Beispiel #2
0
 public function testCreateStringWithInvalidCharacters()
 {
     $invalidString = 'Hello ♥♥♥ World';
     try {
         $object = new PrintableString($invalidString);
         $object->getBinary();
         $this->fail('Should have thrown an exception');
     } catch (\Exception $exception) {
         $this->assertEquals("Could not create a ASN.1 Printable String from the character sequence '{$invalidString}'.", $exception->getMessage());
     }
 }