当前位置: 首页>>代码示例>>PHP>>正文


PHP Test::double方法代码示例

本文整理汇总了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]);
 }
开发者ID:jjok,项目名称:Robo,代码行数:7,代码来源:SvnTest.php

示例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());
 }
开发者ID:delboy1978uk,项目名称:bone,代码行数:7,代码来源:BoneMvcApplicationTest.php

示例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');
 }
开发者ID:geekybeaver,项目名称:larasearch,代码行数:29,代码来源:ReindexJobTest.php

示例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');
 }
开发者ID:menthol,项目名称:Flexible,代码行数:35,代码来源:ReindexJobTest.php

示例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');
 }
开发者ID:sliver,项目名称:Robo,代码行数:7,代码来源:SemVerTest.php

示例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');
 }
开发者ID:helirexi,项目名称:magento-extension-base,代码行数:26,代码来源:DemoTest.php

示例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);
 }
开发者ID:menthol,项目名称:Flexible,代码行数:32,代码来源:DeleteJobTest.php

示例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);
 }
开发者ID:delboy1978uk,项目名称:phpbitcoin,代码行数:11,代码来源:ControlTest.php

示例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']);
 }
开发者ID:jjok,项目名称:Robo,代码行数:8,代码来源:BehatTest.php

示例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')]);
 }
开发者ID:jjok,项目名称:Robo,代码行数:8,代码来源:GulpTest.php

示例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]);
 }
开发者ID:Banjerr,项目名称:infusionPress_Forms,代码行数:8,代码来源:ServiceTest.php

示例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']);
 }
开发者ID:jjok,项目名称:Robo,代码行数:8,代码来源:BowerTest.php

示例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);
     }
 }
开发者ID:mpyw,项目名称:co,代码行数:9,代码来源:CoTest.php

示例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);
 }
开发者ID:boedy,项目名称:php-social-subscribe,代码行数:12,代码来源:InstagramAdapterTest.php

示例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'));
 }
开发者ID:marcellorvalle,项目名称:php-sandbox,代码行数:9,代码来源:CommonTest.php


注:本文中的AspectMock\Test::double方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。