本文整理汇总了PHP中Mockery::getContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP Mockery::getContainer方法的具体用法?PHP Mockery::getContainer怎么用?PHP Mockery::getContainer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mockery
的用法示例。
在下文中一共展示了Mockery::getContainer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
if ($container = m::getContainer()) {
$this->addToAssertionCount($container->mockery_getExpectationCount());
}
parent::tearDown();
}
示例2: assertPostConditions
/**
* Performs assertions shared by all tests of a test case. This method is
* called before execution of a test ends and before the tearDown method.
*/
protected function assertPostConditions()
{
parent::assertPostConditions();
// Add Mockery expectations to assertion count.
if (($container = Mock::getContainer()) !== null) {
$this->addToAssertionCount($container->mockery_getExpectationCount());
}
}
示例3: setUp
protected function setUp()
{
// We intentionally test the static container here. That is what the
// listener will check.
$this->container = \Mockery::getContainer();
$this->listener = new \Mockery\Adapter\Phpunit\TestListener();
$this->testResult = new \PHPUnit_Framework_TestResult();
$this->test = new \Mockery_Adapter_Phpunit_EmptyTestCase();
$this->test->setTestResultObject($this->testResult);
$this->testResult->addListener($this->listener);
$this->assertTrue($this->testResult->wasSuccessful(), 'sanity check: empty test results should be considered successful');
}
示例4: endTest
/**
* After each test, perform Mockery verification tasks and cleanup the
* statically stored Mockery container for the next test.
*
* @param PHPUnit_Framework_Test $test
* @param float $time
*/
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
try {
$container = \Mockery::getContainer();
if ($container != null) {
$expectation_count = $container->mockery_getExpectationCount();
$test->addToAssertionCount($expectation_count);
}
\Mockery::close();
} catch (\Exception $e) {
$result = $test->getTestResultObject();
$result->addError($test, $e, $time);
}
}
示例5: endTest
/**
* After each test, perform Mockery verification tasks and cleanup the
* statically stored Mockery container for the next test.
*
* @param PHPUnit_Framework_Test $test
* @param float $time
*/
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
try {
$container = \Mockery::getContainer();
// check addToAssertionCount is important to avoid mask test errors
if ($container != null && method_exists($test, 'addToAssertionCount')) {
$expectation_count = $container->mockery_getExpectationCount();
$test->addToAssertionCount($expectation_count);
}
\Mockery::close();
} catch (\Exception $e) {
$result = $test->getTestResultObject();
$result->addError($test, $e, $time);
}
}
示例6: verifyMockObjects
protected function verifyMockObjects()
{
$container = Mockery::getContainer();
if (isset($container)) {
$reflected_container = new ReflectionClass($container);
$reflected_mocks = $reflected_container->getProperty('_mocks');
$reflected_mocks->setAccessible(true);
$mocks = $reflected_mocks->getValue($container);
foreach ($mocks as $mock) {
$reflected_mock = new ReflectionClass($mock);
$reflected_expectations = $reflected_mock->getProperty('_mockery_expectations');
$reflected_expectations->setAccessible(true);
$expectations = $reflected_expectations->getValue($mock);
foreach ($expectations as $director) {
$this->addToAssertionCount(count($director->getExpectations()));
}
}
Mockery::close();
}
parent::verifyMockObjects();
}
示例7: tearDown
public function tearDown()
{
$this->addToAssertionCount(Mockery::getContainer()->mockery_getExpectationCount());
Mockery::close();
}
示例8: ignoreAssertionsWhenExpectations
/**
* Do not check assertions were executed when there are constrainted mocks
*/
protected static function ignoreAssertionsWhenExpectations()
{
/** @var Mock $mock */
foreach (\Mockery::getContainer()->getMocks() as $mock) {
/** @var ExpectationDirector $expectationDirector */
foreach ($mock->mockery_getExpectations() as $expectationDirector) {
$expectations = $expectationDirector->getExpectations();
if (method_exists($expectationDirector, 'getDefaultExpectations')) {
//mockery <=0.9.5 compatibility
$expectations = array_merge($expectations, $expectationDirector->getDefaultExpectations());
}
/** @var Expectation $expectation */
foreach ($expectations as $expectation) {
if ($expectation->isCallCountConstrained()) {
Environment::$checkAssertions = FALSE;
return;
}
}
}
}
}