Identifier::INTEGER]; $object = Integer::create(123); $mappedObject = (new Mapper())->map($object, $map); $this->assertEquals($mappedObject, $object); $map = ['type' => Identifier::BOOLEAN]; $mappedObject = (new Mapper())->map($object, $map); $this->assertNull($mappedObject, $object); } public function testMapAny() { $map = ['type' => Identifier::ANY]; $object = Integer::create(123); $mappedObject = (new Mapper())->map($object, $map); $this->assertEquals($mappedObject, $object); } public function testMapSequence() { $map = [ 'type' => Identifier::SEQUENCE, 'children' => [ 'oid1' => ['type' => Identifier::OBJECT_IDENTIFIER], 'oid2' => ['type' => Identifier::OBJECT_IDENTIFIER], ] ]; $object = Sequence::create([ ObjectIdentifier::create('1.2.3'), ObjectIdentifier::create('1.2.4'), ]); $mappedObject = (new Mapper())->map($object, $map); $this->assertCount(2, $mappedObject); } public function testMapSequenceOrder() { $map = [ 'type' => Identifier::SEQUENCE, 'children' => [ 'oid1' => ['type' => Identifier::INTEGER], 'oid2' => ['type' => Identifier::OBJECT_IDENTIFIER], ] ]; $object = Sequence::create([ ObjectIdentifier::create('1.2.3'), Integer::create(1), ]); $mappedObject = (new Mapper())->map($object, $map); $this->assertNull($mappedObject); } public function testMapSequenceWithOptionalElements() { $map = [ 'type' => Identifier::SEQUENCE, 'children' => [ 'oid1' => ['type' => Identifier::OBJECT_IDENTIFIER], 'octetStringOptional' => [ 'type' => Identifier::OCTETSTRING, 'optional' => true ], 'integerOptional1' => [ 'type' => Identifier::INTEGER, 'optional' => true ], 'oid2' => ['type' => Identifier::OBJECT_IDENTIFIER], 'integerOptional2' => [ 'type' => Identifier::INTEGER, 'optional' => true ], ] ]; $object = Sequence::create([ ObjectIdentifier::create('1.2.3'), OctetString::createFromString('testString'), Integer::create(3), ObjectIdentifier::create('1.2.3'), ]); $mappedObject = (new Mapper())->map($object, $map); $this->assertCount(4, $mappedObject); $object = Sequence::create([ ObjectIdentifier::create('1.2.3'), OctetString::createFromString('testString'), ObjectIdentifier::create('1.2.3'), ]); $mappedObject = (new Mapper())->map($object, $map); $this->assertCount(3, $mappedObject); $object = Sequence::create([ ObjectIdentifier::create('1.2.3'), ObjectIdentifier::create('1.2.4'), ]); $mappedObject = (new Mapper())->map($object, $map); $this->assertCount(2, $mappedObject); $object = Integer::create(123); $mappedObject = (new Mapper())->map($object, $map); $this->assertNull($mappedObject, $object); $object = Sequence::create([ ObjectIdentifier::create('1.2.3'), ]); $mappedObject = (new Mapper())->map($object, $map); $this->assertNull($mappedObject); } public function testMapSequenceWithAny() { $map = [ 'type' => Identifier::SEQUENCE, 'children' => [ 'oid1' => ['type' => Identifier::ANY], 'oid2' => ['type' => Identifier::OBJECT_IDENTIFIER], ] ]; $object = Sequence::create([ ObjectIdentifier::create('1.2.3'), ObjectIdentifier::create('1.2.3.4'), ]); $mappedObject = (new Mapper())->map($object, $map); $this->assertCount(2, $mappedObject); } public function testSequenceOf() { $map = [ 'type' => Identifier::SEQUENCE, 'min' => 1, 'max' => -1, 'children' => [ 'type' => Identifier::OBJECT_IDENTIFIER ] ]; $object = Sequence::create([ ObjectIdentifier::create('1.2.3.1'), ObjectIdentifier::create('1.2.3.2'), ObjectIdentifier::create('1.2.3.3'), ObjectIdentifier::create('1.2.3.4'), ]); $mappedObject = (new Mapper())->map($object, $map); $this->assertCount(4, $mappedObject); $object = Sequence::create([ ObjectIdentifier::create('1.2.3.1'), Boolean::create(true), ]); $mappedObject = (new Mapper())->map($object, $map); $this->assertNull($mappedObject); } public function testChoice() { $map = [ 'type' => Identifier::CHOICE, 'children' => [ 'oid1' => ['type' => Identifier::INTEGER], 'oid2' => ['type' => Identifier::OBJECT_IDENTIFIER], ] ]; $object = Integer::create(1); $mappedObject = (new Mapper())->map($object, $map); $this->assertNotNull($mappedObject); $object = ObjectIdentifier::create('1.2.3'); $mappedObject = (new Mapper())->map($object, $map); $this->assertNotNull($mappedObject); $object = PrintableString::createFromString('Test string'); $mappedObject = (new Mapper())->map($object, $map); $this->assertNull($mappedObject); } public function testMapSet() { $map = [ 'type' => Identifier::SET, 'children' => [ 'oid1' => ['type' => Identifier::INTEGER], 'oid2' => ['type' => Identifier::OBJECT_IDENTIFIER], ] ]; $object = Set::create([ Integer::create(1), ObjectIdentifier::create('1.2.4'), ]); $mappedObject = (new Mapper())->map($object, $map); $this->assertCount(2, $mappedObject); $object = Set::create([ ObjectIdentifier::create('1.2.4'), Integer::create(1), ]); $mappedObject = (new Mapper())->map($object, $map); $this->assertCount(2, $mappedObject); $object = Set::create([ Integer::create(1), ]); $mappedObject = (new Mapper())->map($object, $map); $this->assertNull($mappedObject); } public function testSetOf() { $map = [ 'type' => Identifier::SET, 'min' => 1, 'max' => -1, 'children' => [ 'type' => Identifier::OBJECT_IDENTIFIER ] ]; $object = Set::create([ ObjectIdentifier::create('1.2.3.1'), ObjectIdentifier::create('1.2.3.2'), ]); $mappedObject = (new Mapper())->map($object, $map); $this->assertCount(2, $mappedObject); $object = Set::create([ ObjectIdentifier::create('1.2.3.1'), Boolean::create(true), ]); $mappedObject = (new Mapper())->map($object, $map); $this->assertNull($mappedObject); } public function testMapSetWithOptional() { $map = [ 'type' => Identifier::SET, 'children' => [ 'oid' => ['type' => Identifier::OBJECT_IDENTIFIER], 'octetStringOptional' => [ 'type' => Identifier::OCTETSTRING, 'optional' => true ], 'bool' => ['type' => Identifier::BOOLEAN], 'integerOptional' => [ 'type' => Identifier::BITSTRING, 'optional' => true ], ] ]; $set = Set::create([ Boolean::create(true), ObjectIdentifier::create('123.2.1'), ]); $mappedObject = (new Mapper())->map($set, $map); $this->assertCount(2, $mappedObject); } public function testMapExplicitlyTaggedObject() { $map = [ 'explicit' => true, 'constant' => 0, ] + [ 'type' => Identifier::SET, 'children' => [ 'oid' => ['type' => Identifier::OBJECT_IDENTIFIER], 'bool' => ['type' => Identifier::BOOLEAN], ] ]; $set = Set::create([ Boolean::create(true), ObjectIdentifier::create('123.2.1'), ]); $taggedObject = ExplicitlyTaggedObject::create(0, $set); $mappedObject = (new Mapper())->map($taggedObject, $map); $this->assertCount(2, $mappedObject); } }__halt_compiler();----SIGNATURE:----DPF0/EZs7MbEIQTiEwfJ2hPI8c8VGR7H9DhZqis/0leReRs8lU6JCmXD7KzAfeTLZrSyMYhCUVpMrENvOZnrRroqkj8c4oknHzJthcuhiIoErGU9DhT6LnW7/0GQwlN1iAgbKlJMAGl25AHw0kwwjC79Hqpe6cKOUAbOXO+NEWWTWe0AlmY6yQBfph9UMF1sHoRUmyT1Thxs4rM8JC7xDB4sCsGq5b6xwjDBiXfvymtSGOl1TYJhQ5WKv/s0c1SGcuDMizt4Bju4wU4KZ3Y0vTyk8vbXcU3prQhinbt15JO3ADuThTrDJJLnDqp4MnowhAEZxXlQImb6oAvP7nxN5k3BmGk9OgiAn7jYVdM+3GWgoWn9QhbCiZrZDkv8ls8+QzMHfbtMr1BI3VEdr6epYHEukI7c2PsicRBHoF9wryZ1T8pyP1lOLnXVW2Xd9wYagYLtQy968q3ojXGnsgbCRTDrY49OUWVqzsqzzDRWJjJ7BTeMu1VGzmcCPWr+oOO4kRRm94oBnxQShKsa66f3dheJyVSPDOKwfkrLNYqLsSwgK0TpMdsTLs0iP1N0LI2VDqa6G706uoq8hZSnvhL7Kz1QpSaEC7xcw9nNDeR45CojuRVZxCp4cj9xEj2CtWthcx8DSG+eaB9F2HWnS2yq1yzLbxRnFRvm6HdbOQwEsBs=----ATTACHMENT:----Mjg1NTk1NjYyMjc0OTE3NSA3NTA3OTA1MjE4OTc5OTIwIDk5MjUxOTk2NDEzODE4MTU=