@@ -65,13 +65,10 @@ public function testSendActuallyWritesSerializedClosureToShmop(): void
6565
6666 $ raw = shmop_read ($ shmop , 0 , $ size );
6767 $ data = rtrim ($ raw , "\0" );
68- $ this ->assertIsString ($ data );
69-
7068 $ unserialized = unserialize ($ data );
7169 $ this ->assertInstanceOf (SerializableClosure::class, $ unserialized );
7270
73- $ func = $ unserialized ->getClosure ();
74- $ this ->assertIsCallable ($ func );
71+ $ unserialized ->getClosure ();
7572
7673 // shmop_delete($shmop);
7774 // shmop_close($shmop); // deprecated
@@ -90,32 +87,26 @@ public function testSendThrowsWhenShmopCannotBeCreated(): void
9087 }
9188
9289 /**
93- * @throws RandomException
90+ * @throws RandomException|Exception
9491 */
9592 public function testSendThrowsWhenNotAllBytesAreWritten (): void
9693 {
9794 $ key = ftok (__FILE__ , 'b ' ) ?: random_int (1 , 1000000 );
9895
9996 $ process = $ this ->getMockBuilder (Process::class)
10097 ->setConstructorArgs ([$ key ])
101- ->onlyMethods ([])
98+ ->onlyMethods ([' writeToShmop ' ])
10299 ->getMock ();
103100
104- serialize (new SerializableClosure (function () {
105- }));
106-
107- $ shmop = shmop_open ($ key , 'c ' , 0660 , 1 );
108- // shmop_close($shmop); // deprecated function
101+ $ process
102+ ->expects ($ this ->once ())
103+ ->method ('writeToShmop ' )
104+ ->willReturn (10 );
109105
110106 $ this ->expectException (Exception::class);
111107
112108 $ process ->send (function () {
113109 });
114-
115- $ this ->assertNotFalse ($ shmop );
116- if ($ shmop ) {
117- shmop_delete ($ shmop );
118- }
119110 }
120111
121112 /**
@@ -133,11 +124,9 @@ public function testSendDoesNotThrowOnSuccess(): void
133124 });
134125
135126 $ shmop = shmop_open ($ key , 'a ' , 0 , 0 );
136- if ($ shmop ) {
137- $ this ->assertTrue (shmop_delete ($ shmop ));
138- // shmop_close($shmop); // deprecated function
139- } else {
140- $ this ->expectNotToPerformAssertions ();
141- }
127+ $ this ->assertNotFalse ($ shmop , 'Shared memory should exist after send ' );
128+
129+ $ size = shmop_size ($ shmop );
130+ $ this ->assertGreaterThan (0 , $ size , 'Shared memory should contain data ' );
142131 }
143132}
0 commit comments