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


PHP Input::swap方法代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\Input::swap方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::swap方法的具体用法?PHP Input::swap怎么用?PHP Input::swap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Facades\Input的用法示例。


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

示例1: setUp

 public function setUp()
 {
     parent::setUp();
     //Test parameters
     $this->params = ['_fields' => 'title,description,comments.title,user.first_name', 'title-lk' => 'Example Title|Another Title', 'title' => 'Example Title', 'title-not-lk' => 'Example Title', 'title-not' => 'Example Title|Another Title', 'id-min' => 5, 'id-max' => 6, 'id-gt' => 7, 'id-st' => 8, 'id-in' => '1,2', 'id-not-in' => '3,4', '_limit' => 5, '_offset' => 10, '_with' => 'comments.user', '_sort' => '-title,first_name,comments.created_at', '_config' => 'mode-default,meta-filter-count,meta-total-count'];
     $this->fulltextSelectExpression = new Expression('MATCH(title,description) AGAINST("Something to search" IN BOOLEAN MODE) as `_score`');
     //Test data
     $this->data = [['foo' => 'A1', 'bar' => 'B1'], ['foo' => 'A2', 'bar' => 'B2']];
     //Mock the application
     $app = m::mock('AppMock');
     $app->shouldReceive('instance')->once()->andReturn($app);
     Illuminate\Support\Facades\Facade::setFacadeApplication($app);
     //Mock the config
     $config = m::mock('ConfigMock');
     $config->shouldReceive('get')->once()->with('apihandler.prefix')->andReturn('_');
     $config->shouldReceive('get')->once()->with('apihandler.envelope')->andReturn(false);
     $config->shouldReceive('get')->once()->with('apihandler.fulltext')->andReturn('default');
     $config->shouldReceive('get')->once()->with('apihandler.fulltext')->andReturn('native');
     $config->shouldReceive('get')->once()->with('apihandler.fulltext_score_column')->andReturn('_score');
     Config::swap($config);
     $app->shouldReceive('make')->once()->andReturn($config);
     //Mock the input
     $input = m::mock('InputMock');
     $input->shouldReceive('get')->once()->with()->andReturn($this->params);
     Input::swap($input);
     //Mock the response
     $response = m::mock('ResponseMock');
     $response->shouldReceive('json')->once()->andReturn(new JsonResponse(['meta' => [], 'data' => new Collection()]));
     Response::swap($response);
     //Mock pdo
     $pdo = m::mock('PdoMock');
     $pdo->shouldReceive('quote')->once()->with('Something to search')->andReturn('Something to search');
     //Mock the connection the same way as laravel does:
     //tests/Database/DatabaseEloquentBuilderTest.php#L408-L418 (mockConnectionForModel($model, $database))
     $grammar = new Illuminate\Database\Query\Grammars\MySqlGrammar();
     $processor = new Illuminate\Database\Query\Processors\MySqlProcessor();
     $connection = m::mock('Illuminate\\Database\\ConnectionInterface', ['getQueryGrammar' => $grammar, 'getPostProcessor' => $processor]);
     $connection->shouldReceive('select')->once()->with('select * from `posts`', [])->andReturn($this->data);
     $connection->shouldReceive('select')->once()->with('select * from `posts`', [], true)->andReturn($this->data);
     $connection->shouldReceive('raw')->once()->with('MATCH(title,description) AGAINST("Something to search" IN BOOLEAN MODE) as `_score`')->andReturn($this->fulltextSelectExpression);
     $connection->shouldReceive('getPdo')->once()->andReturn($pdo);
     $resolver = m::mock('Illuminate\\Database\\ConnectionResolverInterface', ['connection' => $connection]);
     Post::setConnectionResolver($resolver);
     $this->apiHandler = new ApiHandler();
 }
开发者ID:marcelgwerder,项目名称:laravel-api-handler,代码行数:45,代码来源:ApiHandlerTest.php

示例2: it_uploads_the_image

 /**
  * @test
  *
  * @covers ::upload
  * @covers ::getUploadPath
  * @covers ::getUniqueFilename
  * @covers ::getUploadedFileInfo
  */
 public function it_uploads_the_image()
 {
     $file = new UploadedFile($this->testImage, 'ankit.png', 'image/png', filesize($this->testImage), null, true);
     //mock input
     $input = m::mock(Request::class);
     $input->shouldReceive('setUserResolver')->shouldReceive('file')->andReturn($file);
     Input::swap($input);
     $uploadServiceMock = m::mock('\\AnkitPokhrel\\LaravelImage\\ImageUploadService[_construct]', $this->validationRules);
     $this->assertTrue($uploadServiceMock->upload());
     $uploadedFileInfo = $uploadServiceMock->getUploadedFileInfo();
     foreach (['original_image_name', 'image', 'upload_dir', 'size', 'extension', 'mime_type'] as $key) {
         $this->assertArrayHasKey($key, $uploadedFileInfo);
     }
     return $uploadedFileInfo;
 }
开发者ID:ankitpokhrel,项目名称:laravel-image,代码行数:23,代码来源:ImageUploadServiceTest.php


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