本文整理汇总了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));
}
示例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();
}
示例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();
}
示例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());
}
示例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);
}
示例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));
}
示例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, []);
}
示例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)]);
}