Skip to content

Commit

Permalink
Merge pull request #716 from DirectoryTree/BUG-653
Browse files Browse the repository at this point in the history
Flush container on DirectoryFake::tearDown
  • Loading branch information
stevebauman authored May 13, 2024
2 parents d7c698e + 8963628 commit 8176872
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Testing/DirectoryFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ public static function tearDown(): void
{
foreach (static::$replaced as $name => $connection) {
Container::getConnection($name)->tearDown();
Container::addConnection($connection, $name);
}

Container::flush();

static::$replaced = [];
}

Expand Down
13 changes: 13 additions & 0 deletions tests/Unit/Testing/DirectoryFakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,17 @@ public function testSetupCreatesConnectedFakeConnectionAndLdapInstance()
$this->assertInstanceOf(ConnectionFake::class, $fake);
$this->assertInstanceOf(LdapFake::class, $fake->getLdapConnection());
}

public function testTearDownFlushesContainer()
{
Container::addConnection(new Connection);

DirectoryFake::setup();

$this->assertCount(1, Container::getConnections());

DirectoryFake::tearDown();

$this->assertCount(0, Container::getConnections());
}
}

0 comments on commit 8176872

Please sign in to comment.