Skip to content

Commit

Permalink
Merge pull request #15 from markhuot/clear-out-mocks
Browse files Browse the repository at this point in the history
clear mocks out of the container after each test
  • Loading branch information
markhuot authored Jan 26, 2024
2 parents bfe1808 + a7c69d0 commit 23e7ecb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/test/Mocks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace markhuot\craftpest\test;

use Craft;
use Mockery\MockInterface;

trait Mocks
{
public function tearDownMocks(): void
{
foreach (Craft::$container->getDefinitions() as $class => $definition) {
if ($definition instanceof MockInterface) {
Craft::$container->clear($class);
}
}
}
}
1 change: 1 addition & 0 deletions src/test/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class TestCase extends \PHPUnit\Framework\TestCase
CookieState,
DatabaseAssertions,
Dd,
Mocks,
RequestBuilders,
SnapshotAssertions,
WithExceptionHandling;
Expand Down

0 comments on commit 23e7ecb

Please sign in to comment.