當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Cache::shouldReceive方法代碼示例

本文整理匯總了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();
 }
開發者ID:C4Tech,項目名稱:laravel-nested-sets,代碼行數:11,代碼來源:RepositoryTest.php

示例2: testMarkRead

 public function testMarkRead()
 {
     $entry = $this->logReader->get()->first();
     Cache::shouldReceive('rememberForever')->once()->andReturn($entry);
     $this->assertEquals($entry, $entry->markRead());
 }
開發者ID:stevebauman,項目名稱:log-reader,代碼行數:6,代碼來源:LogReaderTest.php

示例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);
 }
開發者ID:sekouzed,項目名稱:cabinet,代碼行數:12,代碼來源:DbPostRepositoryTest.php

示例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();
 }
開發者ID:hramose,項目名稱:Auja-Laravel,代碼行數:18,代碼來源:MySQLDatabaseHelperSpec.php

示例5: testForgetCachedAssemblyItems

 public function testForgetCachedAssemblyItems()
 {
     $item = $this->newInventory();
     Cache::shouldReceive('forget')->once()->andReturn(true);
     $this->assertTrue($item->forgetCachedAssemblyItems());
 }
開發者ID:jonjonw,項目名稱:inventory,代碼行數:6,代碼來源:InventoryAssemblyTest.php

示例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);
 }
開發者ID:C4Tech,項目名稱:laravel-support,代碼行數:17,代碼來源:RepositoryTest.php

示例7: testGetValues

 public function testGetValues()
 {
     Cache::shouldReceive('get')->once()->with('judge:values', [])->andReturn([]);
     $adapter = new CacheAdapter();
     self::assertEquals([], $adapter->getValues());
 }
開發者ID:jlis,項目名稱:judge,代碼行數:6,代碼來源:CacheAdapterTest.php

示例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);
 }
開發者ID:19peaches,項目名稱:lumineer,代碼行數:30,代碼來源:LumineerUserTest.php

示例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();
 }
開發者ID:C4Tech,項目名稱:laravel-upload,代碼行數:21,代碼來源:RepositoryTraitTest.php


注:本文中的Illuminate\Support\Facades\Cache::shouldReceive方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。