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


PHP AspectMock\Test类代码示例

本文整理汇总了PHP中AspectMock\Test的典型用法代码示例。如果您正苦于以下问题:PHP Test类的具体用法?PHP Test怎么用?PHP Test使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Test类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: tearDown

 public function tearDown()
 {
     parent::tearDown();
     Mockery::close();
     Test::clean();
     $this->dropDatabase();
 }
开发者ID:estebanmatias92,项目名称:pull-automatically-galleries,代码行数:7,代码来源:TestCase.php

示例3: 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

示例4: 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

示例5: 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

示例6: testCreateController

 public function testCreateController()
 {
     Test::double('\\Twig_Loader_Filesystem');
     Test::double('\\Twig_Environment');
     Test::double('\\Twig_Extension_Debug');
     Test::double('\\Bone\\Mvc\\Controller', array('setTwig' => null));
     $factory = new ControllerFactory();
     $controller = $factory->create('\\Bone\\Mvc\\Controller', $this->request);
     $this->assertInstanceOf('\\Bone\\Mvc\\Controller', $controller);
 }
开发者ID:delboy1978uk,项目名称:bone,代码行数:10,代码来源:BoneMvcController.php

示例7: testUpdateListHasNothingToUpdate

 public function testUpdateListHasNothingToUpdate()
 {
     $userStubs = [['id' => 1], ['id' => 2]];
     $localCollectionStub = Test::double('PullAutomaticallyGalleries\\Database\\Eloquent\\Collection', ['diffByKey' => &$localCollectionStub, 'isEmpty' => true])->make();
     $remoteCollectionStub = Test::double('PullAutomaticallyGalleries\\Support\\Collection', ['diffByKey' => &$remoteCollectionStub, 'isEmpty' => true])->make();
     Gallery::shouldReceive('getByUsers')->with([1, 2])->once()->andReturn($localCollectionStub)->getMock();
     RemoteGallery::shouldReceive('getByUsers')->with($userStubs)->once()->andReturn($remoteCollectionStub);
     $this->call('POST', 'galleries', ['users' => $userStubs]);
     $this->assertRedirectedTo('users');
     $this->assertSessionHas('message', 'Has been removed 0 galleries and created 0 galleries');
 }
开发者ID:estebanmatias92,项目名称:pull-automatically-galleries,代码行数:11,代码来源:GalleryControllerTest.php

示例8: testConnectionStatusIsUpdatedWithFailureAfterConfigSave

 public function testConnectionStatusIsUpdatedWithFailureAfterConfigSave()
 {
     AspectMock\Test::double("Tinify\\Client", ["request" => function () {
         throw new Tinify\AccountException("help an error");
     }]);
     $this->configModel->setDataByPath(Model\Config::KEY_PATH, "my_new_key");
     $this->configModel->save();
     $label = $this->getObjectManager()->get("Magento\\Framework\\Data\\Form\\Element\\Label");
     $status = $this->getObjectManager()->get("Tinify\\Magento\\Model\\Config\\ConnectionStatusField");
     $this->assertEquals('<td class="value">' . '<div class="tinify-connection-status tinify-failure">' . '<div class="control-value">API connection unsuccessful.</div>' . '</div>' . '<p class="note"><span>Error: help an error</span></p>' . '</td>', $this->callMethod($status, "_renderValue", $label));
 }
开发者ID:tinify,项目名称:magento2-plugin,代码行数:11,代码来源:ConfigIntegrationTest.php

示例9: testMockingClassMethod

 public function testMockingClassMethod()
 {
     $this->initAspectMock();
     //$mock = \AspectMock\Test::double(MyClass::class, ['myClassMethod' => 'a']);
     $mock = \AspectMock\Test::double('MyClass', ['myClassMethod' => 'a']);
     //$mock = \AspectMock\Test::double('\MyClass', ['myClassMethod' => 'a']);
     $classMethodReturned = MyClass::myClassMethod();
     // Extra verification to see if the AspectMock double is actually being run yet:
     //$mock->verifyInvoked('myClassMethod');
     $this->assertEquals('a', $classMethodReturned);
 }
开发者ID:samsonasik,项目名称:AspectMock-test,代码行数:11,代码来源:MyClassTest.php

示例10: _after

 public function _after(\Codeception\TestCase $test)
 {
     // Ensure that $stopOnFail global static is reset, as tests
     // that set it to true will force an exception, and therefor
     // will not have a chance to clean this up.
     \Robo\Result::$stopOnFail = false;
     \AspectMock\Test::clean();
     $consoleOutput = new ConsoleOutput();
     static::$container->add('output', $consoleOutput);
     static::$container->add('logger', new \Consolidation\Log\Logger($consoleOutput));
 }
开发者ID:jjok,项目名称:Robo,代码行数:11,代码来源:CodeHelper.php

示例11: 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

示例12: 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

示例13: 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

示例14: _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

示例15: 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


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