コード例 #1
0
ファイル: NumericStringTest.php プロジェクト: afk11/phpasn1
 public function testCreateStringWithInvalidCharacters()
 {
     $invalidString = 'Hello World';
     try {
         $object = new NumericString($invalidString);
         $object->getBinary();
         $this->fail('Should have thrown an exception');
     } catch (\Exception $exception) {
         $this->assertEquals("Could not create a ASN.1 Numeric String from the character sequence '{$invalidString}'.", $exception->getMessage());
     }
     $invalidString = '123,456';
     try {
         $object = new NumericString($invalidString);
         $object->getBinary();
         $this->fail('Should have thrown an exception');
     } catch (\Exception $exception) {
         $this->assertEquals("Could not create a ASN.1 Numeric String from the character sequence '{$invalidString}'.", $exception->getMessage());
     }
     $invalidString = '+123456';
     try {
         $object = new NumericString($invalidString);
         $object->getBinary();
         $this->fail('Should have thrown an exception');
     } catch (\Exception $exception) {
         $this->assertEquals("Could not create a ASN.1 Numeric String from the character sequence '{$invalidString}'.", $exception->getMessage());
     }
     $invalidString = '-123456';
     try {
         $object = new NumericString($invalidString);
         $object->getBinary();
         $this->fail('Should have thrown an exception');
     } catch (\Exception $exception) {
         $this->assertEquals("Could not create a ASN.1 Numeric String from the character sequence '{$invalidString}'.", $exception->getMessage());
     }
 }