本文整理汇总了PHP中Illuminate\Support\Facades\Cache::shouldReceive方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::shouldReceive方法的具体用法?PHP Cache::shouldReceive怎么用?PHP Cache::shouldReceive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Cache
的用法示例。
在下文中一共展示了Cache::shouldReceive方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetLeaves
public function testGetLeaves()
{
$this->repo->shouldReceive('formatTag')->with('leaves')->once()->andReturn('tag');
$this->repo->shouldReceive('getCacheId')->with('leaves')->once()->andReturn('hashid');
Cache::shouldReceive('tags->remember')->with(Mockery::type('string'))->with(Mockery::type('string'), Mockery::type('integer'), Mockery::on(function ($closure) {
$this->repo->shouldReceive('leaves->get')->withNoArgs()->once()->andReturn(false);
expect($closure())->false();
return true;
}))->once()->andReturn(true);
expect($this->repo->getLeaves())->true();
}
示例2: testMarkRead
public function testMarkRead()
{
$entry = $this->logReader->get()->first();
Cache::shouldReceive('rememberForever')->once()->andReturn($entry);
$this->assertEquals($entry, $entry->markRead());
}
示例3: testUpdate
public function testUpdate()
{
$this->mockFind(1);
Config::shouldReceive('get')->once()->with('wardrobe.cache')->andReturn(true);
$this->post->shouldReceive('getAttribute')->andReturn(1);
Cache::shouldReceive('forget')->once()->with('post-1')->andReturn(Mockery::self());
$this->post->shouldReceive('fill')->once()->andReturn($this->post)->shouldReceive('save')->once()->withNoArgs()->andReturn($this->post);
$this->post->shouldReceive('tags')->once()->withNoArgs()->andReturn($this->post)->shouldReceive('delete')->once()->withNoArgs()->andReturn($this->post);
$this->post->shouldReceive('tags')->once()->withNoArgs()->andReturn($this->post)->shouldReceive('createMany')->once()->andReturn($this->post);
$returned = $this->DbPostRepository()->update(array('id' => 1, 'title' => 'Wardrobe', 'content' => 'foo bar', 'active' => 1, 'user_id' => 1, 'publish_date' => new Carbon(), 'tags' => array('wardrobe', 'cabinet')));
$this->assertSame($this->post, $returned);
}
示例4:
function it_can_return_computed_column_type_info()
{
Cache::shouldReceive('has')->withAnyArgs()->once()->andReturn(false);
Cache::shouldReceive('put')->withAnyArgs()->once();
$type = \Mockery::mock('Doctrine\\DBAL\\Types\\Type');
$type->shouldReceive('getName')->andReturn('Type');
$column = \Mockery::mock('Doctrine\\DBAL\\Schema\\Column');
$column->shouldReceive('getName')->andReturn('Column');
$column->shouldReceive('getType')->andReturn($type);
$table = \Mockery::mock('Doctrine\\DBAL\\Schema\\Table');
$table->shouldReceive('getName')->andReturn('Table');
$table->shouldReceive('getColumn')->withAnyArgs()->andReturn($column);
$schemaManager = \Mockery::mock('Doctrine\\DBAL\\Schema\\AbstractSchemaManager');
DB::shouldReceive('getDoctrineSchemaManager')->once()->andReturn($schemaManager);
$schemaManager->shouldReceive('listTables')->once()->andReturn(['Table' => $table]);
$this->getColumnType('Table', 'Column')->shouldBe('Type');
\Mockery::close();
}
示例5: testForgetCachedAssemblyItems
public function testForgetCachedAssemblyItems()
{
$item = $this->newInventory();
Cache::shouldReceive('forget')->once()->andReturn(true);
$this->assertTrue($item->forgetCachedAssemblyItems());
}
示例6: testGetAllCollection
public function testGetAllCollection()
{
$cache_id = 'cache-tag';
$collection_model = Mockery::mock('C4tech\\Support\\Contracts\\ModelInterface');
$collection = new Collection([$collection_model]);
$response = 'awwyeah';
$model = Mockery::mock('C4tech\\Support\\Contracts\\ModelInterface[all]');
$model->shouldReceive('all')->withNoArgs()->once()->andReturn($collection);
$this->repo->shouldReceive('getModelClass')->withNoArgs()->once()->andReturn($model);
$this->repo->shouldReceive('getCacheId')->with('all', null)->once()->andReturn($cache_id);
$this->repo->shouldReceive('makeCollection')->with($collection)->once()->andReturn($response);
Cache::shouldReceive('tags->remember')->with([$model])->with($cache_id, Mockery::type('integer'), Mockery::on(function ($closure) use($response) {
expect($closure())->equals($response);
return true;
}))->once()->andReturn(true);
expect($this->repo->getAll())->equals(true);
}
示例7: testGetValues
public function testGetValues()
{
Cache::shouldReceive('get')->once()->with('judge:values', [])->andReturn([]);
$adapter = new CacheAdapter();
self::assertEquals([], $adapter->getValues());
}
示例8: testDetachRole
public function testDetachRole()
{
/*
|------------------------------------------------------------
| Set
|------------------------------------------------------------
*/
$roleObject = m::mock('Role');
$roleArray = ['id' => 2];
$user = m::mock('HasRoleUser')->makePartial();
/*
|------------------------------------------------------------
| Expectation
|------------------------------------------------------------
*/
$roleObject->shouldReceive('getKey')->andReturn(1);
$user->shouldReceive('roles')->andReturn($user);
$user->shouldReceive('detach')->with(1)->once()->ordered();
$user->shouldReceive('detach')->with(2)->once()->ordered();
$user->shouldReceive('detach')->with(3)->once()->ordered();
Cache::shouldReceive('forget')->times(3);
/*
|------------------------------------------------------------
| Assertion
|------------------------------------------------------------
*/
$user->detachRole($roleObject);
$user->detachRole($roleArray);
$user->detachRole(3);
}
示例9: testGetUploads
public function testGetUploads()
{
$tag = 'test-tag';
$object = Mockery::mock('C4tech\\Upload\\Contracts\\UploadModelInterface');
$new_object = 'Demo!';
$collection = Mockery::mock('Illuminate\\Support\\Collection[map]', [[$object]]);
$new_collection = 'TestCollection';
$this->repo->shouldReceive('getTags')->with('uploads')->once()->andReturn([$tag]);
$this->repo->shouldReceive('getCacheId')->with('uploads')->once()->andReturn($tag);
$this->repo->shouldReceive('uploads->get')->withNoArgs()->once()->andReturn($collection);
Upload::shouldReceive('make')->with($object)->once()->andReturn($new_object);
$collection->shouldReceive('map')->with(Mockery::on(function ($closure) use($object, $new_object) {
expect($closure($object))->equals($new_object);
return true;
}))->once()->andReturn($new_collection);
Cache::shouldReceive('tags->remember')->with([$tag])->with($tag, Mockery::type('integer'), Mockery::on(function ($closure) use($new_collection) {
expect($closure())->equals($new_collection);
return true;
}))->once()->andReturn(true);
expect($this->repo->getUploads())->true();
}