-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMockery.php
More file actions
45 lines (40 loc) · 997 Bytes
/
Mockery.php
File metadata and controls
45 lines (40 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Codeception\Module;
use Codeception\Module;
use Codeception\TestInterface;
use Exception;
/**
* Integrates [Mockery](https://github.com/padraic/mockery) into Codeception tests.
*
* Mockery is a simple yet flexible PHP mock object framework for use in unit testing.
*
* ## Status
*
* * Maintainer: **enumag**
* * Stability: **stable**
*
* ## Example (`unit.suite.yml`)
*
* modules:
* enabled: [Mockery]
*
* @author Jáchym Toušek <enumag@gmail.com>
*/
class Mockery extends Module
{
/** @var bool Run mockery expectations after test or not */
private $assert_mocks = true;
public function _after(TestInterface $test)
{
if ($this->assert_mocks) {
\Mockery::close();
} else {
\Mockery::getContainer()->mockery_close();
\Mockery::resetContainer();
}
}
public function _failed(TestInterface $test, Exception $fail)
{
$this->assert_mocks = false;
}
}