本文整理汇总了PHP中Illuminate\Support\Facades\Config::shouldReceive方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::shouldReceive方法的具体用法?PHP Config::shouldReceive怎么用?PHP Config::shouldReceive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Config
的用法示例。
在下文中一共展示了Config::shouldReceive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
// set up config
Config::shouldReceive('get')->zeroOrMoreTimes()->with("datatable::engine")->andReturn(array('exactWordSearch' => false));
$this->collection = new Collection();
$this->engine = new CollectionEngine($this->collection);
}
示例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());
}
示例3: testGetOwner
public function testGetOwner()
{
Config::shouldReceive('get')->once()->with('auth.model')->andReturn('TestUser');
$stub = m::mock('TestUserTeamTraitStub[hasOne]');
$stub->shouldReceive('hasOne')->once()->with('User', 'user_id', 'owner_id')->andReturn([]);
$this->assertEquals([], $stub->owner());
}
示例4: 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());
}
示例5: setupBuilder
protected function setupBuilder($showAllRecords = false)
{
Config::shouldReceive('get');
$cache = m::mock('stdClass');
$driver = m::mock('stdClass');
$data = [['id' => 1, 'name' => 'foo'], ['id' => 2, 'name' => 'bar']];
$builder = m::mock('Illuminate\\Database\\Query\\Builder');
$builder->shouldReceive('select')->once()->with(['id', 'name'])->andReturn($builder);
$builder->shouldReceive('from')->once()->with('users')->andReturn($builder);
$builder->shouldReceive('get')->once()->andReturn($data);
$builder->columns = ['id', 'name'];
$builder->select(['id', 'name'])->from('users');
// ******************************
// Datatables::of() mocks
// ******************************
$builder->shouldReceive('getConnection')->andReturn(m::mock('Illuminate\\Database\\Connection'));
$builder->shouldReceive('toSql')->times(6)->andReturn('select id, name from users');
$builder->getConnection()->shouldReceive('raw')->once()->andReturn('select \'1\' as row_count');
$builder->shouldReceive('select')->once()->andReturn($builder);
$builder->getConnection()->shouldReceive('raw')->andReturn('(select id, name from users) count_row_table');
$builder->shouldReceive('select')->once()->andReturn($builder);
$builder->getConnection()->shouldReceive('table')->times(2)->andReturn($builder);
$builder->shouldReceive('getBindings')->times(2)->andReturn([]);
$builder->shouldReceive('setBindings')->times(2)->with([])->andReturn($builder);
// ******************************
// Datatables::make() mocks
// ******************************
if (!$showAllRecords) {
$builder->shouldReceive('skip')->once()->andReturn($builder);
$builder->shouldReceive('take')->once()->andReturn($builder);
}
$builder->shouldReceive('count')->times(2)->andReturn(2);
return $builder;
}
示例6: setupBuilder
protected function setupBuilder($showAllRecords = false)
{
Config::shouldReceive('get');
$cache = m::mock('stdClass');
$driver = m::mock('stdClass');
$data = [['id' => 1, 'name' => 'foo'], ['id' => 2, 'name' => 'bar']];
$builder = m::mock('Illuminate\\Database\\Query\\Builder');
$builder->shouldReceive('getGrammar')->once()->andReturn($builder);
$builder->shouldReceive('getTablePrefix')->once()->andReturn($builder);
$builder->shouldReceive('getConnection')->andReturn(m::mock('Illuminate\\Database\\Connection'));
$builder->getConnection()->shouldReceive('getDriverName')->once()->andReturn('dbdriver');
// setup builder
$builder->shouldReceive('select')->once()->with(['id', 'name'])->andReturn($builder);
$builder->shouldReceive('from')->once()->with('users')->andReturn($builder);
$builder->columns = ['id', 'name'];
$builder->select(['id', 'name'])->from('users');
// count total records
$builder->shouldReceive('toSql')->times(2)->andReturn('select id, name from users');
$builder->shouldReceive('select')->once()->andReturn($builder);
$builder->getConnection()->shouldReceive('raw')->once()->andReturn('select \'1\' as row_count');
$builder->getConnection()->shouldReceive('table')->once()->andReturn($builder);
$builder->getConnection()->shouldReceive('raw')->andReturn('(select id, name from users) count_row_table');
$builder->shouldReceive('toSql')->once()->andReturn('select id, name from users');
$builder->shouldReceive('getBindings')->once()->andReturn([]);
$builder->shouldReceive('setBindings')->once()->with([])->andReturn($builder);
$builder->shouldReceive('count')->once()->andReturn(2);
// get data
$builder->shouldReceive('get')->once()->andReturn($data);
// pagination
if (!$showAllRecords) {
$builder->shouldReceive('skip')->once()->andReturn($builder);
$builder->shouldReceive('take')->once()->andReturn($builder);
}
return $builder;
}
示例7: testGetModelClassFoundation
public function testGetModelClassFoundation()
{
$class = 'C4tech\\Magic';
Config::shouldReceive('get')->with('upload.models.upload', 'upload.models.upload')->once()->andReturn('C4tech\\Silly');
Config::shouldReceive('get')->with('foundation.models.upload', 'C4tech\\Silly')->once()->andReturn($class);
expect($this->repo->getModelClass())->equals($class);
}
示例8: it_creates_the_user_relationship
/**
* @test
*/
public function it_creates_the_user_relationship()
{
Config::shouldReceive('get')->once()->with('eloquent-sentiment.user')->andReturn('UserClass');
$sentiment = m::mock(Sentiment::class)->makePartial();
$sentiment->shouldReceive('belongsTo')->once()->andReturn('ok');
$this->assertEquals($sentiment->user(), 'ok');
}
示例9: testToArrayJsonify
public function testToArrayJsonify()
{
$this->model->test_thing = 123;
$this->model->shouldReceive('convertToCamelCase')->with(['test_thing' => 123])->once()->andReturn(false);
Config::shouldReceive('get')->with('c4tech.jsonify_output', true)->once()->andReturn(true);
expect($this->model->toArray())->false();
}
示例10: testListenToUploadModelClosure
public function testListenToUploadModelClosure()
{
$model = Mockery::mock('UploadableModel');
$repository = Mockery::mock('C4tech\\Upload\\Contracts\\UploadInterface');
$repository->id = 16;
$tags = ['tags'];
$upload = Mockery::mock('UploadInstance');
$uploadable = Mockery::mock('C4tech\\Upload\\Contracts\\UploadableModelInterface');
$this->repo->shouldReceive('getModelClass')->withNoArgs()->once()->andReturn($model);
Config::shouldReceive('get')->with('app.debug')->twice()->andReturn(true);
Log::shouldReceive('debug')->with(Mockery::type('string'), Mockery::type('array'))->twice();
$model->shouldReceive('updated');
$model->shouldReceive('deleted');
Upload::shouldReceive('getModelClass')->withNoArgs()->once()->andReturn($upload);
$upload->shouldReceive('updated');
$upload->shouldReceive('deleted')->with(Mockery::on(function ($closure) use($upload) {
expect_not($closure($upload));
return true;
}));
Upload::shouldReceive('make')->with($upload)->once()->andReturn($repository);
$repository->shouldReceive('getTags')->with($model)->once()->andReturn($tags);
Cache::shouldReceive('tags->flush')->with($tags)->withNoArgs()->once();
$this->repo->shouldReceive('withUpload')->with($repository)->once()->andreturn([$uploadable]);
$uploadable->shouldReceive('getModel->touch')->withNoArgs()->once();
expect_not($this->repo->listenToUpload());
}
示例11: testPlaceholders
public function testPlaceholders()
{
$this->specify("placeholders are replaced with values of other validated fields", function () {
$rules = ['a' => 'min:{{min}}'];
$data = ['a' => 'abcd', 'min' => 3];
$this->assertTrue($this->makeValidator($rules, $data)->passes());
$data = ['a' => 'ab', 'min' => 3];
$this->assertFalse($this->makeValidator($rules, $data)->passes());
$rules = ['a' => '!min:{{min}}'];
$data = ['a' => 'abcd', 'min' => 3];
$this->assertFalse($this->makeValidator($rules, $data)->passes());
$data = ['a' => 'ab', 'min' => 3];
$this->assertTrue($this->makeValidator($rules, $data)->passes());
});
$this->specify("placeholders are replaced with config values", function () {
Config::shouldReceive('get')->with('app.min')->andReturn(3);
$rules = ['a' => 'min:{{app.min}}'];
$data = ['a' => 'abcd'];
$this->assertTrue($this->makeValidator($rules, $data)->passes());
$data = ['a' => 'ab'];
$this->assertFalse($this->makeValidator($rules, $data)->passes());
$rules = ['a' => '!min:{{app.min}}'];
$data = ['a' => 'abcd'];
$this->assertFalse($this->makeValidator($rules, $data)->passes());
$data = ['a' => 'ab'];
$this->assertTrue($this->makeValidator($rules, $data)->passes());
});
}
示例12: testTrueSecureURL
/**
* Test if a key is return if useSecureURLs is configured true
*/
public function testTrueSecureURL()
{
$expectedResult = 'my-key';
$glideConfig['useSecureURLs'] = true;
Config::shouldReceive('get')->with('app.key')->andReturn($expectedResult);
$result = $this->serviceProvider->getSignKey($glideConfig);
$this->assertEquals($expectedResult, $result);
}
示例13: setUp
protected function setUp()
{
// set up config
Config::shouldReceive('get')->zeroOrMoreTimes()->with("chumper_datatable.engine")->andReturn(array('exactWordSearch' => false));
Config::shouldReceive('get')->zeroOrMoreTimes()->with("chumper_datatable.table")->andReturn(array('class' => 'table table-bordered', 'id' => '', 'options' => array("sPaginationType" => "full_numbers", "bProcessing" => false), 'callbacks' => array(), 'noScript' => false, 'table_view' => 'datatable::template', 'script_view' => 'datatable::javascript'));
$this->dt = new Datatable();
$this->mock = Mockery::mock('Illuminate\\Database\\Query\\Builder');
}
示例14: it_generates_not_rewrite_url_if_config_value_is_false
/** @test */
public function it_generates_not_rewrite_url_if_config_value_is_false()
{
Config::shouldReceive('get')->once()->with("imgproxy::rewrite")->andReturn(false);
URL::shouldReceive('to')->once()->with("packages/spescina/imgproxy/timthumb.php?w=100&h=70&zc=1&q=90&src=image/path/url.jpg")->andReturn("http://www.example.com/packages/spescina/imgproxy/timthumb.php?w=100&h=70&zc=1&q=90&src=image/path/url.jpg");
$imgProxy = new Imgproxy();
$url = $imgProxy->link("image/path/url.jpg", 100, 70);
$this->assertEquals("http://www.example.com/packages/spescina/imgproxy/timthumb.php?w=100&h=70&zc=1&q=90&src=image/path/url.jpg", $url);
}
示例15: testGetApiPrefix
public function testGetApiPrefix()
{
Config::shouldReceive('get')->with('andizzle/rest-framework::deprecated')->andReturn(array());
Config::shouldReceive('get')->with('andizzle/rest-framework::version')->andReturn('v1');
Request::shouldReceive('segments')->once()->andReturn(array('api', 'v1', 'test'));
$server = new RestServer();
$this->assertEquals($server->getApiPrefix(), '/api/v1');
}