當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。