本文整理汇总了PHP中AspectMock\Test::double方法的典型用法代码示例。如果您正苦于以下问题:PHP Test::double方法的具体用法?PHP Test::double怎么用?PHP Test::double使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AspectMock\Test
的用法示例。
在下文中一共展示了Test::double方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _before
protected function _before()
{
$progressBar = test::double('Symfony\\Component\\Console\\Helper\\ProgressBar');
$nullOutput = new \Symfony\Component\Console\Output\NullOutput();
$progressIndicator = new \Robo\Common\ProgressIndicator($progressBar, $nullOutput);
$this->svn = test::double('Robo\\Task\\Vcs\\SvnStack', ['executeCommand' => new \AspectMock\Proxy\Anything(), 'output' => $nullOutput, 'logger' => new \Psr\Log\NullLogger(), 'logger' => Robo::logger(), 'getConfig' => Robo::config(), 'progressIndicator' => $progressIndicator]);
}
示例2: testCanSetSail
public function testCanSetSail()
{
$config = array('routes' => array('/' => array('controller' => 'index', 'action' => 'index', 'params' => array())));
Test::double('\\Bone\\Mvc\\Request', ['getURI' => '/']);
Test::double('\\Bone\\Mvc\\Dispatcher', ['fireCannons' => null]);
$this->assertNull(Application::ahoy($config)->setSail());
}
示例3: it_should_fire_job_with_resolvable_models
/**
* @test
*/
public function it_should_fire_job_with_resolvable_models()
{
/**
*
* Set
*
*/
$model = m::mock('Husband');
$model->shouldReceive('refreshDoc')->with($model)->once();
$husband = am::double('Husband', ['findOrFail' => $model]);
$models = ['Husband:999'];
/**
*
* Expectation
*
*/
$job = m::mock('Illuminate\\Queue\\Jobs\\Job');
$job->shouldReceive('delete')->once();
/**
*
* Assertion
*
*/
with(new ReindexJob())->fire($job, $models);
$husband->verifyInvoked('findOrFail');
}
示例4: it_should_fire_job_with_resolvable_models
/**
* @test
*/
public function it_should_fire_job_with_resolvable_models()
{
/**
*
* Set
*
*/
$app = m::mock('Illuminate\\Foundation\\Application');
$config = m::mock('Menthol\\Flexible\\Config');
$logger = m::mock('Monolog\\Logger');
$model = m::mock('Husband');
$model->shouldReceive('refreshDoc')->with($model)->once();
$husband = am::double('Husband', ['findOrFail' => $model]);
$models = ['Husband:999'];
/**
*
* Expectation
*
*/
$logger->shouldReceive('info')->with('Indexing Husband with ID: 999');
$config->shouldReceive('get')->with('logger', 'menthol.flexible.logger')->andReturn('menthol.flexible.logger');
$app->shouldReceive('make')->with('menthol.flexible.logger')->andReturn($logger);
$job = m::mock('Illuminate\\Queue\\Jobs\\Job');
$job->shouldReceive('delete')->once();
/**
*
* Assertion
*
*/
with(new ReindexJob($app, $config))->fire($job, $models);
// $husband->verifyInvoked('findOrFail');
}
示例5: testSemver
public function testSemver()
{
$semver = test::double('Robo\\Task\\SemVerTask', ['dump' => null]);
$res = $this->taskSemVer()->increment('major')->prerelease('RC')->increment('patch')->run();
verify($res->getMessage())->equals('v1.0.1-RC.1');
$semver->verifyInvoked('dump');
}
示例6: testModelCall
public function testModelCall()
{
// This test demonstrates how to create a test double for Mage
// Normally you would be testing a separate classes method so
// some of the logic below would be in a separate file, obvs.
// Using PhpUnits mock builder we can create a stub object for
// a Magento core file. Which allows us to control what the
// method calls return and also assert they are invoked, etc.
$mockModel = $this->getMockBuilder('Mage_Catalog_Model_Product')->setMethods(array('getSku'))->getMock();
$mockModel->expects($this->once())->method('getSku')->will($this->returnValue('123456789'));
// Because getting a model in Magento consists of a static call
// it makes testing difficult. To counter this we are using a
// library called AspectMock which uses Go! AOP to allow us to
// create test doubles for static method calls. WIN!
$modelStub = test::double('Mage', ['getModel' => $mockModel]);
// This is the logic we would be testing
$model = Mage::getModel('catalog/product');
$sku = $model->getSku();
// Because our $modelStub returned our $mockModel when Mage::getModel()
// is called $model is the same as our $mockModel. By calling getSku()
// we are using the stubbed model method which returns our defined result.
$this->assertSame('123456789', $sku);
// We will also want to assert that the stubbed static method was
// actually called.
$modelStub->verifyInvokedOnce('getModel', 'catalog/product');
}
示例7: it_should_fire_job
/**
* @test
*/
public function it_should_fire_job()
{
/**
*
* Set
*
*/
$app = m::mock('Illuminate\\Foundation\\Application');
$config = m::mock('Menthol\\Flexible\\Config');
$logger = m::mock('Monolog\\Logger');
am::double('Husband', ['deleteDoc' => true]);
$job = m::mock('Illuminate\\Queue\\Jobs\\Job');
$models = ['Husband:999'];
/**
*
* Expectation
*
*/
$logger->shouldReceive('info')->with('Deleting Husband with ID: 999 from Elasticsearch');
$config->shouldReceive('get')->with('logger', 'menthol.flexible.logger')->andReturn('menthol.flexible.logger');
$app->shouldReceive('make')->with('menthol.flexible.logger')->andReturn($logger);
$job->shouldReceive('delete')->once();
/**
*
* Assertion
*
*/
with(new DeleteJob($app, $config))->fire($job, $models);
}
示例8: testStop
/**
* Test shutting down the bitcoin server
* Fake client so it doesnt really shut down
*/
public function testStop()
{
Test::double('Del\\Bitcoin\\Api\\AbstractApi', ['send' => null]);
$this->api = new Control($this->config);
$result = $this->api->stop();
$this->assertNull($result);
}
示例9: testBehatCommand
public function testBehatCommand()
{
$behat = test::double('Robo\\Task\\Testing\\Behat', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]);
$task = (new \Robo\Task\Testing\Behat('behat'))->stopOnFail()->noInteraction()->colors();
verify($task->getCommand())->equals('behat run --stop-on-failure --no-interaction --colors');
$task->run();
$behat->verifyInvoked('executeCommand', ['behat run --stop-on-failure --no-interaction --colors']);
}
示例10: testGulpRun
public function testGulpRun()
{
$gulp = test::double('Robo\\Task\\Gulp\\Run', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]);
$task = (new \Robo\Task\Gulp\Run('default', 'gulp'))->simple();
verify($task->getCommand())->equals($this->adjustQuotes('gulp "default" --tasks-simple'));
$task->run();
$gulp->verifyInvoked('executeCommand', [$this->adjustQuotes('gulp "default" --tasks-simple')]);
}
示例11: setUp
public function setUp()
{
$token = new \Infusionsoft\Token(['access_token' => 'foo', 'expires_in' => 3600]);
$this->ifs = new Infusionsoft();
$this->ifs->setToken($token);
$this->endpoint = 'https://api.infusionsoft.com/crm/xmlrpc/v1?access_token=foo';
$this->transport = test::double('fXmlRpc\\Transport\\GuzzleBridge', ['send' => true]);
}
示例12: testBowerUpdate
public function testBowerUpdate()
{
$bower = test::double('Robo\\Task\\Bower\\Update', ['executeCommand' => null]);
$task = new \Robo\Task\Bower\Update('bower');
$task->setLogger(new \Psr\Log\NullLogger());
$task->run();
$bower->verifyInvoked('executeCommand', ['bower update']);
}
示例13: _before
public function _before()
{
test::double('mpyw\\Co\\Internal\\TypeUtils', ['isCurl' => function ($arg) {
return $arg instanceof \DummyCurl;
}]);
if (!defined('CURLMOPT_MAX_TOTAL_CONNECTIONS')) {
define('CURLMOPT_MAX_TOTAL_CONNECTIONS', 13);
}
}
示例14: testUnsuccessfulUnsubscribe
/**
* @expectedException \Boedy\Subscription\SubscriptionErrorException
*/
public function testUnsuccessfulUnsubscribe()
{
$parameters = array('client_id' => '123456789', 'client_secret' => 'abcdefghij');
//return 400 response
Test::double('\\Boedy\\Http\\Request\\Delete', ['exec' => new HttpResponse('header', 'body', 400)]);
$factory = new HttpRequestFactory();
$instagramAdapter = new InstagramAdapter($factory);
$instagramAdapter->unsubscribe($parameters);
}
示例15: testUsingLinuxDirectorySeparator
public function testUsingLinuxDirectorySeparator()
{
test::double('mrv\\Autoloader\\Common', ['getSeparator' => '/']);
$desiredPath = '/path/to/some/namespace/file.php';
$this->assertEquals($desiredPath, Common::convertPathAccordingSO('\\path\\to\\some\\namespace\\file.php'));
$this->assertEquals($desiredPath, Common::convertPathAccordingSO('\\path\\to\\some\\namespace\\file.php'));
$this->assertEquals($desiredPath, Common::convertPathAccordingSO('/path/to\\some/namespace\\file.php'));
$this->assertEquals($desiredPath, Common::convertPathAccordingSO('/path/to/some/namespace/file.php'));
}