本文整理汇总了PHP中Illuminate\Support\Facades\App::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP App::instance方法的具体用法?PHP App::instance怎么用?PHP App::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\App
的用法示例。
在下文中一共展示了App::instance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLeadSourceIndex
public function testLeadSourceIndex()
{
// Given
$mockNumberList = Mockery::mock();
$mockNumber = Mockery::mock();
$mockNumber->friendly_name = '(555) 444 444';
$mockNumber->region = 'Some region';
$mockNumber->phone_number = '+1555444444';
$mockNumbers = [$mockNumber];
$mockNumberList->available_phone_numbers = $mockNumbers;
$mockTwilio = Mockery::mock('Services_Twilio');
$mockTwilio->account = Mockery::mock();
$mockTwilio->account->available_phone_numbers = Mockery::mock();
$mockTwilio->account->available_phone_numbers->shouldReceive('getList')->with('US', 'Local', ['AreaCode' => null])->andReturn($mockNumberList);
App::instance('Twilio', $mockTwilio);
$newLeadSource = new LeadSource(['number' => '+136428733', 'description' => 'Some billboard somewhere', 'forwarding_number' => '+13947283']);
$newLeadSource->save();
// When
$newResponse = $this->call('GET', route('dashboard'));
// Then
$newLeadSources = $newResponse->getOriginalContent()['leadSources'];
$this->assertCount(1, $newLeadSources);
$this->assertEquals($newLeadSources[0]['number'], '+136428733');
$this->assertEquals($newLeadSources[0]['description'], 'Some billboard somewhere');
$this->assertEquals($newLeadSources[0]['forwarding_number'], '+13947283');
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$data = $request->except("_token");
$data['user']['id'] = 1;
App::instance(SmsCourierInterface::class, new Mitake_SMS($this->apiKey));
event(new SendSMSEvent($data));
$user = User::find($data['user']['id']);
echo "<pre>";
return json_encode($user->sms()->get(), JSON_PRETTY_PRINT);
}
示例3: testIndex
public function testIndex()
{
// Given
$mockNumber = Mockery::mock();
$mockNumber->friendlyName = '(555) 444 444';
$mockNumber->region = 'Some region';
$mockNumber->phoneNumber = '+1555444444';
$mockNumbers = [$mockNumber];
$mockTwilioClient = Mockery::mock(Client::class);
$mockUsPhones = Mockery::mock();
$mockTwilioClient->shouldReceive("availablePhoneNumbers")->withAnyArgs("US")->andReturn($mockUsPhones);
$mockUsPhones->local = Mockery::mock();
$mockUsPhones->local->shouldReceive('stream')->andReturn($mockNumbers);
App::instance(Client::class, $mockTwilioClient);
//Then
$this->visit(route('available_number.index'))->assertViewHas("numbers", $mockNumbers);
}
示例4: testDestroy
public function testDestroy()
{
// Given
Session::start();
$this->assertCount(0, LeadSource::all());
$newLeadSource = new LeadSource(['number' => '+136428733', 'description' => 'Some billboard somewhere', 'forwarding_number' => '+13947283']);
$newLeadSource->save();
$this->assertCount(1, LeadSource::all());
$mockNumber = Mockery::mock();
$mockNumber->sid = 'sup3runiq3s1d';
$mockTwilioClient = Mockery::mock(Client::class);
$mockPhoneToDelete = Mockery::mock(IncomingPhoneNumberInstance::class);
$mockPhoneToDelete->shouldReceive("delete")->once();
$mockTwilioClient->incomingPhoneNumbers = Mockery::mock(IncomingPhoneNumberList::class);
$mockTwilioClient->incomingPhoneNumbers->shouldReceive('read')->withAnyArgs()->once()->andReturn([0 => $mockPhoneToDelete]);
App::instance(Client::class, $mockTwilioClient);
// When
$response = $this->call('DELETE', route('lead_source.destroy', [$newLeadSource]), ['_token' => Session::token()]);
// Then
$this->assertCount(0, LeadSource::all());
}
示例5: it_show_IfCanBeBoughtByTheCurrentUser
/**
* @test
**/
public function it_show_IfCanBeBoughtByTheCurrentUser()
{
$authenticator = m::mock('StdClass')->shouldReceive("check")->once()->andReturn(true)->shouldReceive('hasGroup')->andReturn(true)->getMock();
App::instance('authenticator', $authenticator);
$presenter = new PresenterProducts([]);
$can_buy = $presenter->canBeBought();
$this->assertTrue($can_buy);
}
示例6: mockGetTokenWithError
private function mockGetTokenWithError()
{
$mock_auth = m::mock('StdClass')->shouldReceive('getToken')->once()->andThrow(new UserNotFoundException())->getMock();
App::instance('authenticator', $mock_auth);
}
示例7: prepareMiddleware
/**
* Prepares / Disables route middlewares.
*
* @param bool $disable
*
* @return void
*/
public function prepareMiddleware($disable = true)
{
App::instance('middleware.disable', true);
}