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


PHP Application::expects方法代码示例

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


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

示例1: testMethodCalls

 public function testMethodCalls()
 {
     $id = uniqid('testMethodCallId');
     $pass = [$id];
     $expect = [$id, $this];
     $this->applicationMock->expects($this->any())->method('make')->will($this->returnCallback(function ($make) {
         switch ($make) {
             case 'request':
                 return $this->requestMock;
             case 'commode.common.resolver':
                 return $this->resolver;
             case 'LaravelCommode\\Common\\Controllers\\CommodeControllerTest':
                 return $this;
         }
         dd(func_get_args());
     }));
     $this->requestMock->expects($this->at(0))->method('ajax')->will($this->returnValue(false));
     $this->requestMock->expects($this->at(1))->method('ajax')->will($this->returnValue(false));
     $this->requestMock->expects($this->at(2))->method('ajax')->will($this->returnValue(true));
     $resolveMethodsReflection = new ReflectionProperty($this->controller, 'resolveMethods');
     $resolveMethodsReflection->setAccessible(true);
     $resolveMethodsReflection->setValue($this->controller, false);
     $this->assertSame($pass, $this->controller->callAction('getSomeMethod', $pass));
     $resolveMethodsReflection->setValue($this->controller, true);
     $this->assertSame($expect, $this->controller->callAction('getSomeMethodResolve', $pass));
     $separateRequestsReflection = new ReflectionProperty($this->controller, 'separateRequests');
     $separateRequestsReflection->setAccessible(true);
     $separateRequestsReflection->setValue($this->controller, true);
     $this->requestMock->expects($this->any())->method('ajax')->will($this->returnValue(true));
     $this->assertSame($expect, $this->controller->callAction('getSomeMethodResolve', $pass));
 }
开发者ID:laravel-commode,项目名称:common,代码行数:31,代码来源:CommodeControllerTest.php

示例2: testRegistering

 public function testRegistering()
 {
     $singletonChecks = function ($serviceName, $callable) {
         switch ($serviceName) {
             case ValidationLocatorServiceProvider::PROVIDES_LOCATOR:
                 $this->testCreated = $callable();
                 break;
             case ValidationLocatorServiceProvider::PROVIDES_LOCATOR_INTERFACE:
                 $callable();
                 break;
         }
     };
     $makeCallback = function ($makingOf) {
         switch ($makingOf) {
             case 'db':
                 return $this->dbMock;
             case 'translator':
                 return $this->translatorMock;
             case 'laravel-commode.validation-locator':
                 return $this->testCreated;
         }
     };
     $this->application->expects($this->any())->method('singleton')->will($this->returnCallback($singletonChecks));
     $this->application->expects($this->any())->method('make')->will($this->returnCallback($makeCallback));
     $this->testInstance->registering();
 }
开发者ID:laravel-commode,项目名称:validation-locator,代码行数:26,代码来源:ValidationLocatorServiceProviderTest.php

示例3: testRegisterAbstract

 public function testRegisterAbstract()
 {
     $boundWith = function () {
         return true;
     };
     $boundWill = function ($serviceName) {
         switch ($serviceName) {
             case 'commode.common.loaded':
                 return false;
         }
         dd('bound', $serviceName);
         return true;
     };
     $makeWill = function ($make) {
         switch ($make) {
             case 'commode.common.ghostservice':
                 return $this->ghostServices;
                 break;
             case 'commode.common.resolver':
                 return $this->resolver;
                 break;
         }
         dd('make', func_get_args());
     };
     $this->applicationMock->expects($this->any())->method('getLoadedProviders')->will($this->returnValue([]));
     $this->applicationMock->expects($this->any())->method('bound')->with($this->callback($boundWith))->will($this->returnCallback($boundWill));
     $this->applicationMock->expects($this->any())->method('make')->will($this->returnCallback($makeWill));
     $this->ghostService->register();
     $this->commonGhostService->register();
 }
开发者ID:laravel-commode,项目名称:common,代码行数:30,代码来源:GhostServiceTest.php

示例4: testProvides

 public function testProvides()
 {
     $this->application->expects($this->any())->method('bind')->with(ResolverServiceProvider::PROVIDES_RESOLVER, $this->callback(function ($closure) {
         return $closure($this->application) instanceof Resolver;
     }));
     $this->application->expects($this->any())->method('alias')->with('CommodeResolver', ResolverFacade::class);
     $this->assertContains(ResolverServiceProvider::PROVIDES_RESOLVER, $this->testInstance->provides());
 }
开发者ID:laravel-commode,项目名称:resolver,代码行数:8,代码来源:ResolverServiceProviderTest.php

示例5: testRegistering

 public function testRegistering()
 {
     $registeringMethodReflection = new \ReflectionMethod($this->commodeService, 'registering');
     $registeringMethodReflection->setAccessible(true);
     $this->applicationMock->expects($this->at(0))->method('bindShared')->with($this->anything(), $this->callback(function ($closure) {
         $this->assertInstanceOf('LaravelCommode\\Common\\Resolver\\Resolver', $closure());
         return true;
     }));
     $this->applicationMock->expects($this->at(1))->method('bindShared')->with($this->anything(), $this->callback(function ($closure) {
         $this->assertInstanceOf('LaravelCommode\\Common\\GhostService\\GhostServices', $closure());
         return true;
     }));
     $registeringMethodReflection->invoke($this->commodeService);
 }
开发者ID:laravel-commode,项目名称:common,代码行数:14,代码来源:CommodeCommonServiceProviderTest.php

示例6: prepareApplication

 protected function prepareApplication()
 {
     /**
      * @param $whatToMake
      * @return $this
      * @throws Exception
      */
     $makeWill = function ($whatToMake) {
         switch ($whatToMake) {
             case 'LaravelCommode\\Resolver\\ResolverTest':
                 return $this;
             default:
                 throw new Exception("Unexpected {$whatToMake}");
         }
     };
     $this->applicationMock->expects($this->any())->method('make')->will($this->returnCallback($makeWill));
 }
开发者ID:laravel-commode,项目名称:resolver,代码行数:17,代码来源:ResolverTest.php

示例7: testRegister

 public function testRegister()
 {
     $filterRegistry = new FilterRegistry($this->routingMock, $this->resolverMock);
     $this->applicationMock->expects($this->once())->method('bind')->with(FiltersServiceProvider::InterfaceName, FiltersServiceProvider::ConcreteName);
     $this->applicationMock->expects($this->any())->method('make')->with(FiltersServiceProvider::InterfaceName)->will($this->returnCallback(function () use($filterRegistry) {
         return $filterRegistry;
     }));
     $this->applicationMock->expects($this->once())->method('bindShared')->with(FiltersServiceProvider::ServiceName, $this->callback(function ($callback) {
         $fR = $callback($this->applicationMock);
         $isok = $fR instanceof FilterRegistry;
         return true;
     }));
     $this->applicationMock->expects($this->once())->method('before')->will($this->returnCallback(function ($callback) {
         $callback();
         return null;
     }));
     $reflectionMethod = new \ReflectionMethod($this->testedService, 'registering');
     $reflectionMethod->setAccessible(true);
     $reflectionMethod->invokeArgs($this->testedService, []);
     $reflectionMethod = new \ReflectionMethod($this->testedService, 'launching');
     $reflectionMethod->setAccessible(true);
     $reflectionMethod->invokeArgs($this->testedService, []);
 }
开发者ID:laravel-commode,项目名称:filters,代码行数:23,代码来源:FiltersServiceProviderTest.php

示例8: testExtract

 public function testExtract()
 {
     $this->applicationMock->expects($this->at(0))->method('make')->with(get_class($this->testSubject))->will($this->returnValue($this->testSubject));
     $this->filterRegistry->extractArray([get_class($this->testSubject)]);
 }
开发者ID:laravel-commode,项目名称:filters,代码行数:5,代码来源:FilterRegistryTest.php


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