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