本文整理汇总了PHP中Mockery::setContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP Mockery::setContainer方法的具体用法?PHP Mockery::setContainer怎么用?PHP Mockery::setContainer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mockery
的用法示例。
在下文中一共展示了Mockery::setContainer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExistingStaticMethodMocking
/** @group issue/175 */
public function testExistingStaticMethodMocking()
{
\Mockery::setContainer($this->container);
$mock = $this->container->mock('MockeryTest_PartialStatic[mockMe]');
$mock->shouldReceive('mockMe')->with(5)->andReturn(10);
$this->assertEquals(10, $mock::mockMe(5));
$this->assertEquals(3, $mock::keepMe(3));
}
示例2: testCallingSelfOnlyReturnsLastMockCreatedOrCurrentMockBeingProgrammedSinceTheyAreOneAndTheSame
/**
* @issue issue/35
*/
public function testCallingSelfOnlyReturnsLastMockCreatedOrCurrentMockBeingProgrammedSinceTheyAreOneAndTheSame()
{
\Mockery::setContainer($this->container);
$m = $this->container->mock('MockeryTestFoo');
$this->assertFalse($this->container->self() instanceof MockeryTestFoo2);
//$m = $this->container->mock('MockeryTestFoo2');
//$this->assertTrue($this->container->self() instanceof MockeryTestFoo2);
//$m = $this->container->mock('MockeryTestFoo');
//$this->assertFalse(\Mockery::self() instanceof MockeryTestFoo2);
//$this->assertTrue(\Mockery::self() instanceof MockeryTestFoo);
\Mockery::resetContainer();
}
示例3: testCreatingMockOfClassWithExistingToStringMethodDoesntCreateClassWithTwoToStringMethods
/**
* @issue issue/89
*/
public function testCreatingMockOfClassWithExistingToStringMethodDoesntCreateClassWithTwoToStringMethods()
{
\Mockery::setContainer($this->container);
$m = $this->container->mock('MockeryTest_WithToString');
// this would fatal
$m->shouldReceive("__toString")->andReturn('dave');
$this->assertEquals("dave", "{$m}");
}
示例4: testClassDeclaringUnsetDoesNotThrowException
/**
* @issue issue/21
*/
public function testClassDeclaringUnsetDoesNotThrowException()
{
\Mockery::setContainer($this->container);
$m = $this->container->mock('MockeryTest_UnsetMethod');
$this->container->mockery_verify();
\Mockery::resetContainer();
}