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


PHP App::shouldReceive方法代码示例

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


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

示例1: testCommands

 /**
  * Do the Artisan commands fire?
  */
 public function testCommands()
 {
     $self = $this;
     $this->prepareSpecify();
     $this->specify('Boots', function () use($self) {
         $target = $self->getProvider(['package']);
         $target->shouldReceive('package');
         $target->boot();
     });
     $this->prepareSpecify();
     $this->specify('Identifies provisions', function () use($self) {
         $target = $self->getProvider();
         verify($target->provides())->notEmpty();
     });
     $this->prepareSpecify();
     $this->specify('Binds to application', function () use($self) {
         App::shouldReceive('bind')->with('/^toolbox\\.commands\\./', Mockery::on(function ($closure) {
             $command = $closure();
             verify_that('is a command', is_a($command, 'Illuminate\\Console\\Command'));
             return true;
         }));
         Event::shouldReceive('listen')->with('toolbox.build', Mockery::on(function ($closure) {
             $app = Mockery::mock('Illuminate\\Console\\Application[call]');
             $app->shouldReceive('call');
             $command = $closure($app);
             return true;
         }));
         $target = $self->getProvider(['commands']);
         $target->shouldReceive('commands')->with(Mockery::type('array'));
         $target->register();
     });
 }
开发者ID:impleri,项目名称:laravel-toolbox,代码行数:35,代码来源:ProviderTest.php

示例2: testItRunAuditingEnableConsole

 public function testItRunAuditingEnableConsole()
 {
     App::shouldReceive('runningInConsole')->once()->andReturn(true);
     Config::shouldReceive('get')->once()->with('auditing.audit_console')->andReturn(true);
     $model = new AuditableModel();
     $this->assertTrue($model->isAuditEnabled());
 }
开发者ID:owen-it,项目名称:laravel-auditing,代码行数:7,代码来源:AuditableTest.php

示例3: testPushCommand

 /**
  * Integration Test.
  */
 public function testPushCommand()
 {
     $configuration_file = ['bypass' => false, 'default' => 'AwsS3', 'url' => 'https://s3.amazonaws.com', 'threshold' => 10, 'providers' => ['aws' => ['s3' => ['region' => 'us-standard', 'version' => 'latest', 'buckets' => ['my-bucket-name' => '*'], 'acl' => 'public-read', 'cloudfront' => ['use' => false, 'cdn_url' => ''], 'metadata' => [], 'expires' => gmdate('D, d M Y H:i:s T', strtotime('+5 years')), 'cache-control' => 'max-age=2628000', 'version' => '']]], 'include' => ['directories' => [__DIR__], 'extensions' => [], 'patterns' => []], 'exclude' => ['directories' => [], 'files' => [], 'extensions' => [], 'patterns' => [], 'hidden' => true]];
     $m_consol = M::mock('Symfony\\Component\\Console\\Output\\ConsoleOutput');
     $m_consol->shouldReceive('writeln')->atLeast(1);
     $finder = new \Vinelab\Cdn\Finder($m_consol);
     $asset = new \Vinelab\Cdn\Asset();
     $provider_factory = new \Vinelab\Cdn\ProviderFactory();
     $m_config = M::mock('Illuminate\\Config\\Repository');
     $m_config->shouldReceive('get')->with('cdn')->once()->andReturn($configuration_file);
     $helper = new \Vinelab\Cdn\CdnHelper($m_config);
     $m_console = M::mock('Symfony\\Component\\Console\\Output\\ConsoleOutput');
     $m_console->shouldReceive('writeln')->atLeast(2);
     $m_validator = M::mock('Vinelab\\Cdn\\Validators\\Contracts\\ProviderValidatorInterface');
     $m_validator->shouldReceive('validate');
     $m_helper = M::mock('Vinelab\\Cdn\\CdnHelper');
     $m_spl_file = M::mock('Symfony\\Component\\Finder\\SplFileInfo');
     $m_spl_file->shouldReceive('getPathname')->andReturn('vinelab/cdn/tests/Vinelab/Cdn/AwsS3ProviderTest.php');
     $m_spl_file->shouldReceive('getRealPath')->andReturn(__DIR__ . '/AwsS3ProviderTest.php');
     // partial mock
     $p_aws_s3_provider = M::mock('\\Vinelab\\Cdn\\Providers\\AwsS3Provider[connect]', array($m_console, $m_validator, $m_helper));
     $m_s3 = M::mock('Aws\\S3\\S3Client')->shouldIgnoreMissing();
     $m_s3->shouldReceive('factory')->andReturn('Aws\\S3\\S3Client');
     $m_command = M::mock('Aws\\Command');
     $m_s3->shouldReceive('getCommand')->andReturn($m_command);
     $m_s3->shouldReceive('execute');
     $p_aws_s3_provider->setS3Client($m_s3);
     $p_aws_s3_provider->shouldReceive('connect')->andReturn(true);
     \Illuminate\Support\Facades\App::shouldReceive('make')->once()->andReturn($p_aws_s3_provider);
     $cdn = new \Vinelab\Cdn\Cdn($finder, $asset, $provider_factory, $helper);
     $result = $cdn->push();
     assertEquals($result, true);
 }
开发者ID:filipegar,项目名称:cdn,代码行数:36,代码来源:CdnTest.php

示例4: testCreateThrowsExceptionWhenMissingDefaultConfiguration

 /**
  * @expectedException \Publiux\laravelcdn\Exceptions\MissingConfigurationException
  */
 public function testCreateThrowsExceptionWhenMissingDefaultConfiguration()
 {
     $configurations = ['default' => ''];
     $m_aws_s3 = M::mock('Publiux\\laravelcdn\\Providers\\AwsS3Provider');
     \Illuminate\Support\Facades\App::shouldReceive('make')->once()->andReturn($m_aws_s3);
     $this->provider_factory->create($configurations);
 }
开发者ID:publiux,项目名称:laravelcdn,代码行数:10,代码来源:ProviderFactoryTest.php

示例5: it_should_fire_job_with_unresolvable_models

 /**
  * @test
  */
 public function it_should_fire_job_with_unresolvable_models()
 {
     /**
      *
      * Set
      *
      */
     App::shouldReceive('make')->with('menthol.flexible.proxy', Mockery::any())->once()->andReturn('mock');
     $app = m::mock('Illuminate\\Foundation\\Application');
     $config = m::mock('Menthol\\Flexible\\Config');
     $logger = m::mock('Monolog\\Logger');
     $job = m::mock('Illuminate\\Queue\\Jobs\\Job');
     $models = ['Husband:99999'];
     /**
      *
      * Expectation
      *
      */
     $logger->shouldReceive('info')->with('Indexing Husband with ID: 99999');
     $logger->shouldReceive('error')->with('Indexing Husband with ID: 99999 failed: No query results for model [Husband].');
     $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();
     $job->shouldReceive('release')->with(60)->once();
     /**
      *
      * Assertion
      *
      */
     with(new ReindexJob($app, $config))->fire($job, $models);
 }
开发者ID:menthol,项目名称:Flexible,代码行数:34,代码来源:ReindexJobTest.php

示例6: it_should_transform

 /**
  * @test
  */
 public function it_should_transform()
 {
     /**
      *
      * Set
      *
      */
     $husband = m::mock('Husband')->makePartial();
     /**
      *
      * Expectation
      *
      */
     $husband->shouldReceive('load->toArray')->once()->andReturn('mock');
     $config = m::mock('Menthol\\Flexible\\Config');
     App::shouldReceive('make')->with('Menthol\\Flexible\\Config')->andReturn($config);
     $config->shouldReceive('get')->with('/paths\\..*/')->once();
     /**
      *
      * Assertion
      *
      */
     $transformed = $husband->transform(true);
     $this->assertEquals('mock', $transformed);
 }
开发者ID:menthol,项目名称:Flexible,代码行数:28,代码来源:TransformableTraitTest.php

示例7: testInstallationAlreadyCompleted

 public function testInstallationAlreadyCompleted()
 {
     $this->mockAccountManagementService->shouldReceive('totalNumberOfAccounts')->andReturn(1);
     App::shouldReceive('abort')->with(404)->once();
     $this->middleware->handle('request', function () {
     });
 }
开发者ID:kamaroly,项目名称:shift,代码行数:7,代码来源:InstallationMiddlewareTest.php

示例8: it_should_bind_index

 /**
  * @test
  */
 public function it_should_bind_index()
 {
     /**
      * Set
      */
     App::clearResolvedInstances();
     App::shouldReceive('make')->with('menthol.flexible.index', m::any())->once()->andReturn('mock');
     App::shouldReceive('make')->with('Elasticsearch')->twice()->andReturn('mock');
     $config = m::mock('Menthol\\Flexible\\Config');
     App::shouldReceive('make')->with('Menthol\\Flexible\\Config')->once()->andReturn($config);
     $config->shouldReceive('get')->with('elasticsearch.index_prefix', '')->andReturn('');
     $model = m::mock('Illuminate\\Database\\Eloquent\\Model');
     $model->shouldReceive('getTable')->once()->andReturn('mockType');
     $app = m::mock('LaravelApp');
     $proxy = m::mock('Menthol\\Flexible\\Proxy', [$model]);
     $sp = m::mock('Menthol\\Flexible\\FlexibleServiceProvider[bindIndex]', [$app]);
     /**
      * Expectation
      */
     $app->shouldReceive('bind')->once()->andReturnUsing(function ($name, $closure) use($app, $proxy) {
         $this->assertEquals('menthol.flexible.index', $name);
         $this->assertInstanceOf('Menthol\\Flexible\\Index', $closure($app, ['proxy' => $proxy, 'name' => 'name']));
     });
     /**
      * Assertion
      */
     $sp->bindIndex();
 }
开发者ID:menthol,项目名称:Flexible,代码行数:31,代码来源:FlexibleServiceProviderTest.php

示例9: is_active_calls_is_active_method

 /** @test */
 public function is_active_calls_is_active_method()
 {
     $activeMock = Mockery::mock(Active::class);
     $activeMock->shouldReceive('isActive')->once()->with(['foo'])->andReturn('bar');
     App::shouldReceive('make')->once()->with('active')->andReturn($activeMock);
     $result = is_active('foo');
     $this->assertEquals('bar', $result);
 }
开发者ID:antoinemy,项目名称:folio-laravel,代码行数:9,代码来源:helpersTest.php

示例10: UserTransformer

 /** @test */
 function it_instantiates_the_transformer_if_a_model_uses_the_trait_and_was_defined_in_the_config()
 {
     $user = $this->makeUsers(1, true);
     $user->unsetTransformerProperty();
     Config::shouldReceive('has')->twice()->with('transformers.transformers')->andReturn(true);
     Config::shouldReceive('get')->twice()->with('transformers.transformers')->andReturn([User::class => UserTransformer::class]);
     App::shouldReceive('make')->once()->with(UserTransformer::class)->andReturn(new UserTransformer());
     $this->assertInstanceOf(UserTransformer::class, $user->getTransformer());
 }
开发者ID:logaretm,项目名称:transformers,代码行数:10,代码来源:TransformableTest.php

示例11: testGetService

 public function testGetService()
 {
     // Arrange
     App::shouldReceive('make')->once()->with(\Exception::class)->andReturn(new \Exception());
     $stub = new ModelStub();
     // Act
     $exception = $stub->exception;
     // Assert
     $this->assertInstanceOf(\Exception::class, $exception);
 }
开发者ID:mrgrain,项目名称:eloquent-service-injection,代码行数:10,代码来源:ServiceInjectionTraitTest.php

示例12: UserTransformer

 /** @test */
 function it_transforms_nested_relations()
 {
     $this->makeUserWithPosts();
     $user = User::first();
     $transformer = new UserTransformer();
     App::shouldReceive('make')->once()->with(PostTransformer::class)->andReturn(new PostTransformer());
     App::shouldReceive('make')->once()->with(TagTransformer::class)->andReturn(new TagTransformer());
     $transformedData = $transformer->with('posts.tags')->transform($user);
     $this->assertCount(3, $transformedData['posts']);
     $this->assertCount(4, $transformedData['posts'][0]['tags']);
 }
开发者ID:logaretm,项目名称:transformers,代码行数:12,代码来源:TransformerTest.php

示例13: testRegister

 public function testRegister()
 {
     $this->provider->shouldReceive('mergeConfigFrom')->with(Mockery::type('string'), 'ray_emitter')->once();
     App::shouldReceive('singleton')->with('rayemitter.store', Mockery::on(function ($closure) {
         $result = $closure();
         expect_that($result);
         expect($result instanceof Store)->true();
         return true;
     }))->once();
     expect_not($this->provider->register());
 }
开发者ID:C4Tech,项目名称:laravel-ray-emitter,代码行数:11,代码来源:ServiceProviderTest.php

示例14: test_handle_action

 public function test_handle_action()
 {
     $params = ['model' => $this->user, 'id' => null, 'parent_data' => [], 'additional_assigns' => [], 'belongsTo' => null];
     App::shouldReceive('make')->once()->with('http_method', $params)->andReturn($this->http_method);
     $this->http_method->shouldReceive('handleRequest')->andReturn('json string');
     //since api base controller is protected, we have to use reflection magic
     $reflector = new ReflectionClass(new ApiBaseController());
     $handleAction = $reflector->getMethod('handleAction');
     $handleAction->setAccessible(true);
     $handleAction->invoke(new ApiBaseController(), $this->user);
 }
开发者ID:indatus,项目名称:ranger,代码行数:11,代码来源:ApiBaseControllerTest.php

示例15: testFormValidation

 public function testFormValidation()
 {
     $route = m::mock('Route');
     $route->shouldReceive('getAction')->andReturn(array('controller' => 'indexRule'));
     $request = m::mock('Request');
     $request->shouldReceive('all')->andReturn(array('name' => 'test'));
     App::shouldReceive('make')->andReturn(new FormStub());
     Validator::shouldReceive('make')->andReturn(new ValidatorClass($this->getRealTranslator(), $request->all(), array('name' => array('required', 'min:5'))));
     $controller = new RESTControllerStub();
     $controller->validateRequest($route, $request);
 }
开发者ID:andizzle,项目名称:rest-framework,代码行数:11,代码来源:RESTControllerTest.php


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