Skip to content

Commit

Permalink
Clear descriptors after stop
Browse files Browse the repository at this point in the history
Thanks @cgimenes
  • Loading branch information
donatj committed Jan 22, 2024
1 parent e166c98 commit 1887dcb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/MockWebServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public function stop() : void {
foreach( $this->descriptors as $descriptor ) {
@fclose($descriptor);
}

$this->descriptors = [];
}

/**
Expand Down
20 changes: 20 additions & 0 deletions test/Regression/MockWebServer_RegressionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Test\Regression;

use donatj\MockWebServer\MockWebServer;
use PHPUnit\Framework\TestCase;

class MockWebServer_RegressionTest extends TestCase {

/**
* @doesNotPerformAssertions
*/
public function test_stopTwiceShouldNotExplode() : void {
$server = new MockWebServer;
$server->start();
$server->stop();
$server->stop();
}

}

0 comments on commit 1887dcb

Please sign in to comment.