@@ -501,7 +501,49 @@ public function testDestroyOtherSession() {
501501 ->method ('destroy ' )
502502 ->with ($ sessionId );
503503
504+ $ handler ->expects ($ this ->exactly (2 ))
505+ ->method ('write ' )
506+ ->with ($ this ->logicalOr (
507+ $ this ->equalTo ($ sessionId ),
508+ $ this ->equalTo ($ this ->tokenData [PluginSession::CLAIM_SESSION_ID ])
509+ ));
510+
511+ $ handler ->expects ($ this ->exactly (2 ))
512+ ->method ('open ' );
513+
504514 $ session ->destroySession ($ sessionHash );
505515 }
506516
517+ public function testDestroyOwnSession () {
518+
519+ $ sessionId = $ this ->tokenData [PluginSession::CLAIM_SESSION_ID ];
520+ $ this ->setupEnvironment (null , $ this ->token , false );
521+
522+ // successfull remote call handler mock
523+ $ handler = $ this ->getMockBuilder (SessionHandlerInterface::class)
524+ ->setMethodsExcept ()
525+ ->getMock ();
526+
527+ $ handler ->method ('close ' )->willReturn (true );
528+ $ handler ->method ('destroy ' )->willReturn (true );
529+ $ handler ->method ('open ' )->willReturn (true );
530+ $ handler ->method ('write ' )->willReturn (true );
531+ $ handler ->method ('read ' )->willReturn ($ sessionId );
532+
533+ /** @var PluginSession $session */
534+ $ session = new PluginSession ($ this ->pluginId , $ this ->publicKey , $ handler );
535+
536+ $ handler ->expects ($ this ->once ())
537+ ->method ('destroy ' )
538+ ->with ($ sessionId );
539+
540+ $ handler ->expects ($ this ->once ())
541+ ->method ('write ' )
542+ ->with ($ sessionId );
543+
544+ $ handler ->expects ($ this ->once ())
545+ ->method ('open ' );
546+
547+ $ session ->destroySession ($ sessionId );
548+ }
507549}
0 commit comments