2017-04-25 03:53:04 +05:30
|
|
|
<?php
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace common\tests\_support;
|
2017-04-25 03:53:04 +05:30
|
|
|
|
|
|
|
use Codeception\Module;
|
|
|
|
use Codeception\TestInterface;
|
|
|
|
|
|
|
|
class Mockery extends Module {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var bool Run mockery expectations after test or not
|
|
|
|
*/
|
|
|
|
private $assert_mocks = true;
|
|
|
|
|
|
|
|
public function _before(TestInterface $test) {
|
|
|
|
\Mockery::globalHelpers();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function _after(TestInterface $test) {
|
|
|
|
if ($this->assert_mocks) {
|
|
|
|
\Mockery::close();
|
|
|
|
} else {
|
|
|
|
\Mockery::getContainer()->mockery_close();
|
|
|
|
\Mockery::resetContainer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function _failed(TestInterface $test, $fail) {
|
|
|
|
$this->assert_mocks = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|