本文整理匯總了PHP中Illuminate\Support\Facades\Config::swap方法的典型用法代碼示例。如果您正苦於以下問題:PHP Config::swap方法的具體用法?PHP Config::swap怎麽用?PHP Config::swap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\Config
的用法示例。
在下文中一共展示了Config::swap方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testRoles
public function testRoles()
{
/*
|------------------------------------------------------------
| Set
|------------------------------------------------------------
*/
$belongsToMany = new stdClass();
$user = m::mock('HasRoleUser')->makePartial();
$app = m::mock('app')->shouldReceive('instance')->getMock();
$config = m::mock('config');
Config::setFacadeApplication($app);
Config::swap($config);
/*
|------------------------------------------------------------
| Expectation
|------------------------------------------------------------
*/
$user->shouldReceive('belongsToMany')->with('role_table_name', 'assigned_roles_table_name', 'user_id', 'role_id')->andReturn($belongsToMany)->once();
Config::shouldReceive('get')->once()->with('entrust.role')->andReturn('role_table_name');
Config::shouldReceive('get')->once()->with('entrust.role_user_table')->andReturn('assigned_roles_table_name');
/*
|------------------------------------------------------------
| Assertion
|------------------------------------------------------------
*/
$this->assertSame($belongsToMany, $user->roles());
}
示例2: setUp
public function setUp()
{
parent::setUp();
$app = m::mock('AppMock');
$app->shouldReceive('instance')->once()->andReturn($app);
Illuminate\Support\Facades\Facade::setFacadeApplication($app);
Config::swap($config = m::mock('ConfigMock'));
}
示例3: testAllWorks
public function testAllWorks()
{
$this->prepareFakeData();
$app = m::mock('AppMock');
$app->shouldReceive('instance')->once()->andReturn($app);
\Illuminate\Support\Facades\Facade::setFacadeApplication($app);
\Illuminate\Support\Facades\Config::swap($config = m::mock('ConfigMock'));
$config->shouldReceive('get')->once()->andReturn(5);
$objs = $this->r->all();
$this->assertEquals(5, count($objs));
}
示例4: setUp
public function setUp()
{
parent::setUp();
$app = m::mock('app')->shouldReceive('instance')->getMock();
$this->facadeMocks['config'] = m::mock('config');
$this->facadeMocks['cache'] = m::mock('cache');
Config::setFacadeApplication($app);
Config::swap($this->facadeMocks['config']);
Cache::setFacadeApplication($app);
Cache::swap($this->facadeMocks['cache']);
}
示例5: testGetDescrizioneWorks
public function testGetDescrizioneWorks()
{
$prefisso = "it";
L::set($prefisso);
$desc_expected = "italiano";
$app = m::mock('AppMock');
$app->shouldReceive('instance')->once()->andReturn($app);
\Illuminate\Support\Facades\Facade::setFacadeApplication($app);
\Illuminate\Support\Facades\Config::swap($config = m::mock('ConfigMock'));
Config::shouldReceive(['get' => '', 'get' => $desc_expected]);
$desc = L::get_descrizione();
$this->assertEquals($desc, $desc_expected);
}
示例6: setUp
public function setUp()
{
parent::setUp();
//Test parameters
$this->params = ['_fields' => 'title,description,comments.title,user.first_name', 'title-lk' => 'Example Title|Another Title', 'title' => 'Example Title', 'title-not-lk' => 'Example Title', 'title-not' => 'Example Title|Another Title', 'id-min' => 5, 'id-max' => 6, 'id-gt' => 7, 'id-st' => 8, 'id-in' => '1,2', 'id-not-in' => '3,4', '_limit' => 5, '_offset' => 10, '_with' => 'comments.user', '_sort' => '-title,first_name,comments.created_at', '_config' => 'mode-default,meta-filter-count,meta-total-count'];
$this->fulltextSelectExpression = new Expression('MATCH(title,description) AGAINST("Something to search" IN BOOLEAN MODE) as `_score`');
//Test data
$this->data = [['foo' => 'A1', 'bar' => 'B1'], ['foo' => 'A2', 'bar' => 'B2']];
//Mock the application
$app = m::mock('AppMock');
$app->shouldReceive('instance')->once()->andReturn($app);
Illuminate\Support\Facades\Facade::setFacadeApplication($app);
//Mock the config
$config = m::mock('ConfigMock');
$config->shouldReceive('get')->once()->with('apihandler.prefix')->andReturn('_');
$config->shouldReceive('get')->once()->with('apihandler.envelope')->andReturn(false);
$config->shouldReceive('get')->once()->with('apihandler.fulltext')->andReturn('default');
$config->shouldReceive('get')->once()->with('apihandler.fulltext')->andReturn('native');
$config->shouldReceive('get')->once()->with('apihandler.fulltext_score_column')->andReturn('_score');
Config::swap($config);
$app->shouldReceive('make')->once()->andReturn($config);
//Mock the input
$input = m::mock('InputMock');
$input->shouldReceive('get')->once()->with()->andReturn($this->params);
Input::swap($input);
//Mock the response
$response = m::mock('ResponseMock');
$response->shouldReceive('json')->once()->andReturn(new JsonResponse(['meta' => [], 'data' => new Collection()]));
Response::swap($response);
//Mock pdo
$pdo = m::mock('PdoMock');
$pdo->shouldReceive('quote')->once()->with('Something to search')->andReturn('Something to search');
//Mock the connection the same way as laravel does:
//tests/Database/DatabaseEloquentBuilderTest.php#L408-L418 (mockConnectionForModel($model, $database))
$grammar = new Illuminate\Database\Query\Grammars\MySqlGrammar();
$processor = new Illuminate\Database\Query\Processors\MySqlProcessor();
$connection = m::mock('Illuminate\\Database\\ConnectionInterface', ['getQueryGrammar' => $grammar, 'getPostProcessor' => $processor]);
$connection->shouldReceive('select')->once()->with('select * from `posts`', [])->andReturn($this->data);
$connection->shouldReceive('select')->once()->with('select * from `posts`', [], true)->andReturn($this->data);
$connection->shouldReceive('raw')->once()->with('MATCH(title,description) AGAINST("Something to search" IN BOOLEAN MODE) as `_score`')->andReturn($this->fulltextSelectExpression);
$connection->shouldReceive('getPdo')->once()->andReturn($pdo);
$resolver = m::mock('Illuminate\\Database\\ConnectionResolverInterface', ['connection' => $connection]);
Post::setConnectionResolver($resolver);
$this->apiHandler = new ApiHandler();
}
示例7: setUp
public function setUp()
{
parent::setUp();
Config::swap(new ConfigStub());
}