@@ -22,58 +22,6 @@ public function testConstructor(): void
2222 $ this ->assertSame ($ id , $ envelope ->getId ());
2323 }
2424
25- public function testFromMessageWithStringId (): void
26- {
27- $ id = 'test-id ' ;
28- $ message = $ this ->createMessage ([IdEnvelope::MESSAGE_ID_KEY => $ id ]);
29-
30- $ envelope = IdEnvelope::fromMessage ($ message );
31-
32- $ this ->assertSame ($ id , $ envelope ->getId ());
33- }
34-
35- public function testFromMessageWithIntId (): void
36- {
37- $ id = 123 ;
38- $ message = $ this ->createMessage ([IdEnvelope::MESSAGE_ID_KEY => $ id ]);
39-
40- $ envelope = IdEnvelope::fromMessage ($ message );
41-
42- $ this ->assertSame ($ id , $ envelope ->getId ());
43- }
44-
45- public function testFromMessageWithNullId (): void
46- {
47- $ message = $ this ->createMessage ();
48-
49- $ envelope = IdEnvelope::fromMessage ($ message );
50-
51- $ this ->assertNull ($ envelope ->getId ());
52- }
53-
54- public function testFromMessageWithObjectHavingToString (): void
55- {
56- $ stringableObject = new class {
57- public function __toString (): string
58- {
59- return 'object-id ' ;
60- }
61- };
62- $ message = $ this ->createMessage ([IdEnvelope::MESSAGE_ID_KEY => $ stringableObject ]);
63- $ envelope = IdEnvelope::fromMessage ($ message );
64-
65- $ this ->assertSame ('object-id ' , $ envelope ->getId ());
66- }
67-
68- public function testFromMessageWithInvalidIdType (): void
69- {
70- $ invalidId = ['array-cannot-be-id ' ];
71- $ message = $ this ->createMessage ([IdEnvelope::MESSAGE_ID_KEY => $ invalidId ]);
72- $ message = IdEnvelope::fromMessage ($ message );
73-
74- $ this ->assertNull ($ message ->getId ());
75- }
76-
7725 public function testGetEnvelopeMetadata (): void
7826 {
7927 $ id = 'test-id ' ;
@@ -86,22 +34,6 @@ public function testGetEnvelopeMetadata(): void
8634 $ this ->assertSame ($ id , $ metadata [IdEnvelope::MESSAGE_ID_KEY ]);
8735 }
8836
89- public function testFromData (): void
90- {
91- $ type = 'test-handler ' ;
92- $ data = ['key ' => 'value ' ];
93- $ metadata = ['meta ' => 'data ' , IdEnvelope::MESSAGE_ID_KEY => 'test-id ' ];
94-
95- $ envelope = IdEnvelope::fromData ($ type , $ data , $ metadata );
96-
97- $ this ->assertInstanceOf (IdEnvelope::class, $ envelope );
98- $ this ->assertSame ($ type , $ envelope ->getType ());
99- $ this ->assertSame ($ data , $ envelope ->getData ());
100- $ this ->assertArrayHasKey ('meta ' , $ envelope ->getMetadata ());
101- $ this ->assertSame ('data ' , $ envelope ->getMetadata ()['meta ' ]);
102- $ this ->assertSame ('test-id ' , $ envelope ->getId ());
103- }
104-
10537 private function createMessage (array $ metadata = []): MessageInterface
10638 {
10739 return new Message ('test-handler ' , ['test-data ' ], $ metadata );
0 commit comments