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
0
 public function testMarkRead()
 {
     $entry = $this->logReader->get()->first();
     Cache::shouldReceive('rememberForever')->once()->andReturn($entry);
     $this->assertEquals($entry, $entry->markRead());
 }
示例#3
0
 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);
 }
 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();
 }
 public function testForgetCachedAssemblyItems()
 {
     $item = $this->newInventory();
     Cache::shouldReceive('forget')->once()->andReturn(true);
     $this->assertTrue($item->forgetCachedAssemblyItems());
 }
示例#6
0
 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
0
 public function testGetValues()
 {
     Cache::shouldReceive('get')->once()->with('judge:values', [])->andReturn([]);
     $adapter = new CacheAdapter();
     self::assertEquals([], $adapter->getValues());
 }
示例#8
0
 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);
 }
 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();
 }