Файл: gapps/vendor/mockery/mockery/tests/Mockery/SpyTest.php
Строк: 56
<?php
namespace testMockery;
use Mockery as m;
use MockerySpy;
class SpyTest extends PHPUnit_Framework_TestCase
{
public function setup()
{
$this->container = new MockeryContainer;
}
public function teardown()
{
$this->container->mockery_close();
}
/** @test */
public function itVerifiesAMethodWasCalled()
{
$spy = m::spy();
$spy->myMethod();
$spy->shouldHaveReceived("myMethod");
$this->setExpectedException("MockeryExceptionInvalidCountException");
$spy->shouldHaveReceived("someMethodThatWasNotCalled");
}
/** @test */
public function itVerifiesAMethodWasNotCalled()
{
$spy = m::spy();
$spy->shouldNotHaveReceived("myMethod");
$this->setExpectedException("MockeryExceptionInvalidCountException");
$spy->myMethod();
$spy->shouldNotHaveReceived("myMethod");
}
/** @test */
public function itVerifiesAMethodWasNotCalledWithParticularArguments()
{
$spy = m::spy();
$spy->myMethod(123, 456);
$spy->shouldNotHaveReceived("myMethod", array(789, 10));
$this->setExpectedException("MockeryExceptionInvalidCountException");
$spy->shouldNotHaveReceived("myMethod", array(123, 456));
}
/** @test */
public function itVerifiesAMethodWasCalledASpecificNumberOfTimes()
{
$spy = m::spy();
$spy->myMethod();
$spy->myMethod();
$spy->shouldHaveReceived("myMethod")->twice();
$this->setExpectedException("MockeryExceptionInvalidCountException");
$spy->myMethod();
$spy->shouldHaveReceived("myMethod")->twice();
}
/** @test */
public function itVerifiesAMethodWasCalledWithSpecificArguments()
{
$spy = m::spy();
$spy->myMethod(123, "a string");
$spy->shouldHaveReceived("myMethod")->with(123, "a string");
$spy->shouldHaveReceived("myMethod", array(123, "a string"));
$this->setExpectedException("MockeryExceptionInvalidCountException");
$spy->shouldHaveReceived("myMethod")->with(123);
}
}